Skip to content

Commit 45518a9

Browse files
author
Nina van der Linden
committed
add test for renaming vct
1 parent d8496c6 commit 45518a9

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/e2e/apps/statefulset.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,46 @@ var _ = SIGDescribe("AppStatefulSetStorage", func() {
10211021
framework.ExpectEqual(len(pod.Spec.Volumes), volumeCountBefore[i]-1)
10221022
}
10231023
})
1024+
1025+
ginkgo.It("rename volumeClaimTemplate", func() {
1026+
ctx := context.TODO()
1027+
1028+
ginkgo.By("Creating statefulset " + ssName + " in namespace " + ns)
1029+
_, err := kc.AppsV1beta1().StatefulSets(ns).Create(ctx, ss, metav1.CreateOptions{})
1030+
framework.ExpectNoError(err)
1031+
waitForStatus(ctx, c, kc, ss)
1032+
sst.WaitForStatusReplicas(ss, 2)
1033+
sst.WaitForStatusReadyReplicas(ss, 2)
1034+
1035+
// store number of volumes for each pod
1036+
// the number of volumes is not just equal to the number of VCTs as e.g. the kube-api-access volume is added.
1037+
pods := sst.GetPodList(ss)
1038+
volumeCountBefore := make([]int, len(pods.Items))
1039+
for i, pod := range pods.Items {
1040+
volumeCountBefore[i] = len(pod.Spec.Volumes)
1041+
}
1042+
1043+
ginkgo.By("rename one volumeClaimTemplate")
1044+
1045+
ss, err = updateStatefulSetWithRetries(ctx, kc, ns, ss.Name, func(update *appsv1beta1.StatefulSet) {
1046+
oldName := update.Spec.VolumeClaimTemplates[0].Name
1047+
update.Spec.VolumeClaimTemplates[0].Name = "new-name"
1048+
for _, mount := range update.Spec.Template.Spec.Containers[0].VolumeMounts {
1049+
if mount.Name == oldName {
1050+
mount.Name = "new-name"
1051+
}
1052+
}
1053+
})
1054+
framework.ExpectNoError(err)
1055+
waitForStatus(ctx, c, kc, ss)
1056+
sst.WaitForRollingUpdate(ss)
1057+
1058+
// verify that pods have same number of volumes as before
1059+
pods = sst.GetPodList(ss)
1060+
for i, pod := range pods.Items {
1061+
framework.ExpectEqual(len(pod.Spec.Volumes), volumeCountBefore[i])
1062+
}
1063+
})
10241064
})
10251065
})
10261066

0 commit comments

Comments
 (0)