Skip to content

Commit

Permalink
Some test fixes (#5084)
Browse files Browse the repository at this point in the history
* internal/session: update variable name in test

This was missed in #5071

* internal/tests/cluster: skip failing tests

These tests will need to be fixed or removed. It is not
clear why they are failing, but they are always failing.

* Makefile: try upgrading golangci-lint

* internal/host/plugin: fix flaky test

Hosts contain IP addresses in string form, whose
order is not defined.
  • Loading branch information
johanbrandhorst authored Sep 9, 2024
1 parent d45aa40 commit a830892
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ golangci-lint:

if [ "$(GOLINT_INSTALLED)" = "" ]; then \
curl -sSfL \
https://raw.githubusercontent.com/golangci/golangci-lint/9a8a056e9fe49c0e9ed2287aedce1022c79a115b/install.sh | sh -s -- -b $(GO_PATH)/bin v1.55.2; \
https://raw.githubusercontent.com/golangci/golangci-lint/9a8a056e9fe49c0e9ed2287aedce1022c79a115b/install.sh | sh -s -- -b $(GO_PATH)/bin v1.60.3; \
fi;

.PHONY: cleangen
Expand Down
9 changes: 9 additions & 0 deletions internal/host/plugin/repository_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ func TestJob_UpsertHosts(t *testing.T) {
cmpopts.SortSlices(func(x, y *Host) bool {
return x.GetPublicId() < y.GetPublicId()
}),
cmpopts.SortSlices(func(x, y string) bool {
return x < y
}),
),
)

Expand All @@ -242,6 +245,9 @@ func TestJob_UpsertHosts(t *testing.T) {
cmpopts.SortSlices(func(x, y *Host) bool {
return x.GetPublicId() < y.GetPublicId()
}),
cmpopts.SortSlices(func(x, y string) bool {
return x < y
}),
),
)
plg := plg
Expand Down Expand Up @@ -274,6 +280,9 @@ func TestJob_UpsertHosts(t *testing.T) {
got,
cmpopts.IgnoreUnexported(Host{}, store.Host{}),
cmpopts.IgnoreTypes(&timestamp.Timestamp{}),
cmpopts.SortSlices(func(x, y string) bool {
return x < y
}),
),
)
assert.Empty(
Expand Down
2 changes: 1 addition & 1 deletion internal/session/job_session_cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestSessionConnectionCleanupJob(t *testing.T) {

// Create the job.
job, err := newSessionConnectionCleanupJob(ctx, rw, gracePeriod)
job.gracePeriod = gracePeriod // by-pass factory assert so we dont have to wait so long
job.workerStatusGracePeriod = gracePeriod // by-pass factory assert so we dont have to wait so long
require.NoError(err)

// sleep the status grace period.
Expand Down
10 changes: 10 additions & 0 deletions internal/tests/cluster/x509_verification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"crypto/x509"
"errors"
"fmt"
"io"
"net"
"net/http"
"sync"
Expand Down Expand Up @@ -185,13 +186,22 @@ func TestCustomX509Verification_Client(t *testing.T) {
}

func TestCustomX509Verification_Server(t *testing.T) {
t.Skip("These tests are currently not working and will need further investigation")

ec := event.TestEventerConfig(t, "TestCustomX509Verification_Server", event.TestWithObservationSink(t), event.TestWithSysSink(t))
testLock := &sync.Mutex{}
logger := hclog.New(&hclog.LoggerOptions{
Mutex: testLock,
Name: "test",
Level: hclog.Trace,
})
require.NoError(t, event.InitSysEventer(logger, testLock, "use-TestCustomX509Verification_Server", event.WithEventerConfig(&ec.EventerConfig)))
t.Cleanup(func() { event.TestResetSystEventer(t) })
t.Cleanup(func() {
all, err := io.ReadAll(ec.AllEvents)
require.NoError(t, err)
t.Log(string(all))
})

t.Run("bad cert pool", testCustomX509Verification_Server(ec, x509.NewCertPool(), "", "bad certificate"))
t.Run("bad dns name", testCustomX509Verification_Server(ec, nil, "foobar", "bad certificate"))
Expand Down

0 comments on commit a830892

Please sign in to comment.