Skip to content

Commit b7789cf

Browse files
committed
test(coderd): fix flake on TestWorkspaceBuildTimings
1 parent c6396e3 commit b7789cf

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

coderd/workspacebuilds_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,16 +1214,15 @@ func TestWorkspaceBuildTimings(t *testing.T) {
12141214
ActiveVersionID: version.ID,
12151215
CreatedBy: owner.UserID,
12161216
})
1217-
ws := dbgen.Workspace(t, db, database.Workspace{
1218-
OwnerID: owner.UserID,
1219-
OrganizationID: owner.OrganizationID,
1220-
TemplateID: template.ID,
1221-
})
12221217

1223-
// Create a build to attach timings
1224-
var buildNumber int32
1218+
// Tests will run in parallel. To avoid conflicts and race conditions on the
1219+
// build number, each test will have its own workspace and build.
12251220
makeBuild := func() database.WorkspaceBuild {
1226-
buildNumber++
1221+
ws := dbgen.Workspace(t, db, database.Workspace{
1222+
OwnerID: owner.UserID,
1223+
OrganizationID: owner.OrganizationID,
1224+
TemplateID: template.ID,
1225+
})
12271226
jobID := uuid.New()
12281227
job := dbgen.ProvisionerJob(t, db, pubsub, database.ProvisionerJob{
12291228
ID: jobID,
@@ -1235,7 +1234,7 @@ func TestWorkspaceBuildTimings(t *testing.T) {
12351234
TemplateVersionID: version.ID,
12361235
InitiatorID: owner.UserID,
12371236
JobID: job.ID,
1238-
BuildNumber: buildNumber,
1237+
BuildNumber: 1,
12391238
})
12401239
}
12411240

0 commit comments

Comments
 (0)