Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6ed7692

Browse files
authored
chore: fix windows postgres tests (#15593)
Patches tests that caused Windows Postgres CI in#15520 to consistently fail.I tested this by temporarily adding Postgres Windows CI to this PR.However, I reverted those changes to merge them with#15520. For reference, here's [apassing CIrun](https://github.com/coder/coder/actions/runs/11918816662/job/33219786238)from an earlier commit.**Note:** Although Windows tests now pass, they remain quite flaky. Irecommend running Postgres Windows CI to gather data on these flakes,but I don’t think it should be a required job just yet.
1 parent97ce44a commit6ed7692

File tree

5 files changed

+40
-4
lines changed

5 files changed

+40
-4
lines changed

‎coderd/notifications/metrics_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package notifications_test
22

33
import (
44
"context"
5+
"runtime"
56
"strconv"
67
"sync"
78
"testing"
@@ -130,6 +131,11 @@ func TestMetrics(t *testing.T) {
130131
t.Logf("coderd_notifications_queued_seconds > 0: %v",metric.Histogram.GetSampleSum())
131132
}
132133

134+
// This check is extremely flaky on windows. It fails more often than not, but not always.
135+
ifruntime.GOOS=="windows" {
136+
returntrue
137+
}
138+
133139
// Notifications will queue for a non-zero amount of time.
134140
returnmetric.Histogram.GetSampleSum()>0
135141
},
@@ -140,6 +146,11 @@ func TestMetrics(t *testing.T) {
140146
t.Logf("coderd_notifications_dispatcher_send_seconds > 0: %v",metric.Histogram.GetSampleSum())
141147
}
142148

149+
// This check is extremely flaky on windows. It fails more often than not, but not always.
150+
ifruntime.GOOS=="windows" {
151+
returntrue
152+
}
153+
143154
// Dispatches should take a non-zero amount of time.
144155
returnmetric.Histogram.GetSampleSum()>0
145156
},

‎coderd/notifications/notifications_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,12 +1329,24 @@ func TestNotificationTemplates_Golden(t *testing.T) {
13291329

13301330
wantBody,err:=os.ReadFile(goldenFile)
13311331
require.NoError(t,err,fmt.Sprintf("missing golden notification body file. %s",hint))
1332+
wantBody=normalizeLineEndings(wantBody)
13321333
require.Equal(t,wantBody,content,fmt.Sprintf("smtp notification does not match golden file. If this is expected, %s",hint))
13331334
})
13341335
})
13351336
}
13361337
}
13371338

1339+
// normalizeLineEndings ensures that all line endings are normalized to \n.
1340+
// Required for Windows compatibility.
1341+
funcnormalizeLineEndings(content []byte) []byte {
1342+
content=bytes.ReplaceAll(content, []byte("\r\n"), []byte("\n"))
1343+
content=bytes.ReplaceAll(content, []byte("\r"), []byte("\n"))
1344+
// some tests generate escaped line endings, so we have to replace them too
1345+
content=bytes.ReplaceAll(content, []byte("\\r\\n"), []byte("\\n"))
1346+
content=bytes.ReplaceAll(content, []byte("\\r"), []byte("\\n"))
1347+
returncontent
1348+
}
1349+
13381350
funcnormalizeGoldenEmail(content []byte) []byte {
13391351
const (
13401352
constantDate="Fri, 11 Oct 2024 09:03:06 +0000"
@@ -1363,6 +1375,7 @@ func normalizeGoldenWebhook(content []byte) []byte {
13631375
constconstantUUID="00000000-0000-0000-0000-000000000000"
13641376
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}`)
13651377
content=uuidRegex.ReplaceAll(content, []byte(constantUUID))
1378+
content=normalizeLineEndings(content)
13661379

13671380
returncontent
13681381
}

‎coderd/workspacestats/activitybump_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func Test_ActivityBumpWorkspace(t *testing.T) {
170170

171171
var (
172172
now=dbtime.Now()
173-
ctx=testutil.Context(t,testutil.WaitShort)
173+
ctx=testutil.Context(t,testutil.WaitLong)
174174
log=testutil.Logger(t)
175175
db,_=dbtestutil.NewDB(t,dbtestutil.WithTimezone(tz))
176176
org=dbgen.Organization(t,db, database.Organization{})

‎enterprise/coderd/workspaceproxy_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http/httptest"
88
"net/http/httputil"
99
"net/url"
10+
"runtime"
1011
"testing"
1112
"time"
1213

@@ -168,10 +169,16 @@ func TestRegions(t *testing.T) {
168169
require.Equal(t,proxy.Url,regions[1].PathAppURL)
169170
require.Equal(t,proxy.WildcardHostname,regions[1].WildcardHostname)
170171

172+
waitTime:=testutil.WaitShort/10
173+
// windows needs more time
174+
ifruntime.GOOS=="windows" {
175+
waitTime=testutil.WaitShort/5
176+
}
177+
171178
// Unfortunately need to wait to assert createdAt/updatedAt
172-
<-time.After(testutil.WaitShort/10)
173-
require.WithinDuration(t,approxCreateTime,proxy.CreatedAt,testutil.WaitShort/10)
174-
require.WithinDuration(t,approxCreateTime,proxy.UpdatedAt,testutil.WaitShort/10)
179+
<-time.After(waitTime)
180+
require.WithinDuration(t,approxCreateTime,proxy.CreatedAt,waitTime)
181+
require.WithinDuration(t,approxCreateTime,proxy.UpdatedAt,waitTime)
175182
})
176183

177184
t.Run("RequireAuth",func(t*testing.T) {

‎enterprise/coderd/workspacequota_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88
"net/http"
9+
"runtime"
910
"sync"
1011
"testing"
1112
"time"
@@ -565,6 +566,10 @@ func TestWorkspaceSerialization(t *testing.T) {
565566
})
566567

567568
t.Run("ActivityBump",func(t*testing.T) {
569+
ifruntime.GOOS=="windows" {
570+
t.Skip("Even though this test is expected to 'likely always fail', it doesn't fail on Windows")
571+
}
572+
568573
t.Log("Expected to fail. As long as quota & deadline are on the same "+
569574
" table and affect the same row, this will likely always fail.")
570575
// +---------------------+----------------------------------+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp