MCPcopy Index your code
hub / github.com/coder/coder / MustWaitForProvisionersUnavailable

Function MustWaitForProvisionersUnavailable

coderd/coderdtest/coderdtest.go:1850–1875  ·  view source on GitHub ↗

MustWaitForProvisionersUnavailable waits for provisioners to become unavailable for a specific workspace

(t *testing.T, db database.Store, workspace codersdk.Workspace, tags map[string]string, checkTime time.Time)

Source from the content-addressed store, hash-verified

1848
1849// MustWaitForProvisionersUnavailable waits for provisioners to become unavailable for a specific workspace
1850func MustWaitForProvisionersUnavailable(t *testing.T, db database.Store, workspace codersdk.Workspace, tags map[string]string, checkTime time.Time) {
1851 t.Helper()
1852 ctx := ctxWithProvisionerPermissions(testutil.Context(t, testutil.WaitMedium))
1853
1854 testutil.Eventually(ctx, t, func(ctx context.Context) (done bool) {
1855 // Use the same logic as hasValidProvisioner but expect false
1856 provisionerDaemons, err := db.GetProvisionerDaemonsByOrganization(ctx, database.GetProvisionerDaemonsByOrganizationParams{
1857 OrganizationID: workspace.OrganizationID,
1858 WantTags: tags,
1859 })
1860 if err != nil {
1861 return false
1862 }
1863
1864 // Check if NO provisioners are active (all are stale or gone)
1865 for _, pd := range provisionerDaemons {
1866 if pd.LastSeenAt.Valid {
1867 age := checkTime.Sub(pd.LastSeenAt.Time)
1868 if age <= provisionerdserver.StaleInterval {
1869 return false // Found an active provisioner, keep waiting
1870 }
1871 }
1872 }
1873 return true // No active provisioners found
1874 }, testutil.IntervalFast, "there are still provisioners available for workspace, expected none")
1875}
1876
1877// MustWaitForProvisionersAvailable waits for provisioners to be available for a specific workspace.
1878func MustWaitForProvisionersAvailable(t *testing.T, db database.Store, workspace codersdk.Workspace, ts time.Time) uuid.UUID {

Calls 5

ContextFunction · 0.92
EventuallyFunction · 0.92
HelperMethod · 0.65