Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test VR Validated condition #1577

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Split waitForPromotion() to allow testing negative cases
Split to:
- waitForVolRepCondition() - accept condition name and status. With this
  we can wait until VR is Completed=true, or Validated=false.
- waitForProtectedPVC() - wait until the related protected pvc is
  successful. Used only for positive tests.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs committed Oct 9, 2024
commit 9a8ae781991e06f8f385025c271744d531ce7f06
21 changes: 14 additions & 7 deletions internal/controller/vrg_volrep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2224,7 +2224,8 @@ func (v *vrgTest) promoteVolRepsAndDo(do func(int, int)) {
Name: volRep.Name,
Namespace: volRep.Namespace,
}
v.waitForVolRepPromotion(volrepKey)
v.waitForVolRepCondition(volrepKey, volrep.ConditionCompleted, metav1.ConditionTrue)
v.waitForProtectedPVCs(volrepKey)

do(index, len(volRepList.Items))
}
Expand Down Expand Up @@ -2268,7 +2269,11 @@ func (v *vrgTest) unprotectDeletionOfVolReps() {
}
}

func (v *vrgTest) waitForVolRepPromotion(vrNamespacedName types.NamespacedName) {
func (v *vrgTest) waitForVolRepCondition(
vrNamespacedName types.NamespacedName,
conditionType string,
conditionStatus metav1.ConditionStatus,
) {
updatedVolRep := volrep.VolumeReplication{}

Eventually(func() bool {
Expand All @@ -2277,21 +2282,23 @@ func (v *vrgTest) waitForVolRepPromotion(vrNamespacedName types.NamespacedName)
return false
}

condition := meta.FindStatusCondition(updatedVolRep.Status.Conditions, volrep.ConditionCompleted)
condition := meta.FindStatusCondition(updatedVolRep.Status.Conditions, conditionType)
if condition == nil {
return false
}

return condition.Status == metav1.ConditionTrue
return condition.Status == conditionStatus
}, vrgtimeout, vrginterval).Should(BeTrue(),
"failed to wait for volRep condition %q to become %q", volrep.ConditionCompleted, metav1.ConditionTrue)
"failed to wait for volRep condition %q to become %q", conditionType, conditionStatus)
}

func (v *vrgTest) waitForProtectedPVCs(vrNamespacedName types.NamespacedName) {
Eventually(func() bool {
vrg := v.getVRG()
// as of now name of VolumeReplication resource created by the VolumeReplicationGroup
// is same as the pvc that it replicates. When that changes this has to be changed to
// use the right name to get the appropriate protected PVC condition from VRG status.
protectedPVC := vrgController.FindProtectedPVC(vrg, updatedVolRep.Namespace, updatedVolRep.Name)
protectedPVC := vrgController.FindProtectedPVC(vrg, vrNamespacedName.Namespace, vrNamespacedName.Name)

// failed to get the protectedPVC. Returning false
if protectedPVC == nil {
Expand All @@ -2300,7 +2307,7 @@ func (v *vrgTest) waitForVolRepPromotion(vrNamespacedName types.NamespacedName)

return v.checkProtectedPVCSuccess(vrg, protectedPVC)
}, vrgtimeout, vrginterval).Should(BeTrue(),
"while waiting for protected pvc condition %s/%s", updatedVolRep.Namespace, updatedVolRep.Name)
"while waiting for protected pvc condition %s/%s", vrNamespacedName.Namespace, vrNamespacedName.Name)
}

func (v *vrgTest) checkProtectedPVCSuccess(vrg *ramendrv1alpha1.VolumeReplicationGroup,
Expand Down