TestExecutorFailedWorkspace test AGPL functionality which mainly ensures that autostop actions as a result of a failed workspace build do not trigger. For enterprise functionality see enterprise/coderd/workspaces_test.go
(t *testing.T)
| 1167 | // build do not trigger. |
| 1168 | // For enterprise functionality see enterprise/coderd/workspaces_test.go |
| 1169 | func TestExecutorFailedWorkspace(t *testing.T) { |
| 1170 | t.Parallel() |
| 1171 | |
| 1172 | // Test that an AGPL TemplateScheduleStore properly disables |
| 1173 | // functionality. |
| 1174 | t.Run("OK", func(t *testing.T) { |
| 1175 | t.Parallel() |
| 1176 | |
| 1177 | var ( |
| 1178 | ticker = make(chan time.Time) |
| 1179 | statCh = make(chan autobuild.Stats) |
| 1180 | logger = slogtest.Make(t, &slogtest.Options{ |
| 1181 | // We ignore errors here since we expect to fail |
| 1182 | // builds. |
| 1183 | IgnoreErrors: true, |
| 1184 | }) |
| 1185 | failureTTL = time.Millisecond |
| 1186 | |
| 1187 | client = coderdtest.New(t, &coderdtest.Options{ |
| 1188 | Logger: &logger, |
| 1189 | AutobuildTicker: ticker, |
| 1190 | IncludeProvisionerDaemon: true, |
| 1191 | AutobuildStats: statCh, |
| 1192 | TemplateScheduleStore: schedule.NewAGPLTemplateScheduleStore(), |
| 1193 | }) |
| 1194 | ) |
| 1195 | user := coderdtest.CreateFirstUser(t, client) |
| 1196 | version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{ |
| 1197 | Parse: echo.ParseComplete, |
| 1198 | ProvisionInit: echo.InitComplete, |
| 1199 | ProvisionPlan: echo.PlanComplete, |
| 1200 | ProvisionApply: echo.ApplyFailed, |
| 1201 | ProvisionGraph: echo.GraphComplete, |
| 1202 | }) |
| 1203 | template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID, func(ctr *codersdk.CreateTemplateRequest) { |
| 1204 | ctr.FailureTTLMillis = ptr.Ref[int64](failureTTL.Milliseconds()) |
| 1205 | }) |
| 1206 | coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) |
| 1207 | ws := coderdtest.CreateWorkspace(t, client, template.ID) |
| 1208 | build := coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, ws.LatestBuild.ID) |
| 1209 | require.Equal(t, codersdk.WorkspaceStatusFailed, build.Status) |
| 1210 | ticker <- build.Job.CompletedAt.Add(failureTTL * 2) |
| 1211 | stats := <-statCh |
| 1212 | // Expect no transitions since we're using AGPL. |
| 1213 | require.Len(t, stats.Transitions, 0) |
| 1214 | }) |
| 1215 | } |
| 1216 | |
| 1217 | // TestExecutorInactiveWorkspace test AGPL functionality which mainly |
| 1218 | // ensures that autostop actions as a result of an inactive workspace |
nothing calls this directly
no test coverage detected