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

Commit3e1f6af

Browse files
authored
chore: work around timing issue in TestReplicas/ErrorWithoutLicense (#20002)
Closescoder/internal#268Wraps the assertions in a `testutil.Eventually` so that hopefully anytransient timing issues resolve themselves. If this does not resolve theissue, we may need to plumb through some kind of `chan struct{}` into`api.Entitlements.Update()`
1 parentaaa5071 commit3e1f6af

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

‎enterprise/coderd/replicas_test.go‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"testing"
77
"time"
88

9+
"github.com/stretchr/testify/assert"
910
"github.com/stretchr/testify/require"
1011

1112
"github.com/coder/coder/v2/coderd/coderdtest"
@@ -24,6 +25,7 @@ func TestReplicas(t *testing.T) {
2425
}
2526
t.Run("ErrorWithoutLicense",func(t*testing.T) {
2627
t.Parallel()
28+
ctx:=testutil.Context(t,testutil.WaitLong)
2729
// This will error because replicas are expected to instantly report
2830
// errors when the license is not present.
2931
db,pubsub:=dbtestutil.NewDB(t)
@@ -46,14 +48,19 @@ func TestReplicas(t *testing.T) {
4648
ReplicaErrorGracePeriod:time.Nanosecond,
4749
})
4850
secondClient.SetSessionToken(firstClient.SessionToken())
49-
ents,err:=secondClient.Entitlements(context.Background())
50-
require.NoError(t,err)
51-
require.Len(t,ents.Errors,1)
51+
52+
testutil.Eventually(ctx,t,func(ctx context.Context) (donebool) {
53+
ents,err:=secondClient.Entitlements(ctx)
54+
returnassert.NoError(t,err,"unexpected error from secondClient.Entitlements")&&
55+
len(ents.Errors)==1
56+
},testutil.IntervalFast)
5257
_=secondAPI.Close()
5358

54-
ents,err=firstClient.Entitlements(context.Background())
55-
require.NoError(t,err)
56-
require.Len(t,ents.Warnings,0)
59+
testutil.Eventually(ctx,t,func(ctx context.Context) (donebool) {
60+
ents,err:=firstClient.Entitlements(ctx)
61+
returnassert.NoError(t,err,"unexpected error from firstClient.Entitlements")&&
62+
len(ents.Warnings)==0
63+
},testutil.IntervalFast)
5764
})
5865
t.Run("DoesNotErrorBeforeGrace",func(t*testing.T) {
5966
t.Parallel()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp