8000 chore: fix TestWorkspaceAutobuild/DormancyThresholdOK flake by sreya · Pull Request #11251 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: fix TestWorkspaceAutobuild/DormancyThresholdOK flake #11251

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Changes from 1 commit
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
Next Next commit
chore: fix TestWorkspaceAutobuild/DormancyThresholdOK flake
  • Loading branch information
sreya committed Dec 17, 2023
commit 32e721756effc85474a495d8bad2e2831b96d6a3
15 changes: 10 additions & 5 deletions enterprise/coderd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,18 @@ func TestWorkspaceAutobuild(t *testing.T) {
ws = coderdtest.MustWorkspace(t, client, ws.ID)
require.NotNil(t, ws.DormantAt)

coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, ws.LatestBuild.ID)
build := coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, ws.LatestBuild.ID)
require.Equal(t, codersdk.WorkspaceTransitionStop, build.Transition)
// We should get 2 audit logs, one for stopping the workspace, and one for
// making it dormant.
alogs := auditRecorder.AuditLogs()
require.Len(t, alogs, 2)

for _, alog := range alogs {
require.Eventually(t, func() bool {
// There's the potential for a race between when we commit the transaction for
// indicating a workspace build is complete and when we write the audit
// log, so we need to spin a little bit until the audit log is completed.
return len(auditRecorder.AuditLogs()) == 2
}, testutil.WaitMedium, testutil.IntervalFast)

for _, alog := range auditRecorder.AuditLogs() {
require.Equal(t, int32(http.StatusOK), alog.StatusCode)

switch alog.Action {
Expand Down
0