chore(healthcheck): fix DERP test flakes (#7211)

This commit is contained in:
Colin Adler
2023-04-19 20:03:05 -05:00
committed by GitHub
parent f60b5579a7
commit 5f5edb18b0
6 changed files with 161 additions and 41 deletions

View File

@ -19,6 +19,7 @@ import (
"github.com/coder/coder/coderd/healthcheck"
"github.com/coder/coder/tailnet"
"github.com/coder/coder/testutil"
)
//nolint:tparallel
@ -66,8 +67,7 @@ func TestDERP(t *testing.T) {
for _, node := range region.NodeReports {
assert.True(t, node.Healthy)
assert.True(t, node.CanExchangeMessages)
// TODO: test this without serializing time.Time over the wire.
// assert.Positive(t, node.RoundTripPing)
assert.Positive(t, node.RoundTripPing)
assert.Len(t, node.ClientLogs, 2)
assert.Len(t, node.ClientLogs[0], 1)
assert.Len(t, node.ClientErrs[0], 0)
@ -81,9 +81,13 @@ func TestDERP(t *testing.T) {
}
})
t.Run("OK/Tailscale/Dallas", func(t *testing.T) {
t.Run("Tailscale/Dallas/OK", func(t *testing.T) {
t.Parallel()
if testutil.InCI() {
t.Skip("This test depends on reaching out over the network to Tailscale servers, which is inherently flaky.")
}
derpSrv := derp.NewServer(key.NewNode(), func(format string, args ...any) { t.Logf(format, args...) })
defer derpSrv.Close()
srv := httptest.NewServer(derphttp.Handler(derpSrv))
@ -107,8 +111,7 @@ func TestDERP(t *testing.T) {
for _, node := range region.NodeReports {
assert.True(t, node.Healthy)
assert.True(t, node.CanExchangeMessages)
// TODO: test this without serializing time.Time over the wire.
// assert.Positive(t, node.RoundTripPing)
assert.Positive(t, node.RoundTripPing)
assert.Len(t, node.ClientLogs, 2)
assert.Len(t, node.ClientLogs[0], 1)
assert.Len(t, node.ClientErrs[0], 0)
@ -171,13 +174,12 @@ func TestDERP(t *testing.T) {
for _, node := range region.NodeReports {
assert.False(t, node.Healthy)
assert.True(t, node.CanExchangeMessages)
// TODO: test this without serializing time.Time over the wire.
// assert.Positive(t, node.RoundTripPing)
assert.Positive(t, node.RoundTripPing)
assert.Len(t, node.ClientLogs, 2)
assert.Len(t, node.ClientLogs[0], 3)
assert.Len(t, node.ClientLogs[1], 3)
assert.Len(t, node.ClientErrs, 2)
assert.Len(t, node.ClientErrs[0], 1)
assert.Len(t, node.ClientErrs[0], 1) // this
assert.Len(t, node.ClientErrs[1], 1)
assert.True(t, node.UsesWebsocket)
@ -188,7 +190,7 @@ func TestDERP(t *testing.T) {
}
})
t.Run("OK/STUNOnly", func(t *testing.T) {
t.Run("STUNOnly/OK", func(t *testing.T) {
t.Parallel()
var (