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

fix(coderd/provisionerdserver): fix test flake in TestHeartbeat#11808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 4 commits intomainfromcj/flake-provisionerdserver-heartbeat
Jan 25, 2024
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletionscoderd/provisionerdserver/provisionerdserver_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ func testUserQuietHoursScheduleStore() *atomic.Pointer[schedule.UserQuietHoursSc

func TestAcquireJob_LongPoll(t *testing.T) {
t.Parallel()
//nolint:dogsled // ૮・ᴥ・ა
//nolint:dogsled
srv, _, _, _ := setup(t, false, &overrides{acquireJobLongPollDuration: time.Microsecond})
job, err := srv.AcquireJob(context.Background(), nil)
require.NoError(t, err)
Expand All@@ -76,7 +76,7 @@ func TestAcquireJob_LongPoll(t *testing.T) {

func TestAcquireJobWithCancel_Cancel(t *testing.T) {
t.Parallel()
//nolint:dogsled // ૮ ˶′ﻌ ‵˶ ა
//nolint:dogsled
srv, _, _, _ := setup(t, false, nil)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancel()
Expand All@@ -101,8 +101,8 @@ func TestAcquireJobWithCancel_Cancel(t *testing.T) {
func TestHeartbeat(t *testing.T) {
t.Parallel()

ctx, cancel:=context.WithCancel(context.Background())
t.Cleanup(cancel)
numBeats:=3
ctx := testutil.Context(t, testutil.WaitShort)
heartbeatChan := make(chan struct{})
heartbeatFn := func(hbCtx context.Context) error {
t.Logf("heartbeat")
Expand All@@ -114,28 +114,17 @@ func TestHeartbeat(t *testing.T) {
return nil
}
}
//nolint:dogsled // 。:゚૮ ˶ˆ ﻌ ˆ˶ ა ゚:。
//nolint:dogsled
_, _, _, _ = setup(t, false, &overrides{
ctx: ctx,
heartbeatFn: heartbeatFn,
heartbeatInterval: testutil.IntervalFast,
})

_, ok := <-heartbeatChan
require.True(t, ok, "first heartbeat not received")
_, ok = <-heartbeatChan
require.True(t, ok, "second heartbeat not received")
cancel()
// Close the channel to ensure we don't receive any more heartbeats.
// The test will fail if we do.
defer func() {
if r := recover(); r != nil {
t.Fatalf("heartbeat received after cancel: %v", r)
}
}()

close(heartbeatChan)
<-time.After(testutil.IntervalMedium)
for i := 0; i < numBeats; i++ {
testutil.RequireRecvCtx(ctx, t, heartbeatChan)
}
// goleak.VerifyTestMain ensures that the heartbeat goroutine does not leak
}

func TestAcquireJob(t *testing.T) {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp