@@ -153,15 +153,17 @@ func TestReconcileVolumeSnapshots(t *testing.T) {
153
153
},
154
154
DeletionPolicy : "Delete" ,
155
155
}
156
- err := r .Client .Create (ctx , volumeSnapshotClass )
157
- assert .NilError (t , err )
156
+ assert . NilError ( t , r .Client .Create (ctx , volumeSnapshotClass ) )
157
+ t . Cleanup ( func () { assert .Check (t , r . Client . Delete ( ctx , volumeSnapshotClass )) } )
158
158
159
159
// Create a cluster with snapshots enabled
160
160
cluster := testCluster ()
161
161
cluster .Namespace = ns .Name
162
162
cluster .Spec .Backups .Snapshots = & v1beta1.VolumeSnapshots {
163
163
VolumeSnapshotClassName : volumeSnapshotClassName ,
164
164
}
165
+ assert .NilError (t , r .Client .Create (ctx , cluster ))
166
+ t .Cleanup (func () { assert .Check (t , r .Client .Delete (ctx , cluster )) })
165
167
166
168
// Create pvc for reconcile
167
169
pvc := & corev1.PersistentVolumeClaim {
@@ -188,15 +190,26 @@ func TestReconcileVolumeSnapshots(t *testing.T) {
188
190
})
189
191
190
192
t .Run ("SnapshotsEnabledReadySnapshotsExist" , func (t * testing.T ) {
191
- // volumeSnapshotClass still exists
193
+ // Create a volume snapshot class
194
+ volumeSnapshotClassName := "my-snapshotclass"
195
+ volumeSnapshotClass := & volumesnapshotv1.VolumeSnapshotClass {
196
+ ObjectMeta : metav1.ObjectMeta {
197
+ Name : volumeSnapshotClassName ,
198
+ },
199
+ DeletionPolicy : "Delete" ,
200
+ }
201
+ assert .NilError (t , r .Client .Create (ctx , volumeSnapshotClass ))
202
+ t .Cleanup (func () { assert .Check (t , r .Client .Delete (ctx , volumeSnapshotClass )) })
203
+
192
204
// Create a cluster with snapshots enabled
193
205
cluster := testCluster ()
194
206
cluster .Namespace = ns .Name
195
207
cluster .ObjectMeta .UID = "the-uid-123"
196
- volumeSnapshotClassName := "my-snapshotclass"
197
208
cluster .Spec .Backups .Snapshots = & v1beta1.VolumeSnapshots {
198
209
VolumeSnapshotClassName : volumeSnapshotClassName ,
199
210
}
211
+ assert .NilError (t , r .Client .Create (ctx , cluster ))
212
+ t .Cleanup (func () { assert .Check (t , r .Client .Delete (ctx , cluster )) })
200
213
201
214
// Create pvc with annotation
202
215
pvcName := initialize .String ("dedicated-snapshot-volume" )
@@ -301,15 +314,26 @@ func TestReconcileVolumeSnapshots(t *testing.T) {
301
314
})
302
315
303
316
t .Run ("SnapshotsEnabledCreateSnapshot" , func (t * testing.T ) {
304
- // volumeSnapshotClass still exists
317
+ // Create a volume snapshot class
318
+ volumeSnapshotClassName := "my-snapshotclass"
319
+ volumeSnapshotClass := & volumesnapshotv1.VolumeSnapshotClass {
320
+ ObjectMeta : metav1.ObjectMeta {
321
+ Name : volumeSnapshotClassName ,
322
+ },
323
+ DeletionPolicy : "Delete" ,
324
+ }
325
+ assert .NilError (t , r .Client .Create (ctx , volumeSnapshotClass ))
326
+ t .Cleanup (func () { assert .Check (t , r .Client .Delete (ctx , volumeSnapshotClass )) })
327
+
305
328
// Create a cluster with snapshots enabled
306
329
cluster := testCluster ()
307
330
cluster .Namespace = ns .Name
308
331
cluster .ObjectMeta .UID = "the-uid-123"
309
- volumeSnapshotClassName := "my-snapshotclass"
310
332
cluster .Spec .Backups .Snapshots = & v1beta1.VolumeSnapshots {
311
333
VolumeSnapshotClassName : volumeSnapshotClassName ,
312
334
}
335
+ assert .NilError (t , r .Client .Create (ctx , cluster ))
336
+ t .Cleanup (func () { assert .Check (t , r .Client .Delete (ctx , cluster )) })
313
337
314
338
// Create pvc with annotation
315
339
pvcName := initialize .String ("dedicated-snapshot-volume" )
@@ -840,7 +864,7 @@ func TestGetDedicatedSnapshotVolumeRestoreJob(t *testing.T) {
840
864
func TestGetLatestCompleteBackupJob (t * testing.T ) {
841
865
ctx := context .Background ()
842
866
_ , cc := setupKubernetes (t )
843
- require .ParallelCapacity (t , 1 )
867
+ // require.ParallelCapacity(t, 1)
844
868
845
869
r := & Reconciler {
846
870
Client : cc ,
0 commit comments