@@ -119,11 +119,28 @@ var _ = Describe("WorkspaceController", func() {
119
119
})
120
120
})
121
121
122
+ It ("should not take a backup if content init did not happen" , func () {
123
+ ws := newWorkspace (uuid .NewString (), "default" )
124
+ m := collectMetricCounts (wsMetrics , ws )
125
+ pod := createWorkspaceExpectPod (ws )
126
+
127
+ requestStop (ws )
128
+
129
+ // No content init, expect cleanup without backup.
130
+ expectWorkspaceCleanup (ws , pod )
131
+
132
+ expectMetricsDelta (m , collectMetricCounts (wsMetrics , ws ), metricCounts {
133
+ stops : 1 ,
134
+ })
135
+ })
136
+
122
137
It ("should handle backup failure" , func () {
123
138
ws := newWorkspace (uuid .NewString (), "default" )
124
139
m := collectMetricCounts (wsMetrics , ws )
125
140
pod := createWorkspaceExpectPod (ws )
126
141
142
+ markContentReady (ws )
143
+
127
144
// Stop the workspace.
128
145
requestStop (ws )
129
146
@@ -134,6 +151,7 @@ var _ = Describe("WorkspaceController", func() {
134
151
expectWorkspaceCleanup (ws , pod )
135
152
136
153
expectMetricsDelta (m , collectMetricCounts (wsMetrics , ws ), metricCounts {
154
+ restores : 1 ,
137
155
backups : 1 ,
138
156
backupFailures : 1 ,
139
157
stops : 1 ,
@@ -145,6 +163,8 @@ var _ = Describe("WorkspaceController", func() {
145
163
m := collectMetricCounts (wsMetrics , ws )
146
164
pod := createWorkspaceExpectPod (ws )
147
165
166
+ markContentReady (ws )
167
+
148
168
// Update Pod with failed exit status.
149
169
updateObjWithRetries (k8sClient , pod , true , func (pod * corev1.Pod ) {
150
170
pod .Status .ContainerStatuses = append (pod .Status .ContainerStatuses , corev1.ContainerStatus {
@@ -165,6 +185,7 @@ var _ = Describe("WorkspaceController", func() {
165
185
expectWorkspaceCleanup (ws , pod )
166
186
167
187
expectMetricsDelta (m , collectMetricCounts (wsMetrics , ws ), metricCounts {
188
+ restores : 1 ,
168
189
startFailures : 1 ,
169
190
stops : 1 ,
170
191
backups : 1 ,
@@ -176,6 +197,8 @@ var _ = Describe("WorkspaceController", func() {
176
197
m := collectMetricCounts (wsMetrics , ws )
177
198
pod := createWorkspaceExpectPod (ws )
178
199
200
+ markContentReady (ws )
201
+
179
202
By ("adding Timeout condition" )
180
203
updateObjWithRetries (k8sClient , ws , true , func (ws * workspacev1.Workspace ) {
181
204
ws .Status .Conditions = wsk8s .AddUniqueCondition (ws .Status .Conditions , metav1.Condition {
@@ -190,8 +213,9 @@ var _ = Describe("WorkspaceController", func() {
190
213
expectWorkspaceCleanup (ws , pod )
191
214
192
215
expectMetricsDelta (m , collectMetricCounts (wsMetrics , ws ), metricCounts {
193
- stops : 1 ,
194
- backups : 1 ,
216
+ restores : 1 ,
217
+ stops : 1 ,
218
+ backups : 1 ,
195
219
})
196
220
})
197
221
@@ -200,6 +224,8 @@ var _ = Describe("WorkspaceController", func() {
200
224
m := collectMetricCounts (wsMetrics , ws )
201
225
pod := createWorkspaceExpectPod (ws )
202
226
227
+ markContentReady (ws )
228
+
203
229
// Update Pod with stop and abort conditions.
204
230
updateObjWithRetries (k8sClient , ws , true , func (ws * workspacev1.Workspace ) {
205
231
ws .Status .Conditions = wsk8s .AddUniqueCondition (ws .Status .Conditions , metav1.Condition {
@@ -218,7 +244,8 @@ var _ = Describe("WorkspaceController", func() {
218
244
expectWorkspaceCleanup (ws , pod )
219
245
220
246
expectMetricsDelta (m , collectMetricCounts (wsMetrics , ws ), metricCounts {
221
- stops : 1 ,
247
+ restores : 1 ,
248
+ stops : 1 ,
222
249
})
223
250
})
224
251
@@ -227,6 +254,8 @@ var _ = Describe("WorkspaceController", func() {
227
254
m := collectMetricCounts (wsMetrics , ws )
228
255
pod := createWorkspaceExpectPod (ws )
229
256
257
+ markContentReady (ws )
258
+
230
259
Expect (k8sClient .Delete (ctx , ws )).To (Succeed ())
231
260
232
261
expectPhaseEventually (ws , workspacev1 .WorkspacePhaseStopping )
@@ -236,8 +265,9 @@ var _ = Describe("WorkspaceController", func() {
236
265
expectWorkspaceCleanup (ws , pod )
237
266
238
267
expectMetricsDelta (m , collectMetricCounts (wsMetrics , ws ), metricCounts {
239
- stops : 1 ,
240
- backups : 1 ,
268
+ restores : 1 ,
269
+ stops : 1 ,
270
+ backups : 1 ,
241
271
})
242
272
})
243
273
})
0 commit comments