Skip to content

Commit 2a0c67f

Browse files
committed
chore: update build configuration and e2e test helpers
Add ceph-csi-config name/namespace env var substitution to Makefile deploy, build-installer, and bundle targets. Update manager deployment with ConfigMap env vars. Add retry-on-conflict to e2e spec update helpers. Assisted-by: Claude <noreply@anthropic.com> Signed-off-by: Rakshith R <rar@redhat.com>
1 parent d340c42 commit 2a0c67f

6 files changed

Lines changed: 99 additions & 78 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metada
416416
cd config/manifests/bases && $(KUSTOMIZE) edit add annotation --force 'olm.skipRange':"$(SKIP_RANGE)"
417417
cd config/manifests/bases && $(KUSTOMIZE) edit add patch --name ceph-volsync-plugin-operator.v0.0.1 --kind ClusterServiceVersion\
418418
--patch '[{"op": "replace", "path": "/spec/replaces", "value": "$(REPLACES)"}]'
419-
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
419+
$(KUSTOMIZE) build config/manifests | sed 's|MOVER_IMAGE_PLACEHOLDER|${MOVER_IMG}|g; s|CEPH_CSI_CONFIG_NAME_PLACEHOLDER|${CEPH_CSI_CONFIG_NAME}|g; s|CEPH_CSI_CONFIG_NAMESPACE_PLACEHOLDER|${CEPH_CSI_CONFIG_NAMESPACE}|g' | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
420420
$(OPERATOR_SDK) bundle validate ./bundle
421421

422422
.PHONY: bundle-build

internal/controller/replicationdestination_controller_test.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import (
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
)
2626

27+
const (
28+
testRDName = "test-rd"
29+
testRDNS = "test-ns"
30+
)
31+
2732
func TestRdHasMover(t *testing.T) {
2833
testCases := []struct {
2934
name string
@@ -34,8 +39,8 @@ func TestRdHasMover(t *testing.T) {
3439
name: "No mover",
3540
rd: &volsyncv1alpha1.ReplicationDestination{
3641
ObjectMeta: metav1.ObjectMeta{
37-
Name: "test-rd",
38-
Namespace: "test-ns",
42+
Name: testRDName,
43+
Namespace: testRDNS,
3944
},
4045
Spec: volsyncv1alpha1.ReplicationDestinationSpec{},
4146
},
@@ -45,8 +50,8 @@ func TestRdHasMover(t *testing.T) {
4550
name: "Rclone mover",
4651
rd: &volsyncv1alpha1.ReplicationDestination{
4752
ObjectMeta: metav1.ObjectMeta{
48-
Name: "test-rd",
49-
Namespace: "test-ns",
53+
Name: testRDName,
54+
Namespace: testRDNS,
5055
},
5156
Spec: volsyncv1alpha1.ReplicationDestinationSpec{
5257
Rclone: &volsyncv1alpha1.ReplicationDestinationRcloneSpec{},
@@ -58,8 +63,8 @@ func TestRdHasMover(t *testing.T) {
5863
name: "Restic mover",
5964
rd: &volsyncv1alpha1.ReplicationDestination{
6065
ObjectMeta: metav1.ObjectMeta{
61-
Name: "test-rd",
62-
Namespace: "test-ns",
66+
Name: testRDName,
67+
Namespace: testRDNS,
6368
},
6469
Spec: volsyncv1alpha1.ReplicationDestinationSpec{
6570
Restic: &volsyncv1alpha1.ReplicationDestinationResticSpec{},
@@ -71,8 +76,8 @@ func TestRdHasMover(t *testing.T) {
7176
name: "Rsync mover",
7277
rd: &volsyncv1alpha1.ReplicationDestination{
7378
ObjectMeta: metav1.ObjectMeta{
74-
Name: "test-rd",
75-
Namespace: "test-ns",
79+
Name: testRDName,
80+
Namespace: testRDNS,
7681
},
7782
Spec: volsyncv1alpha1.ReplicationDestinationSpec{
7883
Rsync: &volsyncv1alpha1.ReplicationDestinationRsyncSpec{},
@@ -84,8 +89,8 @@ func TestRdHasMover(t *testing.T) {
8489
name: "RsyncTLS mover",
8590
rd: &volsyncv1alpha1.ReplicationDestination{
8691
ObjectMeta: metav1.ObjectMeta{
87-
Name: "test-rd",
88-
Namespace: "test-ns",
92+
Name: testRDName,
93+
Namespace: testRDNS,
8994
},
9095
Spec: volsyncv1alpha1.ReplicationDestinationSpec{
9196
RsyncTLS: &volsyncv1alpha1.ReplicationDestinationRsyncTLSSpec{},

internal/controller/replicationsource_controller_test.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import (
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
)
2626

27+
const (
28+
testRSName = "test-rs"
29+
testRSNS = "test-ns"
30+
)
31+
2732
func TestRsHasMover(t *testing.T) {
2833
testCases := []struct {
2934
name string
@@ -34,8 +39,8 @@ func TestRsHasMover(t *testing.T) {
3439
name: "No mover",
3540
rs: &volsyncv1alpha1.ReplicationSource{
3641
ObjectMeta: metav1.ObjectMeta{
37-
Name: "test-rs",
38-
Namespace: "test-ns",
42+
Name: testRSName,
43+
Namespace: testRSNS,
3944
},
4045
Spec: volsyncv1alpha1.ReplicationSourceSpec{},
4146
},
@@ -45,8 +50,8 @@ func TestRsHasMover(t *testing.T) {
4550
name: "Rclone mover",
4651
rs: &volsyncv1alpha1.ReplicationSource{
4752
ObjectMeta: metav1.ObjectMeta{
48-
Name: "test-rs",
49-
Namespace: "test-ns",
53+
Name: testRSName,
54+
Namespace: testRSNS,
5055
},
5156
Spec: volsyncv1alpha1.ReplicationSourceSpec{
5257
Rclone: &volsyncv1alpha1.ReplicationSourceRcloneSpec{},
@@ -58,8 +63,8 @@ func TestRsHasMover(t *testing.T) {
5863
name: "Restic mover",
5964
rs: &volsyncv1alpha1.ReplicationSource{
6065
ObjectMeta: metav1.ObjectMeta{
61-
Name: "test-rs",
62-
Namespace: "test-ns",
66+
Name: testRSName,
67+
Namespace: testRSNS,
6368
},
6469
Spec: volsyncv1alpha1.ReplicationSourceSpec{
6570
Restic: &volsyncv1alpha1.ReplicationSourceResticSpec{},
@@ -71,8 +76,8 @@ func TestRsHasMover(t *testing.T) {
7176
name: "Rsync mover",
7277
rs: &volsyncv1alpha1.ReplicationSource{
7378
ObjectMeta: metav1.ObjectMeta{
74-
Name: "test-rs",
75-
Namespace: "test-ns",
79+
Name: testRSName,
80+
Namespace: testRSNS,
7681
},
7782
Spec: volsyncv1alpha1.ReplicationSourceSpec{
7883
Rsync: &volsyncv1alpha1.ReplicationSourceRsyncSpec{},
@@ -84,8 +89,8 @@ func TestRsHasMover(t *testing.T) {
8489
name: "RsyncTLS mover",
8590
rs: &volsyncv1alpha1.ReplicationSource{
8691
ObjectMeta: metav1.ObjectMeta{
87-
Name: "test-rs",
88-
Namespace: "test-ns",
92+
Name: testRSName,
93+
Namespace: testRSNS,
8994
},
9095
Spec: volsyncv1alpha1.ReplicationSourceSpec{
9196
RsyncTLS: &volsyncv1alpha1.ReplicationSourceRsyncTLSSpec{},

test/e2e/helpers_test.go

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ var waitTimeout = getEnvDuration("WAIT_TIMEOUT", 2*time.Minute)
4949
// dataMatchPollInterval is how often we retry the full validate flow when polling for data match.
5050
const dataMatchPollInterval = 30 * time.Second
5151

52+
const (
53+
busyboxImage = "busybox"
54+
shCmd = "/bin/sh"
55+
volMountName = "vol"
56+
srcVolName = "src-vol"
57+
dstVolName = "dst-vol"
58+
copyMethodSnapshot = "Snapshot"
59+
copyMethodDirect = "Direct"
60+
copyMethodKey = "copyMethod"
61+
)
62+
5263
// innerPollInterval is the poll interval for sub-waits inside tryValidateSyncedData.
5364
const innerPollInterval = 5 * time.Second
5465

@@ -520,14 +531,14 @@ func runPodWithPVC(ctx context.Context, podName, pvcName string, drv driverConfi
520531
Containers: []corev1.Container{
521532
{
522533
Name: "worker",
523-
Image: "busybox",
534+
Image: busyboxImage,
524535
ImagePullPolicy: corev1.PullAlways,
525-
Command: []string{"/bin/sh", "-c", command},
536+
Command: []string{shCmd, "-c", command},
526537
},
527538
},
528539
Volumes: []corev1.Volume{
529540
{
530-
Name: "vol",
541+
Name: volMountName,
531542
VolumeSource: corev1.VolumeSource{
532543
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
533544
ClaimName: pvcName,
@@ -543,14 +554,14 @@ func runPodWithPVC(ctx context.Context, podName, pvcName string, drv driverConfi
543554
if isBlock {
544555
pod.Spec.Containers[0].VolumeDevices = []corev1.VolumeDevice{
545556
{
546-
Name: "vol",
557+
Name: volMountName,
547558
DevicePath: "/dev/block",
548559
},
549560
}
550561
} else {
551562
pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{
552563
{
553-
Name: "vol",
564+
Name: volMountName,
554565
MountPath: "/data",
555566
},
556567
}
@@ -638,14 +649,14 @@ func compareDataInPod(ctx context.Context, podName, srcPVC, dstPVC string, drv d
638649
Containers: []corev1.Container{
639650
{
640651
Name: "compare",
641-
Image: "busybox",
652+
Image: busyboxImage,
642653
ImagePullPolicy: corev1.PullAlways,
643-
Command: []string{"/bin/sh", "-c", command},
654+
Command: []string{shCmd, "-c", command},
644655
},
645656
},
646657
Volumes: []corev1.Volume{
647658
{
648-
Name: "src-vol",
659+
Name: srcVolName,
649660
VolumeSource: corev1.VolumeSource{
650661
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
651662
ClaimName: srcPVC,
@@ -654,7 +665,7 @@ func compareDataInPod(ctx context.Context, podName, srcPVC, dstPVC string, drv d
654665
},
655666
},
656667
{
657-
Name: "dst-vol",
668+
Name: dstVolName,
658669
VolumeSource: corev1.VolumeSource{
659670
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
660671
ClaimName: dstPVC,
@@ -669,23 +680,23 @@ func compareDataInPod(ctx context.Context, podName, srcPVC, dstPVC string, drv d
669680
if isBlock {
670681
pod.Spec.Containers[0].VolumeDevices = []corev1.VolumeDevice{
671682
{
672-
Name: "src-vol",
683+
Name: srcVolName,
673684
DevicePath: "/dev/src-block",
674685
},
675686
{
676-
Name: "dst-vol",
687+
Name: dstVolName,
677688
DevicePath: "/dev/dst-block",
678689
},
679690
}
680691
} else {
681692
pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{
682693
{
683-
Name: "src-vol",
694+
Name: srcVolName,
684695
MountPath: "/src",
685696
ReadOnly: true,
686697
},
687698
{
688-
Name: "dst-vol",
699+
Name: dstVolName,
689700
MountPath: "/dst",
690701
ReadOnly: true,
691702
},
@@ -730,7 +741,7 @@ func validateSyncedData(
730741
) {
731742
var snapName string
732743

733-
if copyMethod == "Snapshot" {
744+
if copyMethod == copyMethodSnapshot {
734745
By("getting snapshot from RD latestImage")
735746

736747
rd := &volsyncv1alpha1.ReplicationDestination{}
@@ -813,7 +824,7 @@ func validateSyncedData(
813824

814825
_ = k8sClientSet.CoreV1().PersistentVolumeClaims(namespace).Delete(ctx, tempPVC, metav1.DeleteOptions{})
815826

816-
if copyMethod == "Direct" {
827+
if copyMethod == copyMethodDirect {
817828
By("cleaning up validation snapshot")
818829

819830
snap := &snapv1.VolumeSnapshot{
@@ -898,7 +909,7 @@ func cleanupTryResources(ctx context.Context, snapPrefix, copyMethod string) {
898909
},
899910
})
900911

901-
if copyMethod == "Direct" {
912+
if copyMethod == copyMethodDirect {
902913
deleteAndWaitFor(ctx, &snapv1.VolumeSnapshot{
903914
ObjectMeta: metav1.ObjectMeta{
904915
Name: snapPrefix + "-validate",
@@ -942,14 +953,14 @@ func tryCompareDataInPod(ctx context.Context, podName, srcPVC, dstPVC string, dr
942953
Containers: []corev1.Container{
943954
{
944955
Name: "compare",
945-
Image: "busybox",
956+
Image: busyboxImage,
946957
ImagePullPolicy: corev1.PullAlways,
947-
Command: []string{"/bin/sh", "-c", command},
958+
Command: []string{shCmd, "-c", command},
948959
},
949960
},
950961
Volumes: []corev1.Volume{
951962
{
952-
Name: "src-vol",
963+
Name: srcVolName,
953964
VolumeSource: corev1.VolumeSource{
954965
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
955966
ClaimName: srcPVC,
@@ -958,7 +969,7 @@ func tryCompareDataInPod(ctx context.Context, podName, srcPVC, dstPVC string, dr
958969
},
959970
},
960971
{
961-
Name: "dst-vol",
972+
Name: dstVolName,
962973
VolumeSource: corev1.VolumeSource{
963974
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
964975
ClaimName: dstPVC,
@@ -973,23 +984,23 @@ func tryCompareDataInPod(ctx context.Context, podName, srcPVC, dstPVC string, dr
973984
if isBlock {
974985
pod.Spec.Containers[0].VolumeDevices = []corev1.VolumeDevice{
975986
{
976-
Name: "src-vol",
987+
Name: srcVolName,
977988
DevicePath: "/dev/src-block",
978989
},
979990
{
980-
Name: "dst-vol",
991+
Name: dstVolName,
981992
DevicePath: "/dev/dst-block",
982993
},
983994
}
984995
} else {
985996
pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{
986997
{
987-
Name: "src-vol",
998+
Name: srcVolName,
988999
MountPath: "/src",
9891000
ReadOnly: true,
9901001
},
9911002
{
992-
Name: "dst-vol",
1003+
Name: dstVolName,
9931004
MountPath: "/dst",
9941005
ReadOnly: true,
9951006
},
@@ -1033,7 +1044,7 @@ func tryValidateSyncedData(
10331044

10341045
var snapName string
10351046

1036-
if copyMethod == "Snapshot" {
1047+
if copyMethod == copyMethodSnapshot {
10371048
rd := &volsyncv1alpha1.ReplicationDestination{}
10381049

10391050
err := k8sClient.Get(ctx, types.NamespacedName{Name: rdName, Namespace: namespace}, rd)

0 commit comments

Comments
 (0)