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)
| 1848 | |
| 1849 | // MustWaitForProvisionersUnavailable waits for provisioners to become unavailable for a specific workspace |
| 1850 | func 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. |
| 1878 | func MustWaitForProvisionersAvailable(t *testing.T, db database.Store, workspace codersdk.Workspace, ts time.Time) uuid.UUID { |