Skip to content

Commit

Permalink
WIP: 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 <nsoffer@redhat.com>
  • Loading branch information
nirs committed Sep 25, 2024
1 parent 223d892 commit e21ddfe
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions internal/controller/vrg_volrep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,54 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
})
})

// Test VRG deletion when VR failed validation
var vrgDeleteFailedVR *vrgTest
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.promoteVolRepsFailValidation()
})
It("verify that DataReady and DataProtected conditions are false", func() {
vrgDeleteFailedVR.verifyVRGStatusCondition(vrgController.VRGConditionTypeDataReady, false)
vrgDeleteFailedVR.verifyVRGStatusCondition(vrgController.VRGConditionTypeDataProtected, false)
})
It("VRG can be deleted", func() {
By("Starting the VRG deletion process")
vrg := vrgDeleteFailedVR.getVRG()
Expect(k8sClient.Delete(context.TODO(), vrg)).To(Succeed())

By("Ensuring VRG is deleted eventually as a result")
Eventually(func() error {
return apiReader.Get(context.TODO(), vrgDeleteFailedVR.vrgNamespacedName(), vrg)
}, vrgtimeout*2, 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 @@ -2165,6 +2213,10 @@ func (v *vrgTest) promoteVolRepsWithoutVrgStatusCheck() {
v.promoteVolRepsAndDo(promoteOptions{}, func(index, count int) {})
}

func (v *vrgTest) promoteVolRepsFailValidation() {
v.promoteVolRepsAndDo(promoteOptions{ValidatedFailed: true}, func(index, count int) {})
}

type promoteOptions struct {
ValidatedMissing bool
ValidatedFailed bool
Expand Down

0 comments on commit e21ddfe

Please sign in to comment.