diff --git a/deploy/example/windows/deployment.yaml b/deploy/example/windows/deployment.yaml index c96da0b2510..5405bcc511f 100644 --- a/deploy/example/windows/deployment.yaml +++ b/deploy/example/windows/deployment.yaml @@ -31,7 +31,7 @@ spec: "kubernetes.io/os": windows containers: - name: busybox - image: e2eteam/busybox:1.29 + image: mcr.microsoft.com/windows/servercore:ltsc2022 command: - "powershell.exe" - "-Command" diff --git a/deploy/example/windows/statefulset.yaml b/deploy/example/windows/statefulset.yaml index c23c64ff047..8cb61dbf718 100644 --- a/deploy/example/windows/statefulset.yaml +++ b/deploy/example/windows/statefulset.yaml @@ -18,7 +18,7 @@ spec: "kubernetes.io/os": windows containers: - name: busybox-smb - image: e2eteam/busybox:1.29 + image: mcr.microsoft.com/windows/servercore:ltsc2022 command: - "powershell.exe" - "-Command" diff --git a/test/e2e/dynamic_provisioning_test.go b/test/e2e/dynamic_provisioning_test.go index 3ba5bd6ec7e..9ef6f048d21 100644 --- a/test/e2e/dynamic_provisioning_test.go +++ b/test/e2e/dynamic_provisioning_test.go @@ -71,7 +71,8 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { }, }, }, - IsWindows: isWindowsCluster, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, } podCheckCmd := []string{"cat", "/mnt/test-1/data"} @@ -123,7 +124,8 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { }, }, }, - IsWindows: isWindowsCluster, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, }, } test := testsuites.DynamicallyProvisionedCmdVolumeTest{ @@ -148,7 +150,8 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { }, }, }, - IsWindows: isWindowsCluster, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, }, { Cmd: convertToPowershellCommandIfNecessary("while true; do echo $(date -u) >> /mnt/test-1/data; sleep 100; done"), @@ -161,7 +164,8 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { }, }, }, - IsWindows: isWindowsCluster, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, }, } test := testsuites.DynamicallyProvisionedCollocatedPodTest{ @@ -190,7 +194,8 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { }, }, }, - IsWindows: isWindowsCluster, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, }, } test := testsuites.DynamicallyProvisionedReadOnlyVolumeTest{ @@ -217,7 +222,8 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { }, }, }, - IsWindows: isWindowsCluster, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, } podCheckCmd := []string{"cat", "/mnt/test-1/data"} @@ -286,9 +292,10 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { pods := []testsuites.PodDetails{ { - Cmd: convertToPowershellCommandIfNecessary("echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data"), - Volumes: volumes, - IsWindows: isWindowsCluster, + Cmd: convertToPowershellCommandIfNecessary("echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data"), + Volumes: volumes, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, }, } test := testsuites.DynamicallyProvisionedPodWithMultiplePVsTest{ @@ -312,7 +319,8 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { }, }, }, - IsWindows: isWindowsCluster, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, }, } test := testsuites.DynamicallyProvisionedVolumeSubpathTester{ @@ -381,7 +389,8 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { }, }, }, - IsWindows: isWindowsCluster, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, }, } test := testsuites.DynamicallyProvisionedCmdVolumeTest{ @@ -414,7 +423,8 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { }, }, }, - IsWindows: isWindowsCluster, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, }, } test := testsuites.DynamicallyProvisionedCmdVolumeTest{ @@ -447,7 +457,8 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { }, }, }, - IsWindows: isWindowsCluster, + IsWindows: isWindowsCluster, + WinServerVer: winServerVer, }, } test := testsuites.DynamicallyProvisionedCmdVolumeTest{ diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index d54b6fab8ba..560eab91a3f 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -40,6 +40,7 @@ const ( kubeconfigEnvVar = "KUBECONFIG" reportDirEnv = "ARTIFACTS" testWindowsEnvVar = "TEST_WINDOWS" + testWinServerVerEnvVar = "WINDOWS_SERVER_VERSION" defaultReportDir = "test/e2e" testSmbSourceEnvVar = "TEST_SMB_SOURCE" testSmbSecretNameEnvVar = "TEST_SMB_SECRET_NAME" @@ -52,6 +53,7 @@ const ( var ( smbDriver *smb.Driver isWindowsCluster = os.Getenv(testWindowsEnvVar) != "" + winServerVer = os.Getenv(testWinServerVerEnvVar) defaultStorageClassParameters = map[string]string{ "source": getSmbTestEnvVarValue(testSmbSourceEnvVar, defaultSmbSource), "csi.storage.k8s.io/provisioner-secret-name": getSmbTestEnvVarValue(testSmbSecretNameEnvVar, defaultSmbSecretName), @@ -117,6 +119,7 @@ var _ = ginkgo.BeforeSuite(func() { framework.AfterReadingAllFlags(&framework.TestContext) kubeconfig := os.Getenv(kubeconfigEnvVar) + log.Println(testWinServerVerEnvVar, os.Getenv(testWinServerVerEnvVar), fmt.Sprintf("%v", winServerVer)) // Install SMB provisioner on cluster installSMBProvisioner := testCmd{ diff --git a/test/e2e/testsuites/specs.go b/test/e2e/testsuites/specs.go index a515e9225d8..30e744e898a 100644 --- a/test/e2e/testsuites/specs.go +++ b/test/e2e/testsuites/specs.go @@ -29,9 +29,10 @@ import ( ) type PodDetails struct { - Cmd string - Volumes []VolumeDetails - IsWindows bool + Cmd string + Volumes []VolumeDetails + IsWindows bool + WinServerVer string } type VolumeDetails struct { @@ -86,7 +87,7 @@ type DataSource struct { //nolint:dupl func (pod *PodDetails) SetupWithDynamicVolumes(ctx context.Context, client clientset.Interface, namespace *v1.Namespace, csiDriver driver.DynamicPVTestDriver, storageClassParameters map[string]string) (*TestPod, []func(ctx context.Context)) { - tpod := NewTestPod(client, namespace, pod.Cmd, pod.IsWindows) + tpod := NewTestPod(client, namespace, pod.Cmd, pod.IsWindows, pod.WinServerVer) cleanupFuncs := make([]func(ctx context.Context), 0) for n, v := range pod.Volumes { tpvc, funcs := v.SetupDynamicPersistentVolumeClaim(ctx, client, namespace, csiDriver, storageClassParameters) @@ -104,7 +105,7 @@ func (pod *PodDetails) SetupWithDynamicVolumes(ctx context.Context, client clien // //nolint:dupl func (pod *PodDetails) SetupWithDynamicMultipleVolumes(ctx context.Context, client clientset.Interface, namespace *v1.Namespace, csiDriver driver.DynamicPVTestDriver, storageClassParameters map[string]string) (*TestPod, []func(ctx context.Context)) { - tpod := NewTestPod(client, namespace, pod.Cmd, pod.IsWindows) + tpod := NewTestPod(client, namespace, pod.Cmd, pod.IsWindows, pod.WinServerVer) cleanupFuncs := make([]func(ctx context.Context), 0) for n, v := range pod.Volumes { tpvc, funcs := v.SetupDynamicPersistentVolumeClaim(ctx, client, namespace, csiDriver, storageClassParameters) @@ -119,7 +120,7 @@ func (pod *PodDetails) SetupWithDynamicMultipleVolumes(ctx context.Context, clie } func (pod *PodDetails) SetupWithPreProvisionedVolumes(ctx context.Context, client clientset.Interface, namespace *v1.Namespace, csiDriver driver.PreProvisionedVolumeTestDriver) (*TestPod, []func(ctx context.Context)) { - tpod := NewTestPod(client, namespace, pod.Cmd, pod.IsWindows) + tpod := NewTestPod(client, namespace, pod.Cmd, pod.IsWindows, pod.WinServerVer) cleanupFuncs := make([]func(ctx context.Context), 0) for n, v := range pod.Volumes { tpvc, funcs := v.SetupPreProvisionedPersistentVolumeClaim(ctx, client, namespace, csiDriver) @@ -149,14 +150,14 @@ func (pod *PodDetails) SetupDeployment(ctx context.Context, client clientset.Int tpvc.ValidateProvisionedPersistentVolume(ctx) cleanupFuncs = append(cleanupFuncs, tpvc.Cleanup) ginkgo.By("setting up the Deployment") - tDeployment := NewTestDeployment(client, namespace, pod.Cmd, tpvc.persistentVolumeClaim, fmt.Sprintf("%s%d", volume.VolumeMount.NameGenerate, 1), fmt.Sprintf("%s%d", volume.VolumeMount.MountPathGenerate, 1), volume.VolumeMount.ReadOnly, pod.IsWindows) + tDeployment := NewTestDeployment(client, namespace, pod.Cmd, tpvc.persistentVolumeClaim, fmt.Sprintf("%s%d", volume.VolumeMount.NameGenerate, 1), fmt.Sprintf("%s%d", volume.VolumeMount.MountPathGenerate, 1), volume.VolumeMount.ReadOnly, pod.IsWindows, pod.WinServerVer) cleanupFuncs = append(cleanupFuncs, tDeployment.Cleanup) return tDeployment, cleanupFuncs } func (pod *PodDetails) SetupWithDynamicVolumesWithSubpath(ctx context.Context, client clientset.Interface, namespace *v1.Namespace, csiDriver driver.DynamicPVTestDriver, storageClassParameters map[string]string) (*TestPod, []func(ctx context.Context)) { - tpod := NewTestPod(client, namespace, pod.Cmd, pod.IsWindows) + tpod := NewTestPod(client, namespace, pod.Cmd, pod.IsWindows, pod.WinServerVer) cleanupFuncs := make([]func(ctx context.Context), 0) for n, v := range pod.Volumes { tpvc, funcs := v.SetupDynamicPersistentVolumeClaim(ctx, client, namespace, csiDriver, storageClassParameters) diff --git a/test/e2e/testsuites/testsuites.go b/test/e2e/testsuites/testsuites.go index 56d4d7b2d28..92e17ff8eca 100644 --- a/test/e2e/testsuites/testsuites.go +++ b/test/e2e/testsuites/testsuites.go @@ -335,7 +335,7 @@ type TestDeployment struct { podName string } -func NewTestDeployment(c clientset.Interface, ns *v1.Namespace, command string, pvc *v1.PersistentVolumeClaim, volumeName, mountPath string, readOnly, isWindows bool) *TestDeployment { +func NewTestDeployment(c clientset.Interface, ns *v1.Namespace, command string, pvc *v1.PersistentVolumeClaim, volumeName, mountPath string, readOnly, isWindows bool, winServerVer string) *TestDeployment { generateName := "smb-volume-tester-" selectorValue := fmt.Sprintf("%s%d", generateName, rand.Int()) replicas := int32(1) @@ -400,7 +400,7 @@ func NewTestDeployment(c clientset.Interface, ns *v1.Namespace, command string, Value: "win1809", }, } - testDeployment.deployment.Spec.Template.Spec.Containers[0].Image = "e2eteam/busybox:1.29" + testDeployment.deployment.Spec.Template.Spec.Containers[0].Image = "mcr.microsoft.com/windows/servercore:" + getWinImageTag(winServerVer) testDeployment.deployment.Spec.Template.Spec.Containers[0].Command = []string{"powershell.exe"} testDeployment.deployment.Spec.Template.Spec.Containers[0].Args = []string{"-Command", command} } @@ -502,7 +502,7 @@ type TestPod struct { namespace *v1.Namespace } -func NewTestPod(c clientset.Interface, ns *v1.Namespace, command string, isWindows bool) *TestPod { +func NewTestPod(c clientset.Interface, ns *v1.Namespace, command string, isWindows bool, winServerVer string) *TestPod { testPod := &TestPod{ client: c, namespace: ns, @@ -537,7 +537,7 @@ func NewTestPod(c clientset.Interface, ns *v1.Namespace, command string, isWindo Value: "win1809", }, } - testPod.pod.Spec.Containers[0].Image = "e2eteam/busybox:1.29" + testPod.pod.Spec.Containers[0].Image = "mcr.microsoft.com/windows/servercore:" + getWinImageTag(winServerVer) testPod.pod.Spec.Containers[0].Command = []string{"powershell.exe"} testPod.pod.Spec.Containers[0].Args = []string{"-Command", command} } @@ -545,6 +545,14 @@ func NewTestPod(c clientset.Interface, ns *v1.Namespace, command string, isWindo return testPod } +func getWinImageTag(winServerVer string) string { + testWinImageTag := "ltsc2019" + if winServerVer == "windows-2022" { + testWinImageTag = "ltsc2022" + } + return testWinImageTag +} + func (t *TestPod) Create(ctx context.Context) { var err error