Skip to content

Commit

Permalink
add a test for a statefulset with multiple migrated PVCs
Browse files Browse the repository at this point in the history
  • Loading branch information
laverya committed Oct 16, 2023
1 parent 37bb0b0 commit 9b69a4f
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion pkg/migrate/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2353,7 +2353,7 @@ func Test_scaleDownPods(t *testing.T) {
},
},
{
name: "existing statefulset pod",
name: "existing multi-volume statefulset pod",
matchingPVCs: map[string][]*corev1.PersistentVolumeClaim{
"ns1": {
&corev1.PersistentVolumeClaim{
Expand All @@ -2369,6 +2369,19 @@ func Test_scaleDownPods(t *testing.T) {
VolumeName: "sourcepv",
},
},
&corev1.PersistentVolumeClaim{
TypeMeta: metav1.TypeMeta{
Kind: "PersistentVolumeClaim",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "secondpvc",
Namespace: "ns1",
},
Spec: corev1.PersistentVolumeClaimSpec{
VolumeName: "secondpv",
},
},
},
},
resources: []runtime.Object{
Expand Down Expand Up @@ -2413,6 +2426,15 @@ func Test_scaleDownPods(t *testing.T) {
},
},
},
{
Name: "secondmatchingVolume",
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: "secondpvc",
ReadOnly: false,
},
},
},
},
},
Status: corev1.PodStatus{},
Expand All @@ -2435,6 +2457,24 @@ func Test_scaleDownPods(t *testing.T) {
Name: "sourcepv",
},
},
&corev1.PersistentVolumeClaim{
TypeMeta: metav1.TypeMeta{
Kind: "PersistentVolumeClaim",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "secondpvc",
Namespace: "ns1",
},
Spec: corev1.PersistentVolumeClaimSpec{
VolumeName: "secondpv",
},
},
&corev1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: "secondpv",
},
},
},
wantPods: map[string][]corev1.Pod{
"ns1": nil,
Expand Down Expand Up @@ -2478,9 +2518,30 @@ func Test_scaleDownPods(t *testing.T) {
VolumeName: "sourcepv",
},
},
&corev1.PersistentVolumeClaim{
TypeMeta: metav1.TypeMeta{
Kind: "PersistentVolumeClaim",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "secondpvc",
Namespace: "ns1",
},
Spec: corev1.PersistentVolumeClaimSpec{
VolumeName: "secondpv",
},
},
},
},
wantPVs: []corev1.PersistentVolume{
{
ObjectMeta: metav1.ObjectMeta{
Name: "secondpv",
Annotations: map[string]string{
sourceNodeAnnotation: "statefulset",
},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "sourcepv",
Expand Down

0 comments on commit 9b69a4f

Please sign in to comment.