Skip to content

Commit

Permalink
Test deleting a VRG when VR failed validation
Browse files Browse the repository at this point in the history
This simulates the bug when user select the wrong dr policy without
flattening enabled when protecting for a PVC that needs flattening.
Without the fix this test will timeout when deleting the VRG. With the
fix the VRG should be deleted.

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Sep 26, 2024
1 parent 8e9ad64 commit 76fc3cf
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions internal/controller/vrg_volrep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,51 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
})
})

// Test VRG deletion when VR failed validation
var vrgDeleteFailedVR *vrgTest
//nolint:dupl
Context("VR failed validation in primary state", func() {
createTestTemplate := &template{
ClaimBindInfo: corev1.ClaimBound,
VolumeBindInfo: corev1.VolumeBound,
schedulingInterval: "1h",
storageClassName: "manual",
replicationClassName: "test-replicationclass",
vrcProvisioner: "manual.storage.com",
scProvisioner: "manual.storage.com",
replicationClassLabels: map[string]string{"protection": "ramen"},
}
It("sets up PVCs, PVs and VRGs (with s3 stores that fail uploads)", func() {
createTestTemplate.s3Profiles = []string{s3Profiles[vrgS3ProfileNumber].S3ProfileName}
vrgDeleteFailedVR = newVRGTestCaseCreateAndStart(1, createTestTemplate, true, false)
})
It("waits for VRG to create a VR for each PVC", func() {
expectedVRCount := len(vrgDeleteFailedVR.pvcNames)
vrgDeleteFailedVR.waitForVRCountToMatch(expectedVRCount)
})
It("simulate VR with failed validation", func() {
vrgDeleteFailedVR.promoteVolRepsWithOptions(promoteOptions{ValidatedFailed: true})
})
It("VRG can be deleted", func() {
By("deleting the VRG")
vrg := vrgDeleteFailedVR.getVRG()
Expect(k8sClient.Delete(context.TODO(), vrg)).To(Succeed())

By("ensuring VRG is deleted")
Eventually(func() error {
return apiReader.Get(context.TODO(), vrgDeleteFailedVR.vrgNamespacedName(), vrg)
}, vrgtimeout, vrginterval).
Should(MatchError(errors.NewNotFound(schema.GroupResource{
Group: ramendrv1alpha1.GroupVersion.Group,
Resource: "volumereplicationgroups",
}, vrgDeleteFailedVR.vrgName)))

vrgDeleteFailedVR.cleanupNamespace()
vrgDeleteFailedVR.cleanupSC()
vrgDeleteFailedVR.cleanupVRC()
})
})

// Try the simple case of creating VRG, PVC, PV and
// check whether VolRep resources are created or not
var vrgTestCases []*vrgTest
Expand Down Expand Up @@ -2174,6 +2219,10 @@ func (v *vrgTest) promoteVolRepsWithoutVrgStatusCheck() {
v.promoteVolRepsAndDo(promoteOptions{}, func(index, count int) {})
}

func (v *vrgTest) promoteVolRepsWithOptions(options promoteOptions) {
v.promoteVolRepsAndDo(options, func(index, count int) {})
}

type promoteOptions struct {
ValidatedMissing bool
ValidatedFailed bool
Expand Down

0 comments on commit 76fc3cf

Please sign in to comment.