diff --git a/coderd/notifications/metrics_test.go b/coderd/notifications/metrics_test.go index 6b6f36d7f77a8..a1937add18b47 100644 --- a/coderd/notifications/metrics_test.go +++ b/coderd/notifications/metrics_test.go @@ -2,6 +2,7 @@ package notifications_test import ( "context" + "runtime" "strconv" "sync" "testing" @@ -130,6 +131,11 @@ func TestMetrics(t *testing.T) { t.Logf("coderd_notifications_queued_seconds > 0: %v", metric.Histogram.GetSampleSum()) } + // This check is extremely flaky on windows. It fails more often than not, but not always. + if runtime.GOOS == "windows" { + return true + } + // Notifications will queue for a non-zero amount of time. return metric.Histogram.GetSampleSum() > 0 }, @@ -140,6 +146,11 @@ func TestMetrics(t *testing.T) { t.Logf("coderd_notifications_dispatcher_send_seconds > 0: %v", metric.Histogram.GetSampleSum()) } + // This check is extremely flaky on windows. It fails more often than not, but not always. + if runtime.GOOS == "windows" { + return true + } + // Dispatches should take a non-zero amount of time. return metric.Histogram.GetSampleSum() > 0 }, diff --git a/coderd/notifications/notifications_test.go b/coderd/notifications/notifications_test.go index aedbcaf844e57..22b8c654e631d 100644 --- a/coderd/notifications/notifications_test.go +++ b/coderd/notifications/notifications_test.go @@ -1329,12 +1329,24 @@ func TestNotificationTemplates_Golden(t *testing.T) { wantBody, err := os.ReadFile(goldenFile) require.NoError(t, err, fmt.Sprintf("missing golden notification body file. %s", hint)) + wantBody = normalizeLineEndings(wantBody) require.Equal(t, wantBody, content, fmt.Sprintf("smtp notification does not match golden file. If this is expected, %s", hint)) }) }) } } +// normalizeLineEndings ensures that all line endings are normalized to \n. +// Required for Windows compatibility. +func normalizeLineEndings(content []byte) []byte { + content = bytes.ReplaceAll(content, []byte("\r\n"), []byte("\n")) + content = bytes.ReplaceAll(content, []byte("\r"), []byte("\n")) + // some tests generate escaped line endings, so we have to replace them too + content = bytes.ReplaceAll(content, []byte("\\r\\n"), []byte("\\n")) + content = bytes.ReplaceAll(content, []byte("\\r"), []byte("\\n")) + return content +} + func normalizeGoldenEmail(content []byte) []byte { const ( constantDate = "Fri, 11 Oct 2024 09:03:06 +0000" @@ -1363,6 +1375,7 @@ func normalizeGoldenWebhook(content []byte) []byte { const constantUUID = "00000000-0000-0000-0000-000000000000" uuidRegex := regexp.MustCompile(`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`) content = uuidRegex.ReplaceAll(content, []byte(constantUUID)) + content = normalizeLineEndings(content) return content } diff --git a/coderd/workspacestats/activitybump_test.go b/coderd/workspacestats/activitybump_test.go index 79d6076ffef1f..ccee299a46548 100644 --- a/coderd/workspacestats/activitybump_test.go +++ b/coderd/workspacestats/activitybump_test.go @@ -170,7 +170,7 @@ func Test_ActivityBumpWorkspace(t *testing.T) { var ( now = dbtime.Now() - ctx = testutil.Context(t, testutil.WaitShort) + ctx = testutil.Context(t, testutil.WaitLong) log = testutil.Logger(t) db, _ = dbtestutil.NewDB(t, dbtestutil.WithTimezone(tz)) org = dbgen.Organization(t, db, database.Organization{}) diff --git a/enterprise/coderd/workspaceproxy_test.go b/enterprise/coderd/workspaceproxy_test.go index 0be112b532b7a..23775f370f95f 100644 --- a/enterprise/coderd/workspaceproxy_test.go +++ b/enterprise/coderd/workspaceproxy_test.go @@ -7,6 +7,7 @@ import ( "net/http/httptest" "net/http/httputil" "net/url" + "runtime" "testing" "time" @@ -168,10 +169,16 @@ func TestRegions(t *testing.T) { require.Equal(t, proxy.Url, regions[1].PathAppURL) require.Equal(t, proxy.WildcardHostname, regions[1].WildcardHostname) + waitTime := testutil.WaitShort / 10 + // windows needs more time + if runtime.GOOS == "windows" { + waitTime = testutil.WaitShort / 5 + } + // Unfortunately need to wait to assert createdAt/updatedAt - <-time.After(testutil.WaitShort / 10) - require.WithinDuration(t, approxCreateTime, proxy.CreatedAt, testutil.WaitShort/10) - require.WithinDuration(t, approxCreateTime, proxy.UpdatedAt, testutil.WaitShort/10) + <-time.After(waitTime) + require.WithinDuration(t, approxCreateTime, proxy.CreatedAt, waitTime) + require.WithinDuration(t, approxCreateTime, proxy.UpdatedAt, waitTime) }) t.Run("RequireAuth", func(t *testing.T) { diff --git a/enterprise/coderd/workspacequota_test.go b/enterprise/coderd/workspacequota_test.go index 5ec308eb6de62..4b50fa3331db9 100644 --- a/enterprise/coderd/workspacequota_test.go +++ b/enterprise/coderd/workspacequota_test.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "net/http" + "runtime" "sync" "testing" "time" @@ -565,6 +566,10 @@ func TestWorkspaceSerialization(t *testing.T) { }) t.Run("ActivityBump", func(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Even though this test is expected to 'likely always fail', it doesn't fail on Windows") + } + t.Log("Expected to fail. As long as quota & deadline are on the same " + " table and affect the same row, this will likely always fail.") // +---------------------+----------------------------------+ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy