Skip to content

Commit

Permalink
vrg_volrep_test: tests with no peerClasses
Browse files Browse the repository at this point in the history
adding tests with no peerClasses and no replicaitonID
in VRC

Signed-off-by: rakeshgm <rakeshgm@redhat.com>
  • Loading branch information
rakeshgm committed Aug 8, 2024
1 parent d93cb6f commit c97a818
Showing 1 changed file with 107 additions and 23 deletions.
130 changes: 107 additions & 23 deletions internal/controller/vrg_volrep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
}
It("sets up PVCs, PVs and VRGs (with s3 stores that fail ObjectStore get)", func() {
vrgS3storeGetTemplate.s3Profiles = []string{s3Profiles[bucketInvalidS3ProfileNumber2].S3ProfileName}
vrgS3StoreGetTestCase = newVRGTestCaseCreateAndStart(2, vrgS3storeGetTemplate, true, false)
vrgS3StoreGetTestCase = newVRGTestCaseCreateAndStart(2, vrgS3storeGetTemplate, true, false, true)
})
It("waits for VRG status to match", func() {
vrgS3StoreGetTestCase.verifyVRGStatusCondition(vrgController.VRGConditionTypeClusterDataReady, false)
Expand Down Expand Up @@ -598,7 +598,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
}
It("sets up PVCs, PVs and VRGs (with s3 stores that fail uploads)", func() {
vrgsS3UploadTestTemplate.s3Profiles = []string{s3Profiles[uploadErrorS3ProfileNumber].S3ProfileName}
vrgS3UploadTestCase = newVRGTestCaseCreateAndStart(3, vrgsS3UploadTestTemplate, true, false)
vrgS3UploadTestCase = newVRGTestCaseCreateAndStart(3, vrgsS3UploadTestTemplate, true, false, true)
})
It("waits for VRG to create a VR for each PVC", func() {
expectedVRCount := len(vrgS3UploadTestCase.pvcNames)
Expand Down Expand Up @@ -636,7 +636,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
}
It("sets up PVCs, PVs and VRGs (with s3 stores that fail uploads)", func() {
vrgVRDeleteEnsureTestTemplate.s3Profiles = []string{s3Profiles[vrgS3ProfileNumber].S3ProfileName}
vrgVRDeleteEnsureTestCase = newVRGTestCaseCreateAndStart(1, vrgVRDeleteEnsureTestTemplate, true, false)
vrgVRDeleteEnsureTestCase = newVRGTestCaseCreateAndStart(1, vrgVRDeleteEnsureTestTemplate, true, false, true)
})
It("waits for VRG to create a VR for each PVC", func() {
expectedVRCount := len(vrgVRDeleteEnsureTestCase.pvcNames)
Expand Down Expand Up @@ -704,7 +704,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
vrcLabels := genVRCLabels(replicationIDs[c], storageID, "ramen")
createTestTemplate.storageIDLabels = storageIDLabel
createTestTemplate.replicationClassLabels = vrcLabels
v := newVRGTestCaseCreateAndStart(c, createTestTemplate, true, false)
v := newVRGTestCaseCreateAndStart(c, createTestTemplate, true, false, true)
vrgTestCases = append(vrgTestCases, v)
}
})
Expand Down Expand Up @@ -754,7 +754,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
It("sets up PVCs, PVs and VRGs - with nil/empty StorageClassName", func() {
vrgEmptySCTemplate.s3Profiles = []string{s3Profiles[vrgS3ProfileNumber].S3ProfileName}
vrgEmptySCTemplate.volsyncEnabled = true
vrgEmptySC = newVRGTestCaseCreateAndStart(1, vrgEmptySCTemplate, true, false)
vrgEmptySC = newVRGTestCaseCreateAndStart(1, vrgEmptySCTemplate, true, false, true)
})
It("waits for VRG status to match", func() {
vrgEmptySC.verifyVRGStatusExpectation(false, "")
Expand Down Expand Up @@ -785,7 +785,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
vrgMissingSCTemplate.s3Profiles = []string{s3Profiles[vrgS3ProfileNumber].S3ProfileName}
vrgMissingSCTemplate.volsyncEnabled = true
vrgMissingSCTemplate.scDisabled = true
vrgMissingSC = newVRGTestCaseCreateAndStart(1, vrgMissingSCTemplate, true, false)
vrgMissingSC = newVRGTestCaseCreateAndStart(1, vrgMissingSCTemplate, true, false, true)
})
It("waits for VRG status to match", func() {
vrgMissingSC.verifyVRGStatusExpectation(false, "")
Expand Down Expand Up @@ -823,7 +823,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
vrgTestTemplate.replicationClassLabels = vrcLabels
// Test the scenario where the pvc is not bound yet
// and expect no VRs to be created.
v := newVRGTestCaseCreateAndStart(c, vrgTestTemplate, false, false)
v := newVRGTestCaseCreateAndStart(c, vrgTestTemplate, false, false, true)
vrgTests = append(vrgTests, v)
}
})
Expand Down Expand Up @@ -886,7 +886,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
storageID := storageIDLabel[vrgController.StorageIDLabel]
vrgTestTemplateVSEnabled.storageIDLabels = storageIDLabel
vrgTestTemplateVSEnabled.replicationClassLabels = genVRCLabels(replicationIDs[0], storageID, "ramen")
v := newVRGTestCaseCreateAndStart(4, vrgTestTemplateVSEnabled, false, false)
v := newVRGTestCaseCreateAndStart(4, vrgTestTemplateVSEnabled, false, false, true)
vrgStatusTests = append(vrgStatusTests, v)
})
var v *vrgTest
Expand Down Expand Up @@ -931,7 +931,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
storageID := storageIDLabel[vrgController.StorageIDLabel]
vrgTest2Template.replicationClassLabels = genVRCLabels(replicationIDs[0], storageID, "ramen")
vrgTest2Template.storageIDLabels = storageIDLabel
v := newVRGTestCaseCreateAndStart(4, vrgTest2Template, true, true)
v := newVRGTestCaseCreateAndStart(4, vrgTest2Template, true, true, true)
vrgStatus2Tests = append(vrgStatus2Tests, v)
})
It("waits for VRG to create a VR for each PVC bind and checks status", func() {
Expand Down Expand Up @@ -972,7 +972,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
storageID := storageIDLabel[vrgController.StorageIDLabel]
vrgTest3Template.replicationClassLabels = genVRCLabels(replicationIDs[0], storageID, "ramen")
vrgTest3Template.storageIDLabels = storageIDLabel
v := newVRGTestCaseCreateAndStart(4, vrgTest3Template, false, true)
v := newVRGTestCaseCreateAndStart(4, vrgTest3Template, false, true, true)
vrgStatus3Tests = append(vrgStatus3Tests, v)
})
var v *vrgTest
Expand Down Expand Up @@ -1018,7 +1018,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
storageID := storageIDLabel[vrgController.StorageIDLabel]
vrgScheduleTestTemplate.replicationClassLabels = genVRCLabels(replicationIDs[0], storageID, "ramen")
vrgScheduleTestTemplate.storageIDLabels = storageIDLabel
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTestTemplate, true, true)
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTestTemplate, true, true, true)
vrgScheduleTests = append(vrgScheduleTests, v)
})
It("expect no VR to be created as PVC not bound and check status", func() {
Expand Down Expand Up @@ -1055,7 +1055,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
storageID := storageIDLabel[vrgController.StorageIDLabel]
vrgScheduleTest2Template.replicationClassLabels = genVRCLabels(replicationIDs[0], storageID, "ramen")
vrgScheduleTest2Template.storageIDLabels = storageIDLabel
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTest2Template, true, true)
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTest2Template, true, true, true)
vrgSchedule2Tests = append(vrgSchedule2Tests, v)
})
It("expect no VR to be created as PVC not bound and check status", func() {
Expand Down Expand Up @@ -1091,7 +1091,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
vrgScheduleTest3Template.s3Profiles = []string{s3Profiles[vrgS3ProfileNumber].S3ProfileName}
storageIDLabel := genStorageIDLabel(storageIDs[0])
vrgScheduleTest3Template.storageIDLabels = storageIDLabel
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTest3Template, true, true)
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTest3Template, true, true, true)
vrgSchedule3Tests = append(vrgSchedule3Tests, v)
})
It("expect no VR to be created as VR not created and check status", func() {
Expand Down Expand Up @@ -1137,7 +1137,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
vrgScheduleTest4Template.additionalVRCInfoList[0].replicationClassLabels = genVRCLabels(
replicationIDs[0], storageID, "ramen")
vrgScheduleTest4Template.storageIDLabels = storageIDLabel
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTest4Template, true, true)
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTest4Template, true, true, true)
vrgSchedule4Tests = append(vrgSchedule4Tests, v)
})
It("expect no VR to be created as VR not created and check status", func() {
Expand Down Expand Up @@ -1182,7 +1182,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
vrgScheduleTest5Template.additionalVRCInfoList[0].replicationClassLabels = genVRCLabels(
replicationIDs[0], storageID, "ramen")
vrgScheduleTest5Template.storageIDLabels = storageIDLabel
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTest5Template, true, true)
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTest5Template, true, true, true)
vrgSchedule5Tests = append(vrgSchedule5Tests, v)
})
It("expect 4 VRs to be created and check status", func() {
Expand Down Expand Up @@ -1239,7 +1239,7 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
vrgScheduleTest6Template.additionalVRCInfoList[1].replicationClassLabels = genVRCLabels(
replicationIDs[0], storageID, "ramen")
vrgScheduleTest6Template.storageIDLabels = storageIDLabel
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTest6Template, true, true)
v := newVRGTestCaseCreateAndStart(4, vrgScheduleTest6Template, true, true, true)
vrgSchedule6Tests = append(vrgSchedule6Tests, v)
})
It("expect no VR to be created as VR not created and check status", func() {
Expand All @@ -1256,6 +1256,80 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
})
})

// Basic test with no peerClasses
var vrgNoPeerClasses []*vrgTest
vrgNoPeerClassesTemplate := &template{
ClaimBindInfo: corev1.ClaimBound,
VolumeBindInfo: corev1.VolumeBound,
schedulingInterval: "1h",
storageClassName: "manual",
replicationClassName: "test-replicationclass",
vrcProvisioner: "manual.storage.com",
scProvisioner: "manual.storage.com",
}
Context("Basic test with no peerClassses", func() {
It("sets up PVCs, PVs and VRGs", func() {
vrgNoPeerClassesTemplate.s3Profiles = []string{s3Profiles[vrgS3ProfileNumber].S3ProfileName}
storageIDLabel := genStorageIDLabel(storageIDs[0])
storageID := storageIDLabel[vrgController.StorageIDLabel]
vrcLabels := genVRCLabels(replicationIDs[0], storageID, "ramen")
vrgNoPeerClassesTemplate.storageIDLabels = storageIDLabel
vrgNoPeerClassesTemplate.replicationClassLabels = vrcLabels
v := newVRGTestCaseCreateAndStart(2, vrgNoPeerClassesTemplate, true, false, false)
vrgNoPeerClasses = append(vrgNoPeerClasses, v)
})
It("expect VR to be created and check status", func() {
v := vrgNoPeerClasses[0]
v.waitForVRCountToMatch(v.pvcCount)
})
It("waits for VRG status to match", func() {
v := vrgNoPeerClasses[0]
v.promoteVolReps()
v.verifyVRGStatusExpectation(true, vrgController.VRGConditionReasonReady)
})
It("cleans up after testing", func() {
v := vrgNoPeerClasses[0]
v.cleanupProtected()
})
})

// Basic test with no peerClasses with no replicationID in vrc
var vrgNoPeerClassesAndReplicationID []*vrgTest
vrgNoPeerClassesAndReplicationIDTemplate := &template{
ClaimBindInfo: corev1.ClaimBound,
VolumeBindInfo: corev1.VolumeBound,
schedulingInterval: "1h",
storageClassName: "manual",
replicationClassName: "test-replicationclass",
vrcProvisioner: "manual.storage.com",
scProvisioner: "manual.storage.com",
}
Context("Basic test with no peerClassses with replicationID in vrc", func() {
It("sets up PVCs, PVs and VRGs", func() {
vrgNoPeerClassesAndReplicationIDTemplate.s3Profiles = []string{s3Profiles[vrgS3ProfileNumber].S3ProfileName}
storageIDLabel := genStorageIDLabel(storageIDs[0])
storageID := storageIDLabel[vrgController.StorageIDLabel]
vrcLabels := genVRCLabels("", storageID, "ramen")
vrgNoPeerClassesAndReplicationIDTemplate.storageIDLabels = storageIDLabel
vrgNoPeerClassesAndReplicationIDTemplate.replicationClassLabels = vrcLabels
v := newVRGTestCaseCreateAndStart(2, vrgNoPeerClassesAndReplicationIDTemplate, true, false, false)
vrgNoPeerClassesAndReplicationID = append(vrgNoPeerClassesAndReplicationID, v)
})
It("expect VR to be created and check status", func() {
v := vrgNoPeerClassesAndReplicationID[0]
v.waitForVRCountToMatch(v.pvcCount)
})
It("waits for VRG status to match", func() {
v := vrgNoPeerClassesAndReplicationID[0]
v.promoteVolReps()
v.verifyVRGStatusExpectation(true, vrgController.VRGConditionReasonReady)
})
It("cleans up after testing", func() {
v := vrgNoPeerClassesAndReplicationID[0]
v.cleanupProtected()
})
})

// TODO: Add tests to move VRG to Secondary
// TODO: Add tests to ensure delete as Secondary (check if delete as Primary is tested above)
})
Expand Down Expand Up @@ -1379,7 +1453,9 @@ func (v *vrgTest) VRGTestCaseStart() {
// with Status.Phase set to ClaimPending instead of ClaimBound. Expectation
// is that, until pvc is not bound, VolRep resources should not be created
// by VRG.
func newVRGTestCaseCreateAndStart(pvcCount int, testTemplate *template, checkBind, vrgFirst bool) *vrgTest {
func newVRGTestCaseCreateAndStart(pvcCount int, testTemplate *template, checkBind,
vrgFirst, includePeerClasses bool,
) *vrgTest {
var replicationID string

v := newVRGTestCaseCreate(pvcCount, testTemplate, checkBind, vrgFirst)
Expand All @@ -1391,8 +1467,11 @@ func newVRGTestCaseCreateAndStart(pvcCount int, testTemplate *template, checkBin
}

storageID := testTemplate.storageIDLabels[vrgController.StorageIDLabel]
asyncPeerClass := genPeerClass(replicationID, testTemplate.storageClassName, []string{storageID})
v.asyncPeerClasses = []ramendrv1alpha1.PeerClass{asyncPeerClass}
if includePeerClasses {
asyncPeerClass := genPeerClass(replicationID, testTemplate.storageClassName, []string{storageID})
v.asyncPeerClasses = []ramendrv1alpha1.PeerClass{asyncPeerClass}
}

v.VRGTestCaseStart()

return v
Expand Down Expand Up @@ -2588,9 +2667,14 @@ func genPeerClass(replicationID, storageClassName string, storageIDs []string) r

//nolint:unparam
func genVRCLabels(replicationID, storageID, protectionKey string) map[string]string {
return map[string]string{
vrgController.VolumeReplicationIDLabel: replicationID,
vrgController.StorageIDLabel: storageID,
"protection": protectionKey,
vrcLabel := map[string]string{
vrgController.StorageIDLabel: storageID,
"protection": protectionKey,
}

if replicationID != "" {
vrcLabel[vrgController.VolumeReplicationIDLabel] = replicationID
}

return vrcLabel
}

0 comments on commit c97a818

Please sign in to comment.