From a428d12a05d6796a43d1f8914a7afc426fa7b0cc Mon Sep 17 00:00:00 2001 From: Kacper Sawicki Date: Mon, 25 Aug 2025 12:09:03 +0000 Subject: [PATCH 1/2] test: add sleep interval in TestPatchCancelWorkspaceBuild --- coderd/workspacebuilds_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/coderd/workspacebuilds_test.go b/coderd/workspacebuilds_test.go index e888115093a9b..a2fe198eba252 100644 --- a/coderd/workspacebuilds_test.go +++ b/coderd/workspacebuilds_test.go @@ -577,6 +577,9 @@ func TestPatchCancelWorkspaceBuild(t *testing.T) { build, err = client.WorkspaceBuild(ctx, workspace.LatestBuild.ID) return assert.NoError(t, err) && build.Job.Status == codersdk.ProvisionerJobRunning }, testutil.WaitShort, testutil.IntervalFast) + + time.Sleep(testutil.IntervalMedium) + err := client.CancelWorkspaceBuild(ctx, build.ID, codersdk.CancelWorkspaceBuildParams{}) require.NoError(t, err) require.Eventually(t, func() bool { From 78eecfbb832cdc2fdbffedc53dcab8367d7a33b1 Mon Sep 17 00:00:00 2001 From: Kacper Sawicki Date: Wed, 27 Aug 2025 11:11:04 +0000 Subject: [PATCH 2/2] instead of sleep use eventually --- coderd/workspacebuilds_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/coderd/workspacebuilds_test.go b/coderd/workspacebuilds_test.go index a2fe198eba252..994411a8b3817 100644 --- a/coderd/workspacebuilds_test.go +++ b/coderd/workspacebuilds_test.go @@ -578,10 +578,11 @@ func TestPatchCancelWorkspaceBuild(t *testing.T) { return assert.NoError(t, err) && build.Job.Status == codersdk.ProvisionerJobRunning }, testutil.WaitShort, testutil.IntervalFast) - time.Sleep(testutil.IntervalMedium) + require.Eventually(t, func() bool { + err := client.CancelWorkspaceBuild(ctx, build.ID, codersdk.CancelWorkspaceBuildParams{}) + return assert.NoError(t, err) + }, testutil.WaitShort, testutil.IntervalMedium) - err := client.CancelWorkspaceBuild(ctx, build.ID, codersdk.CancelWorkspaceBuildParams{}) - require.NoError(t, err) require.Eventually(t, func() bool { var err error build, err = client.WorkspaceBuild(ctx, build.ID)