mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: executor_test: reduce test execution time (#1876)
Removes 5-second wait in autobuild.executor unit tests: - Adds a write-only channel to Executor and plumbs through to unit tests - Modifies runOnce to return an executor.RunStats struct and write to statsCh if not nil
This commit is contained in:
@ -64,6 +64,7 @@ type Options struct {
|
||||
SSHKeygenAlgorithm gitsshkey.Algorithm
|
||||
APIRateLimit int
|
||||
AutobuildTicker <-chan time.Time
|
||||
AutobuildStats chan<- executor.Stats
|
||||
|
||||
// IncludeProvisionerD when true means to start an in-memory provisionerD
|
||||
IncludeProvisionerD bool
|
||||
@ -92,6 +93,11 @@ func NewWithAPI(t *testing.T, options *Options) (*codersdk.Client, *coderd.API)
|
||||
options.AutobuildTicker = ticker
|
||||
t.Cleanup(func() { close(ticker) })
|
||||
}
|
||||
if options.AutobuildStats != nil {
|
||||
t.Cleanup(func() {
|
||||
close(options.AutobuildStats)
|
||||
})
|
||||
}
|
||||
|
||||
// This can be hotswapped for a live database instance.
|
||||
db := databasefake.New()
|
||||
@ -122,7 +128,7 @@ func NewWithAPI(t *testing.T, options *Options) (*codersdk.Client, *coderd.API)
|
||||
db,
|
||||
slogtest.Make(t, nil).Named("autobuild.executor").Leveled(slog.LevelDebug),
|
||||
options.AutobuildTicker,
|
||||
)
|
||||
).WithStatsChannel(options.AutobuildStats)
|
||||
lifecycleExecutor.Run()
|
||||
|
||||
srv := httptest.NewUnstartedServer(nil)
|
||||
|
Reference in New Issue
Block a user