Skip to content

Commit 5320628

Browse files
authored
tkg win test fix (#3430)
1 parent 78aab64 commit 5320628

File tree

9 files changed

+55
-32
lines changed

9 files changed

+55
-32
lines changed

tests/e2e/constants/env_constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,5 @@ const (
213213
EnvVmknic4Vsan = "VMKNIC_FOR_VSAN"
214214
EnvAccessMode = "ACCESS_MODE"
215215
EnvVpToCsi = "VCPTOCSI"
216+
EnvVsphereTKGSystemNamespace = "VSPHERE_TKG_SYSTEM_NAMESPACE"
216217
)

tests/e2e/constants/kubernetes.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ const (
100100
VsphereCloudProviderConfiguration = "vsphere-cloud-provider.conf"
101101
VsphereControllerManager = "vmware-system-tkg-controller-manager"
102102
VSphereCSIConf = "csi-vsphere.conf"
103-
VsphereTKGSystemNamespace = "svc-tkg-domain-c10"
104103
WcpServiceName = "wcp"
105104
VmcWcpHost = "10.2.224.24" //This is the LB IP of VMC WCP and its constant
106105
DevopsTKG = "test-cluster-e2e-script"

tests/e2e/e2e_common.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ const (
229229
vsphereCloudProviderConfiguration = "vsphere-cloud-provider.conf"
230230
vsphereControllerManager = "vmware-system-tkg-controller-manager"
231231
vSphereCSIConf = "csi-vsphere.conf"
232-
vsphereTKGSystemNamespace = "svc-tkg-domain-c10"
232+
envVsphereTKGSystemNamespace = "VSPHERE_TKG_SYSTEM_NAMESPACE"
233233
waitTimeForCNSNodeVMAttachmentReconciler = 30 * time.Second
234234
wcpServiceName = "wcp"
235235
vmcWcpHost = "10.2.224.24" //This is the LB IP of VMC WCP and its constant
@@ -349,6 +349,7 @@ const (
349349
stretchedSvc = "stretchedSvc"
350350
devops = "devops"
351351
vc901 = "vc901"
352+
multiGc = "multiGc"
352353
)
353354

354355
// The following variables are required to know cluster type to run common e2e

tests/e2e/gc_block_resize_retain_policy.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
126126

127127
// Replace second element with pod.Name.
128128
if windowsEnv {
129-
cmd = []string{"exec", "", "--namespace=" + namespace, "powershell.exe", "cat", "/mnt/volume1/fstype.txt"}
129+
cmd = []string{"exec", "", "--namespace=" + namespace, "--", "powershell.exe", "-Command", "cat",
130+
"/mnt/volume1/fstype.txt"}
130131
} else {
131132
cmd = []string{"exec", "", "--namespace=" + namespace, "--", "/bin/sh", "-c", "df -Tkm | grep /mnt/volume1"}
132133
}
@@ -206,7 +207,8 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
206207
// 18. Delete PVC created in step 6.
207208
// 19. Delete PV leftover in GC.
208209
// 20. Delete SC created in step 1.
209-
ginkgo.It("PV with reclaim policy can be reused and resized with pod", ginkgo.Label(p0, block, tkg, vc70), func() {
210+
ginkgo.It("PV with reclaim policy can be reused and resized with pod", ginkgo.Label(p0, block, tkg,
211+
windows, vc70), func() {
210212
ctx, cancel := context.WithCancel(context.Background())
211213
defer cancel()
212214
// Create a Pod to use this PVC, and verify volume has been attached.
@@ -586,7 +588,7 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
586588
"exec",
587589
pod.Name,
588590
"--namespace=" + namespaceNewGC,
589-
"powershell.exe",
591+
"powershell.exe -Command",
590592
"cat",
591593
"/mnt/volume1/fstype.txt",
592594
}

tests/e2e/gc_block_volume_expansion.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Test", func() {
117117

118118
// Replace second element with pod.Name.
119119
if windowsEnv {
120-
cmd = []string{"exec", "", "--namespace=" + namespace, "powershell.exe", "cat", "/mnt/volume1/fstype.txt"}
120+
cmd = []string{"exec", "", "--namespace=" + namespace, "--", "powershell.exe", "-Command",
121+
"cat", "/mnt/volume1/fstype.txt"}
121122
} else {
122123
cmd = []string{"exec", "", "--namespace=" + namespace, "--", "/bin/sh", "-c", "df -Tkm | grep /mnt/volume1"}
123124
}
@@ -236,9 +237,11 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Test", func() {
236237
"exec",
237238
pod.Name,
238239
"--namespace=" + namespace,
240+
"--",
239241
"powershell.exe",
240-
"$out = New-Object byte[] 536870912; (New-Object Random).NextBytes($out); " +
241-
"[System.IO.File]::WriteAllBytes('/mnt/volume1/testdata2.txt', $out)",
242+
"-Command",
243+
"'$out = New-Object byte[] 536870912; (New-Object Random).NextBytes($out); " +
244+
"[System.IO.File]::WriteAllBytes('/mnt/volume1/testdata2.txt', $out)'",
242245
}
243246
_ = e2ekubectl.RunKubectlOrDie(namespace, cmdTestData...)
244247
} else {
@@ -360,7 +363,9 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Test", func() {
360363
"exec",
361364
pod.Name,
362365
"--namespace=" + namespace,
366+
"--",
363367
"powershell.exe",
368+
"-Command",
364369
"Copy-Item -Path '/mnt/volume1/testdata2.txt' " +
365370
"-Destination '/mnt/volume1/testdata2_pod.txt'",
366371
}
@@ -380,7 +385,9 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Test", func() {
380385
"exec",
381386
pod.Name,
382387
"--namespace=" + namespace,
388+
"--",
383389
"powershell.exe",
390+
"-Command",
384391
"((Get-FileHash '/mnt/volume1/testdata2.txt' -Algorithm SHA256).Hash -eq " +
385392
"(Get-FileHash '/mnt/volume1/testdata2_pod.txt' -Algorithm SHA256).Hash)",
386393
}
@@ -1527,6 +1534,11 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Test", func() {
15271534
ginkgo.By("Creating pod to attach PV to the node")
15281535
pod, err := createPod(ctx, client, namespace, nil, []*v1.PersistentVolumeClaim{pvclaim}, false, execCommand)
15291536
gomega.Expect(err).NotTo(gomega.HaveOccurred())
1537+
defer func() {
1538+
// Delete POD.
1539+
ginkgo.By(fmt.Sprintf("Deleting the pod %s in namespace %s", pod.Name, namespace))
1540+
deletePodAndWaitForVolsToDetach(ctx, client, pod)
1541+
}()
15301542

15311543
ginkgo.By(fmt.Sprintf("Verify volume: %s is attached to the node: %s",
15321544
pv.Spec.CSI.VolumeHandle, pod.Spec.NodeName))
@@ -1564,10 +1576,13 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Test", func() {
15641576
"exec",
15651577
pod.Name,
15661578
"--namespace=" + namespace,
1579+
"--",
15671580
"powershell.exe",
1581+
"-Command",
15681582
"$out = New-Object byte[] 536870912; (New-Object Random).NextBytes($out); " +
15691583
"[System.IO.File]::WriteAllBytes('/mnt/volume1/testdata2.txt', $out)",
15701584
}
1585+
15711586
_ = e2ekubectl.RunKubectlOrDie(namespace, cmdTestData...)
15721587
} else {
15731588
_ = e2ekubectl.RunKubectlOrDie(namespace, "cp", testdataFile,
@@ -1582,7 +1597,9 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Test", func() {
15821597
"exec",
15831598
pod.Name,
15841599
"--namespace=" + namespace,
1600+
"--",
15851601
"powershell.exe",
1602+
"-Command",
15861603
"Copy-Item -Path '/mnt/volume1/testdata2.txt' " +
15871604
"-Destination '/mnt/volume1/testdata2_pod.txt'",
15881605
}
@@ -1603,7 +1620,9 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Test", func() {
16031620
"exec",
16041621
pod.Name,
16051622
"--namespace=" + namespace,
1623+
"--",
16061624
"powershell.exe",
1625+
"-Command",
16071626
"((Get-FileHash '/mnt/volume1/testdata2.txt' -Algorithm SHA256).Hash -eq " +
16081627
"(Get-FileHash '/mnt/volume1/testdata2_pod.txt' -Algorithm SHA256).Hash)",
16091628
}

tests/e2e/k8testutil/util.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,8 @@ func BringDownCsiController(Client clientset.Interface, namespace ...string) {
11461146

11471147
// bringDownTKGController helps to bring the TKG control manager pod down.
11481148
// Its taks svc client as input.
1149-
func BringDownTKGController(Client clientset.Interface) {
1150-
UpdateDeploymentReplica(Client, 0, constants.VsphereControllerManager, constants.VsphereTKGSystemNamespace)
1149+
func BringDownTKGController(Client clientset.Interface, vsphereTKGSystemNamespace string) {
1150+
UpdateDeploymentReplica(Client, 0, constants.VsphereControllerManager, vsphereTKGSystemNamespace)
11511151
ginkgo.By("TKGControllManager replica is set to 0")
11521152
}
11531153

@@ -1168,9 +1168,9 @@ func BringUpCsiController(Client clientset.Interface, csiReplicaCount int32, nam
11681168

11691169
// bringUpTKGController helps to bring the TKG control manager pod up.
11701170
// Its taks svc client as input.
1171-
func BringUpTKGController(Client clientset.Interface, tkgReplica int32) {
1171+
func BringUpTKGController(Client clientset.Interface, tkgReplica int32, vsphereTKGSystemNamespace string) {
11721172
err := UpdateDeploymentReplicawithWait(Client,
1173-
tkgReplica, constants.VsphereControllerManager, constants.VsphereTKGSystemNamespace)
1173+
tkgReplica, constants.VsphereControllerManager, vsphereTKGSystemNamespace)
11741174
gomega.Expect(err).NotTo(gomega.HaveOccurred())
11751175
ginkgo.By("TKGControllManager is up")
11761176
}
@@ -7150,7 +7150,7 @@ func ExecCommandOnGcWorker(sshClientConfig *ssh.ClientConfig,
71507150
}
71517151

71527152
cmdToGetContainerInfo := fmt.Sprintf("ssh -o StrictHostKeyChecking=no -i key %s@%s "+
7153-
"'%s' | grep -v 'Warning'", constants.GcNodeUser, gcWorkerIp, cmd)
7153+
"'%s' 2> /dev/null", constants.GcNodeUser, gcWorkerIp, cmd)
71547154
framework.Logf("Invoking command '%v' on host %v", cmdToGetContainerInfo,
71557155
svcMasterIP)
71567156
cmdResult, err = SshExec(sshClientConfig, vs, svcMasterIP,

tests/e2e/tkgs_ha_utils.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func verifyOnlineVolumeExpansionOnGc(client clientset.Interface, namespace strin
268268
"exec",
269269
pod.Name,
270270
"--namespace=" + namespace,
271-
"powershell.exe",
271+
"-- powershell.exe -Command",
272272
"$out = New-Object byte[] 536870912; (New-Object Random).NextBytes($out); " +
273273
"[System.IO.File]::WriteAllBytes('/mnt/volume1/testdata2.txt', $out)",
274274
}
@@ -286,7 +286,7 @@ func verifyOnlineVolumeExpansionOnGc(client clientset.Interface, namespace strin
286286
"exec",
287287
pod.Name,
288288
"--namespace=" + namespace,
289-
"powershell.exe",
289+
"-- powershell.exe -Command",
290290
"Copy-Item -Path '/mnt/volume1/testdata2.txt' " +
291291
"-Destination '/mnt/volume1/testdata2_pod.txt'",
292292
}
@@ -306,7 +306,7 @@ func verifyOnlineVolumeExpansionOnGc(client clientset.Interface, namespace strin
306306
"exec",
307307
pod.Name,
308308
"--namespace=" + namespace,
309-
"powershell.exe",
309+
"-- powershell.exe -Command",
310310
"((Get-FileHash '/mnt/volume1/testdata2.txt' -Algorithm SHA256).Hash -eq " +
311311
"(Get-FileHash '/mnt/volume1/testdata2_pod.txt' -Algorithm SHA256).Hash)",
312312
}

tests/e2e/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ func bringDownCsiController(Client clientset.Interface, namespace ...string) {
10711071

10721072
// bringDownTKGController helps to bring the TKG control manager pod down.
10731073
// Its taks svc client as input.
1074-
func bringDownTKGController(Client clientset.Interface) {
1074+
func bringDownTKGController(Client clientset.Interface, vsphereTKGSystemNamespace string) {
10751075
updateDeploymentReplica(Client, 0, vsphereControllerManager, vsphereTKGSystemNamespace)
10761076
ginkgo.By("TKGControllManager replica is set to 0")
10771077
}
@@ -1093,7 +1093,7 @@ func bringUpCsiController(Client clientset.Interface, csiReplicaCount int32, nam
10931093

10941094
// bringUpTKGController helps to bring the TKG control manager pod up.
10951095
// Its taks svc client as input.
1096-
func bringUpTKGController(Client clientset.Interface, tkgReplica int32) {
1096+
func bringUpTKGController(Client clientset.Interface, tkgReplica int32, vsphereTKGSystemNamespace string) {
10971097
err := updateDeploymentReplicawithWait(Client, tkgReplica, vsphereControllerManager, vsphereTKGSystemNamespace)
10981098
gomega.Expect(err).NotTo(gomega.HaveOccurred())
10991099
ginkgo.By("TKGControllManager is up")
@@ -7590,7 +7590,7 @@ func execCommandOnGcWorker(sshClientConfig *ssh.ClientConfig, svcMasterIP string
75907590
}
75917591

75927592
cmdToGetContainerInfo := fmt.Sprintf("ssh -o StrictHostKeyChecking=no -i key %s@%s "+
7593-
"'%s' | grep -v 'Warning'", gcNodeUser, gcWorkerIp, cmd)
7593+
"'%s' 2> /dev/null", gcNodeUser, gcWorkerIp, cmd)
75947594
framework.Logf("Invoking command '%v' on host %v", cmdToGetContainerInfo,
75957595
svcMasterIP)
75967596
cmdResult, err = sshExec(sshClientConfig, svcMasterIP,

tests/e2e/volume_health_test.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var _ = ginkgo.Describe("Volume health check", func() {
5757
isVsanHealthServiceStopped bool
5858
isSPSServiceStopped bool
5959
csiNamespace string
60+
vsphereTKGSystemNamespace string
6061
)
6162

6263
ginkgo.BeforeEach(func() {
@@ -70,6 +71,7 @@ var _ = ginkgo.Describe("Volume health check", func() {
7071
csiNamespace = GetAndExpectStringEnvVar(envCSINamespace)
7172
nodeList, err := fnodes.GetReadySchedulableNodes(ctx, f.ClientSet)
7273
datastoreURL = GetAndExpectStringEnvVar(envSharedDatastoreURL)
74+
vsphereTKGSystemNamespace = GetAndExpectStringEnvVar(envVsphereTKGSystemNamespace)
7375
framework.ExpectNoError(err, "Unable to find ready and schedulable Node")
7476
if guestCluster {
7577
svcClient, svNamespace := getSvcClientAndNamespace()
@@ -1289,14 +1291,14 @@ var _ = ginkgo.Describe("Volume health check", func() {
12891291
gomega.Expect(err).NotTo(gomega.HaveOccurred())
12901292
csiReplicaCount := *deployment.Spec.Replicas
12911293

1292-
bringDownTKGController(svClient)
1293-
bringDownCsiController(gcClient)
1294+
bringDownTKGController(svClient, vsphereTKGSystemNamespace)
1295+
bringDownCsiController(gcClient, vsphereTKGSystemNamespace)
12941296
isControllerUP = false
12951297

12961298
defer func() {
12971299
if !isControllerUP {
1298-
bringUpTKGController(svClient, tkgReplicaCount)
1299-
bringUpCsiController(gcClient, csiReplicaCount)
1300+
bringUpTKGController(svClient, tkgReplicaCount, vsphereTKGSystemNamespace)
1301+
bringUpCsiController(gcClient, csiReplicaCount, vsphereTKGSystemNamespace)
13001302
}
13011303
}()
13021304

@@ -1313,8 +1315,8 @@ var _ = ginkgo.Describe("Volume health check", func() {
13131315
gomega.Expect(svPVC.Annotations[volumeHealthAnnotation]).Should(gomega.BeEquivalentTo(healthStatusAccessible))
13141316

13151317
ginkgo.By("Bring up csi-controller pod in GC")
1316-
bringUpTKGController(svClient, tkgReplicaCount)
1317-
bringUpCsiController(gcClient, csiReplicaCount)
1318+
bringUpTKGController(svClient, tkgReplicaCount, vsphereTKGSystemNamespace)
1319+
bringUpCsiController(gcClient, csiReplicaCount, vsphereTKGSystemNamespace)
13181320
isControllerUP = true
13191321

13201322
ginkgo.By("Verify health status of GC PVC after GC csi is up")
@@ -2123,7 +2125,6 @@ var _ = ginkgo.Describe("Volume health check", func() {
21232125
gcClient, err = createKubernetesClientFromConfig(k8senv)
21242126
gomega.Expect(err).NotTo(gomega.HaveOccurred())
21252127
}
2126-
21272128
tkgReplicaDeployment, err := svcClient.AppsV1().Deployments(vsphereTKGSystemNamespace).Get(ctx,
21282129
vsphereControllerManager, metav1.GetOptions{})
21292130
gomega.Expect(err).NotTo(gomega.HaveOccurred())
@@ -2140,8 +2141,8 @@ var _ = ginkgo.Describe("Volume health check", func() {
21402141
err := waitForHostToBeUp(hostIP)
21412142
gomega.Expect(err).NotTo(gomega.HaveOccurred())
21422143
if !isControllerUP {
2143-
bringUpTKGController(svcClient, tkgReplicaCount)
2144-
bringUpCsiController(gcClient, csiReplicaCount)
2144+
bringUpTKGController(svcClient, tkgReplicaCount, vsphereTKGSystemNamespace)
2145+
bringUpCsiController(gcClient, csiReplicaCount, vsphereTKGSystemNamespace)
21452146
}
21462147
err = fpv.DeletePersistentVolumeClaim(ctx, client, pvc.Name, namespace)
21472148
gomega.Expect(err).NotTo(gomega.HaveOccurred())
@@ -2160,8 +2161,8 @@ var _ = ginkgo.Describe("Volume health check", func() {
21602161
gomega.Expect(pvclaim.Annotations[volumeHealthAnnotation]).Should(gomega.BeEquivalentTo(healthStatusAccessible))
21612162

21622163
ginkgo.By("Bring down csi-controller pod in GC")
2163-
bringDownTKGController(svcClient)
2164-
bringDownCsiController(gcClient)
2164+
bringDownTKGController(svcClient, vsphereTKGSystemNamespace)
2165+
bringDownCsiController(gcClient, vsphereTKGSystemNamespace)
21652166
isControllerUP = false
21662167

21672168
// Get SV PVC before PSOD.
@@ -2181,8 +2182,8 @@ var _ = ginkgo.Describe("Volume health check", func() {
21812182
gomega.Expect(err).NotTo(gomega.HaveOccurred())
21822183

21832184
ginkgo.By("Bring up csi-controller pod in GC")
2184-
bringUpTKGController(svcClient, tkgReplicaCount)
2185-
bringUpCsiController(gcClient, csiReplicaCount)
2185+
bringUpTKGController(svcClient, tkgReplicaCount, vsphereTKGSystemNamespace)
2186+
bringUpCsiController(gcClient, csiReplicaCount, vsphereTKGSystemNamespace)
21862187
isControllerUP = true
21872188

21882189
ginkgo.By("Verify health status of GC PVC after GC csi is up")

0 commit comments

Comments
 (0)