From 3ec82f66f4ec2cc7c7f8f3d48c439e8780dec578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Fri, 10 May 2024 14:46:41 +0200 Subject: [PATCH] tests: add comments in tests --- .../resources/strategicmerge_test.go | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/pkg/utils/kubernetes/resources/strategicmerge_test.go b/pkg/utils/kubernetes/resources/strategicmerge_test.go index 635752982..daad87f9c 100644 --- a/pkg/utils/kubernetes/resources/strategicmerge_test.go +++ b/pkg/utils/kubernetes/resources/strategicmerge_test.go @@ -746,14 +746,28 @@ func TestStrategicMergePatchPodTemplateSpec(t *testing.T) { Spec: corev1.PodSpec{ Volumes: []corev1.Volume{ { - // NOTE: This was required in 1.2.x and older verisons of the operator. + // NOTE: This was required in 1.2.x and older versions of the operator. // Now this only checks that this approach still works. Name: consts.ClusterCertificateVolume, + // 1.3.x introduced a change in how strategic merge patch is applied for PodTemplateSpec + // and the only discovered "breaking change" is that volume entries missing the + // volume source will result in removing the volume source from the base. + // Including the volume source in the patch (even empty like below) will keep the volume source. + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{}, + }, }, { - // NOTE: This was required in 1.2.x and older verisons of the operator. + // NOTE: This was required in 1.2.x and older versions of the operator. // Now this only checks that this approach still works. Name: consts.ControlPlaneAdmissionWebhookVolumeName, + // 1.3.x introduced a change in how strategic merge patch is applied for PodTemplateSpec + // and the only discovered "breaking change" is that volume entries missing the + // volume source will result in removing the volume source from the base. + // Including the volume source in the patch (even empty like below) will keep the volume source. + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{}, + }, }, { Name: "volume1", @@ -771,13 +785,13 @@ func TestStrategicMergePatchPodTemplateSpec(t *testing.T) { Name: "controller", VolumeMounts: []corev1.VolumeMount{ { - // NOTE: This was required in 1.2.x and older verisons of the operator. + // NOTE: This was required in 1.2.x and older versions of the operator. // Now this only checks that this approach still works. Name: consts.ClusterCertificateVolume, MountPath: consts.ClusterCertificateVolumeMountPath, }, { - // NOTE: This was required in 1.2.x and older verisons of the operator. + // NOTE: This was required in 1.2.x and older versions of the operator. // Now this only checks that this approach still works. Name: consts.ControlPlaneAdmissionWebhookVolumeName, MountPath: consts.ControlPlaneAdmissionWebhookVolumeMountPath,