Skip to content

Commit c88ae3f

Browse files
committed
[test]Fix PVC handling in SimulateDeployment
In #277 it was wrongly assumed that a StatefulSet of Deployment only has a single container spec and the volume mounts only removed from the first container. This leads to test failures in module using multiple containers per Pod. Now this is fixed by dropping the mounts from each container.
1 parent d886a78 commit c88ae3f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

modules/test/helpers/deployment.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ func (tc *TestHelper) SimulateDeploymentReadyWithPods(name types.NamespacedName,
9292
// with a missing volume. So to avoid that we remove every mount and
9393
// volume from the pod we create here.
9494
pod.Spec.Volumes = []corev1.Volume{}
95-
pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{}
95+
for i := range pod.Spec.Containers {
96+
pod.Spec.Containers[i].VolumeMounts = []corev1.VolumeMount{}
97+
}
9698

9799
var netStatus []networkv1.NetworkStatus
98100
for network, IPs := range networkIPs {

modules/test/helpers/statefulset.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ func (tc *TestHelper) SimulateStatefulSetReplicaReadyWithPods(name types.Namespa
7979
// with a missing volume. So to avoid that we remove every mount and
8080
// volume from the pod we create here.
8181
pod.Spec.Volumes = []corev1.Volume{}
82-
pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{}
82+
for i := range pod.Spec.Containers {
83+
pod.Spec.Containers[i].VolumeMounts = []corev1.VolumeMount{}
84+
}
8385

8486
var netStatus []networkv1.NetworkStatus
8587
for network, IPs := range networkIPs {

0 commit comments

Comments
 (0)