Skip to content

Commit

Permalink
Test propagating VR conditions message
Browse files Browse the repository at this point in the history
Verify that when VR Validated condition is False, the condition message
is propagated to the protected pvc DataReady condition message.

To make this easy to test, we have a new helper for waiting until
protected pvc condition status and message are updated to specified
values.

We propagate the same message to the DataProtected condition, but this
behavior seems like unwanted behavior that should change and is not
worth testing.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs committed Nov 10, 2024
1 parent b8871c6 commit aa0a819
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions internal/controller/vrg_volrep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,19 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
It("simulate VR with failed validation", func() {
vrgDeleteFailedVR.promoteVolRepsWithOptions(promoteOptions{ValidatedFailed: true})
})
It("propagate VR condition message to protected pvc conditions", func() {
vrName := vrgDeleteFailedVR.pvcNames[0]
vr := volrep.VolumeReplication{}
Expect(k8sClient.Get(context.TODO(), vrName, &vr)).To(Succeed())
validated := meta.FindStatusCondition(vr.Status.Conditions, volrep.ConditionValidated)
Expect(validated).NotTo(BeNil())
vrgDeleteFailedVR.waitForProtectedPVCCondition(
vrName,
vrgController.VRGConditionTypeDataReady,
metav1.ConditionFalse,
validated.Message,
)
})
It("VRG can be deleted", func() {
By("deleting the VRG")
vrg := vrgDeleteFailedVR.getVRG()
Expand Down Expand Up @@ -2532,6 +2545,30 @@ func (v *vrgTest) waitForVolRepCondition(
"failed to wait for volRep condition %q to become %q", conditionType, conditionStatus)
}

func (v *vrgTest) waitForProtectedPVCCondition(
key types.NamespacedName,
conditionType string,
conditionStatus metav1.ConditionStatus,
conditionMessage string,
) {
Eventually(func() bool {
vrg := v.getVRG()
protectedPVC := vrgController.FindProtectedPVC(vrg, key.Namespace, key.Name)
if protectedPVC == nil {
return false
}

condition := meta.FindStatusCondition(protectedPVC.Conditions, conditionType)
if condition == nil {
return false
}

return condition.Status == conditionStatus && condition.Message == conditionMessage
}, vrgtimeout, vrginterval).Should(BeTrue(),
"failed to wait for protected pvc condition %q to become %q with message %q",
conditionType, conditionStatus, conditionMessage)
}

func (v *vrgTest) waitForProtectedPVCs(vrNamespacedName types.NamespacedName) {
Eventually(func() bool {
vrg := v.getVRG()
Expand Down

0 comments on commit aa0a819

Please sign in to comment.