MCPcopy Create free account
hub / github.com/coder/coder / TestPrebuildReconciliation

Function TestPrebuildReconciliation

enterprise/coderd/prebuilds/reconcile_test.go:160–322  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

158}
159
160func TestPrebuildReconciliation(t *testing.T) {
161 t.Parallel()
162
163 testScenarios := []testScenario{
164 {
165 name: "never create prebuilds for inactive template versions",
166 prebuildLatestTransitions: allTransitions,
167 prebuildJobStatuses: allJobStatuses,
168 templateVersionActive: []bool{false},
169 shouldCreateNewPrebuild: ptr.To(false),
170 templateDeleted: []bool{false},
171 },
172 {
173 name: "no need to create a new prebuild if one is already running",
174 prebuildLatestTransitions: []database.WorkspaceTransition{
175 database.WorkspaceTransitionStart,
176 },
177 prebuildJobStatuses: []database.ProvisionerJobStatus{
178 database.ProvisionerJobStatusSucceeded,
179 },
180 templateVersionActive: []bool{true},
181 templateDeleted: []bool{false},
182 shouldCreateNewPrebuild: ptr.To(false),
183 },
184 {
185 name: "don't create a new prebuild if one is queued to build or already building",
186 prebuildLatestTransitions: []database.WorkspaceTransition{
187 database.WorkspaceTransitionStart,
188 },
189 prebuildJobStatuses: []database.ProvisionerJobStatus{
190 database.ProvisionerJobStatusPending,
191 database.ProvisionerJobStatusRunning,
192 },
193 templateVersionActive: []bool{true},
194 shouldCreateNewPrebuild: ptr.To(false),
195 templateDeleted: []bool{false},
196 },
197 {
198 name: "create a new prebuild if one is in a state that disqualifies it from ever being claimed",
199 prebuildLatestTransitions: []database.WorkspaceTransition{
200 database.WorkspaceTransitionStop,
201 database.WorkspaceTransitionDelete,
202 },
203 prebuildJobStatuses: []database.ProvisionerJobStatus{
204 database.ProvisionerJobStatusPending,
205 database.ProvisionerJobStatusRunning,
206 database.ProvisionerJobStatusCanceling,
207 database.ProvisionerJobStatusSucceeded,
208 },
209 templateVersionActive: []bool{true},
210 shouldCreateNewPrebuild: ptr.To(true),
211 templateDeleted: []bool{false},
212 },
213 {
214 // See TestFailedBuildBackoff for the start/failed case.
215 name: "create a new prebuild if one is in any kind of exceptional state",
216 prebuildLatestTransitions: []database.WorkspaceTransition{
217 database.WorkspaceTransitionStop,

Callers

nothing calls this directly

Calls 2

testCasesMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected