Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1bbe3bb

Browse files
committed
add test that fails since we still trigger autobuilds even if a
provisioner is not availableSigned-off-by: Callum Styan <callumstyan@gmail.com>
1 parent36d2e01 commit1bbe3bb

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

‎coderd/autobuild/lifecycle_executor_test.go‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,3 +1583,47 @@ func mustWorkspaceParameters(t *testing.T, client *codersdk.Client, workspaceID
15831583
funcTestMain(m*testing.M) {
15841584
goleak.VerifyTestMain(m,testutil.GoleakOptions...)
15851585
}
1586+
1587+
funcTestExecutorAutostartSkipsWhenNoProvisionersAvailable(t*testing.T) {
1588+
t.Parallel()
1589+
1590+
var (
1591+
sched=mustSchedule(t,"CRON_TZ=UTC 0 * * * *")
1592+
tickCh=make(chan time.Time)
1593+
statsCh=make(chan autobuild.Stats)
1594+
)
1595+
1596+
// Create client with provisioner daemon
1597+
client,provisionerCloser:=coderdtest.NewWithProvisionerCloser(t,&coderdtest.Options{
1598+
AutobuildTicker:tickCh,
1599+
IncludeProvisionerDaemon:true,
1600+
AutobuildStats:statsCh,
1601+
})
1602+
1603+
// Create workspace with autostart enabled
1604+
workspace:=mustProvisionWorkspace(t,client,func(cwr*codersdk.CreateWorkspaceRequest) {
1605+
cwr.AutostartSchedule=ptr.Ref(sched.String())
1606+
})
1607+
1608+
// Stop the workspace while provisioner is available
1609+
workspace=coderdtest.MustTransitionWorkspace(t,client,workspace.ID,
1610+
codersdk.WorkspaceTransitionStart,codersdk.WorkspaceTransitionStop)
1611+
1612+
// Now shut down the provisioner daemon
1613+
err:=provisionerCloser.Close()
1614+
require.NoError(t,err)
1615+
1616+
// Trigger autobuild after scheduled time
1617+
gofunc() {
1618+
tickCh<-sched.Next(workspace.LatestBuild.CreatedAt)
1619+
close(tickCh)
1620+
}()
1621+
1622+
// Wait for executor to run
1623+
stats:=<-statsCh
1624+
require.Len(t,stats.Errors,0,"should not have errors")
1625+
1626+
// Verify workspace is still stopped
1627+
workspace=coderdtest.MustWorkspace(t,client,workspace.ID)
1628+
require.Equal(t,codersdk.WorkspaceTransitionStop,workspace.LatestBuild.Transition)
1629+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp