test: remove provisioner heartbeat from 'AllProvisionersStale' (#21903)

Provisioner async heartbeat will mark the 'stale' provisioner as ready

closes https://github.com/coder/internal/issues/1288
This commit is contained in:
Steven Masley
2026-02-04 08:29:44 -06:00
committed by GitHub
parent 9d887f2aac
commit a4ffafd46d
2 changed files with 19 additions and 3 deletions
+8
View File
@@ -1996,8 +1996,15 @@ func MemoryProvisionerWithVersionOverride(version string) MemoryProvisionerDaemo
}
}
func MemoryProvisionerWithHeartbeatOverride(heartbeatFN func(context.Context) error) MemoryProvisionerDaemonOption {
return func(opts *memoryProvisionerDaemonOptions) {
opts.heartbeatFn = heartbeatFN
}
}
type memoryProvisionerDaemonOptions struct {
versionOverride string
heartbeatFn func(context.Context) error
}
// CreateInMemoryProvisionerDaemon is an in-memory connection to a provisionerd.
@@ -2087,6 +2094,7 @@ func (api *API) CreateInMemoryTaggedProvisionerDaemon(dialCtx context.Context, n
OIDCConfig: api.OIDCConfig,
ExternalAuthConfigs: api.ExternalAuthConfigs,
Clock: api.Clock,
HeartbeatFn: options.heartbeatFn,
},
api.NotificationsEnqueuer,
&api.PrebuildsReconciler,
+11 -3
View File
@@ -19,6 +19,7 @@ import (
"cdr.dev/slog/v3"
"github.com/coder/coder/v2/agent/agenttest"
"github.com/coder/coder/v2/coderd"
"github.com/coder/coder/v2/coderd/audit"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/coderd/database"
@@ -1358,12 +1359,19 @@ func TestPostWorkspacesByOrganization(t *testing.T) {
// Given: a coderd instance with a provisioner daemon
store, ps, db := dbtestutil.NewDBWithSQLDB(t)
client, closeDaemon := coderdtest.NewWithProvisionerCloser(t, &coderdtest.Options{
client, _, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
Database: store,
Pubsub: ps,
IncludeProvisionerDaemon: true,
IncludeProvisionerDaemon: false,
})
defer closeDaemon.Close()
// Create a new provisioner with a heartbeater that does nothing.
provisioner := coderdtest.NewTaggedProvisionerDaemon(t, api, "test-provisioner", nil, coderd.MemoryProvisionerWithHeartbeatOverride(func(ctx context.Context) error {
// The default heartbeat updates the `last_seen_at` column in the database.
// By overriding it to do nothing, we can simulate a provisioner that is not sending heartbeats, and is therefore stale.
return nil
}))
defer provisioner.Close()
// Given: a user, template, and workspace
user := coderdtest.CreateFirstUser(t, client)