- Notifications
You must be signed in to change notification settings - Fork1.1k
fix: fix flake in TestExecutorAutostartSkipsWhenNoProvisionersAvailable#19478
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
6fa1e31d269c7f78efcc8e86b4691c0520483e8699File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4,6 +4,7 @@ import ( | ||
| "context" | ||
| "database/sql" | ||
| "errors" | ||
| "sync" | ||
| "testing" | ||
| "time" | ||
| @@ -1720,19 +1721,32 @@ func TestExecutorAutostartSkipsWhenNoProvisionersAvailable(t *testing.T) { | ||
| // Stop the workspace while provisioner is available | ||
| workspace = coderdtest.MustTransitionWorkspace(t, client, workspace.ID, codersdk.WorkspaceTransitionStart, codersdk.WorkspaceTransitionStop) | ||
| p, err := coderdtest.GetProvisionerForTags(db, time.Now(), workspace.OrganizationID, provisionerDaemonTags) | ||
| require.NoError(t, err, "Error getting provisioner for workspace") | ||
| var wg sync.WaitGroup | ||
| wg.Add(2) | ||
| next := sched.Next(workspace.LatestBuild.CreatedAt) | ||
| go func() { | ||
| defer wg.Done() | ||
| // Ensure the provisioner is stale | ||
| staleTime := next.Add(-(provisionerdserver.StaleInterval * 2)) | ||
| coderdtest.UpdateProvisionerLastSeenAt(t, db, p.ID, staleTime) | ||
| p, err = coderdtest.GetProvisionerForTags(db, time.Now(), workspace.OrganizationID, provisionerDaemonTags) | ||
| assert.NoError(t, err, "Error getting provisioner for workspace") | ||
| assert.Eventually(t, func() bool { return p.LastSeenAt.Time.UnixNano() == staleTime.UnixNano() }, testutil.WaitMedium, testutil.IntervalFast) | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. nit: Suggest instead checking less than or equal to staleTime instead instead? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This should be fine, We could make this more explicitly enforced by also double checking that in addition to the | ||
| }() | ||
| go func() { | ||
| defer wg.Done() | ||
| // Ensure the provisioner is gone or stale before triggering the autobuild | ||
| coderdtest.MustWaitForProvisionersUnavailable(t, db, workspace, provisionerDaemonTags, next) | ||
| // Trigger autobuild | ||
| tickCh <- next | ||
| }() | ||
| wg.Wait() | ||
| stats := <-statsCh | ||
| @@ -1758,5 +1772,5 @@ func TestExecutorAutostartSkipsWhenNoProvisionersAvailable(t *testing.T) { | ||
| }() | ||
| stats = <-statsCh | ||
| assert.Len(t, stats.Transitions, 1, "should create builds when provisioners are available") | ||
| } | ||
Uh oh!
There was an error while loading.Please reload this page.