Skip to content

Commit

Permalink
tkg test adaptation on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rajguptavm committed Nov 4, 2024
1 parent 5e42551 commit 90dfbf8
Show file tree
Hide file tree
Showing 18 changed files with 720 additions and 261 deletions.
4 changes: 3 additions & 1 deletion tests/e2e/csi_cns_telemetry_statefulsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ var _ = ginkgo.Describe("[csi-block-vanilla] [csi-file-vanilla] [csi-supervisor]
replicas := *(statefulset.Spec.Replicas)
// Waiting for pods status to be Ready.
fss.WaitForStatusReadyReplicas(ctx, client, statefulset, replicas)
gomega.Expect(fss.CheckMount(ctx, client, statefulset, mountPath)).NotTo(gomega.HaveOccurred())
if !windowsEnv {
gomega.Expect(fss.CheckMount(ctx, client, statefulset, mountPath)).NotTo(gomega.HaveOccurred())
}
ssPodsBeforeScaleDown := fss.GetPodList(ctx, client, statefulset)
gomega.Expect(ssPodsBeforeScaleDown.Items).NotTo(gomega.BeEmpty(),
fmt.Sprintf("Unable to get list of Pods from the Statefulset: %v", statefulset.Name))
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/csi_snapshot_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,9 @@ var _ = ginkgo.Describe("Volume Snapshot Basic Test", func() {

// Waiting for pods status to be Ready
fss.WaitForStatusReadyReplicas(ctx, client, statefulset, replicas)
gomega.Expect(fss.CheckMount(ctx, client, statefulset, mountPath)).NotTo(gomega.HaveOccurred())
if !windowsEnv {
gomega.Expect(fss.CheckMount(ctx, client, statefulset, mountPath)).NotTo(gomega.HaveOccurred())
}
ssPodsBeforeScaleDown := fss.GetPodList(ctx, client, statefulset)
gomega.Expect(ssPodsBeforeScaleDown.Items).NotTo(gomega.BeEmpty(),
fmt.Sprintf("Unable to get list of Pods from the Statefulset: %v", statefulset.Name))
Expand Down
20 changes: 15 additions & 5 deletions tests/e2e/csi_snapshot_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,15 +660,25 @@ func verifyVolumeRestoreOperation(ctx context.Context, client clientset.Interfac
isDiskAttached, err := e2eVSphere.isVolumeAttachedToVM(client, volHandle2, vmUUID)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(isDiskAttached).To(gomega.BeTrue(), "Volume is not attached to the node")

var cmd []string
ginkgo.By("Verify the volume is accessible and Read/write is possible")
cmd := []string{"exec", pod.Name, "--namespace=" + namespace, "--", "/bin/sh", "-c",
"cat /mnt/volume1/Pod1.html "}
if windowsEnv {
cmd = []string{"exec", pod.Name, "--namespace=" + namespace, "powershell.exe", "cat /mnt/volume1/Pod1.html"}
} else {
cmd = []string{"exec", pod.Name, "--namespace=" + namespace, "--", "/bin/sh", "-c",
"cat /mnt/volume1/Pod1.html "}
}
output := e2ekubectl.RunKubectlOrDie(namespace, cmd...)
gomega.Expect(strings.Contains(output, "Hello message from Pod1")).NotTo(gomega.BeFalse())

wrtiecmd := []string{"exec", pod.Name, "--namespace=" + namespace, "--", "/bin/sh", "-c",
"echo 'Hello message from test into Pod1' >> /mnt/volume1/Pod1.html"}
var wrtiecmd []string
if windowsEnv {
wrtiecmd = []string{"exec", pod.Name, "--namespace=" + namespace, "powershell.exe", "Add-Content /mnt/volume1/Pod1.html 'Hello message from test into Pod1'"}
} else {
wrtiecmd = []string{"exec", pod.Name, "--namespace=" + namespace, "--", "/bin/sh", "-c",
"echo 'Hello message from test into Pod1' > /mnt/volume1/Pod1.html"}
}

e2ekubectl.RunKubectlOrDie(namespace, wrtiecmd...)
output = e2ekubectl.RunKubectlOrDie(namespace, cmd...)
gomega.Expect(strings.Contains(output, "Hello message from test into Pod1")).NotTo(gomega.BeFalse())
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e/csi_static_provisioning_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ var _ = ginkgo.Describe("Basic Static Provisioning", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}
if guestCluster {
svcClient, svNamespace := getSvcClientAndNamespace()
setResourceQuota(svcClient, svNamespace, rqLimit)
// Get a config to talk to the apiserver
restConfig := getRestConfigClient()
_, svNamespace := getSvcClientAndNamespace()
setStoragePolicyQuota(ctx, restConfig, storagePolicyName, svNamespace, rqLimit)
}

if os.Getenv(envFullSyncWaitTime) != "" {
Expand Down Expand Up @@ -181,7 +183,6 @@ var _ = ginkgo.Describe("Basic Static Provisioning", func() {

if guestCluster {
svcClient, svNamespace := getSvcClientAndNamespace()
setResourceQuota(svcClient, svNamespace, defaultrqLimit)
dumpSvcNsEventsOnTestFailure(svcClient, svNamespace)
}
if supervisorCluster {
Expand Down Expand Up @@ -212,7 +213,8 @@ var _ = ginkgo.Describe("Basic Static Provisioning", func() {
framework.Logf("storageclass name :%s", storageclass.GetName())

ginkgo.By("create resource quota")
setStoragePolicyQuota(ctx, restConfig, storagePolicyName, namespace, rqLimit)
// setStoragePolicyQuota(ctx, restConfig, storagePolicyName, namespace, rqLimit)
createResourceQuota(client, namespace, rqLimit, storagePolicyName)

return restConfig, storageclass, profileID
}
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/e2e_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,19 @@ const (
evacMModeType = "evacuateAllData"
fcdName = "BasicStaticFCD"
fileSizeInMb = int64(2048)
filePathPod = "/mnt/volume1/Pod.html"
filePathPod1 = "/mnt/volume1/Pod1.html"
filePathPod2 = "/mnt/volume1/Pod2.html"
filePathFsType = "/mnt/volume1/fstype"
fullSyncFss = "trigger-csi-fullsync"
gcNodeUser = "vmware-system-user"
gcKubeConfigPath = "GC_KUBE_CONFIG"
gcSshKey = "TEST-CLUSTER-SSH-KEY"
healthGreen = "green"
healthRed = "red"
healthStatusAccessible = "accessible"
healthStatusInAccessible = "inaccessible"
healthStatusWaitTime = 2 * time.Minute
healthStatusWaitTime = 3 * time.Minute
hostdServiceName = "hostd"
invalidFSType = "ext10"
k8sPodTerminationTimeOut = 7 * time.Minute
Expand Down Expand Up @@ -220,7 +223,7 @@ const (
vsphereCloudProviderConfiguration = "vsphere-cloud-provider.conf"
vsphereControllerManager = "vmware-system-tkg-controller-manager"
vSphereCSIConf = "csi-vsphere.conf"
vsphereTKGSystemNamespace = "vmware-system-tkg"
vsphereTKGSystemNamespace = "svc-tkg-domain-c10"
waitTimeForCNSNodeVMAttachmentReconciler = 30 * time.Second
wcpServiceName = "wcp"
vmcWcpHost = "10.2.224.24" //This is the LB IP of VMC WCP and its constant
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/fullsync_test_for_block_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,8 @@ var _ bool = ginkgo.Describe("full-sync-test", func() {

// TODO: Replace static wait with polling
ginkgo.By(fmt.Sprintf("Sleeping for %v seconds to allow vsan-health to completely shutdown",
vsanHealthServiceWaitTime))
time.Sleep(time.Duration(vsanHealthServiceWaitTime) * time.Second)
oneMinuteWaitTimeInSeconds))
time.Sleep(time.Duration(oneMinuteWaitTimeInSeconds) * time.Second)

ginkgo.By("when vsan-health is stopped, delete pod1")
err = fpod.DeletePodWithWait(ctx, client, pod)
Expand Down Expand Up @@ -910,6 +910,7 @@ var _ bool = ginkgo.Describe("full-sync-test", func() {

ginkgo.By(fmt.Sprintf("Waiting for CNS volume %s to be deleted", volHandle))
err = e2eVSphere.waitForCNSVolumeToBeDeleted(volHandle)

gomega.Expect(err).NotTo(gomega.HaveOccurred())

})
Expand Down
75 changes: 59 additions & 16 deletions tests/e2e/gc_block_resize_retain_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
storagePolicyName = GetAndExpectStringEnvVar(envStoragePolicyNameForSharedDatastores)

scParameters := make(map[string]string)
scParameters[scParamFsType] = ext4FSType
if windowsEnv {
scParameters[scParamFsType] = ntfsFSType
} else {
scParameters[scParamFsType] = ext4FSType
}
// Set resource quota.
ginkgo.By("Set Resource quota for GC")
svcClient, svNamespace := getSvcClientAndNamespace()
Expand Down Expand Up @@ -122,8 +126,11 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
pvDeleted = false

// Replace second element with pod.Name.
cmd = []string{"exec", "", fmt.Sprintf("--namespace=%v", namespace),
"--", "/bin/sh", "-c", "df -Tkm | grep /mnt/volume1"}
if windowsEnv {
cmd = []string{"exec", "", "--namespace=" + namespace, "powershell.exe", "cat", "/mnt/volume1/fstype.txt"}
} else {
cmd = []string{"exec", "", "--namespace=" + namespace, "--", "/bin/sh", "-c", "df -Tkm | grep /mnt/volume1"}
}

// Set up default pandora sync wait time.
pandoraSyncWaitTime = defaultPandoraSyncWaitTime
Expand Down Expand Up @@ -219,10 +226,15 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
ginkgo.By("Verify the volume is accessible and filesystem type is as expected")
cmd[1] = pod.Name
lastOutput := e2ekubectl.RunKubectlOrDie(namespace, cmd...)
gomega.Expect(strings.Contains(lastOutput, ext4FSType)).NotTo(gomega.BeFalse())
if windowsEnv {
gomega.Expect(strings.Contains(lastOutput, ntfsFSType)).NotTo(gomega.BeFalse())
} else {
gomega.Expect(strings.Contains(lastOutput, ext4FSType)).NotTo(gomega.BeFalse())
}

ginkgo.By("Check filesystem size for mount point /mnt/volume1 before expansion")
originalFsSize, err := getFSSizeMb(f, pod)
// originalFsSize, err := getFSSizeMb(f, pod)
originalFsSize, err := getFileSystemSizeForOsType(f, client, pod)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// Delete POD.
Expand Down Expand Up @@ -337,7 +349,11 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
ginkgo.By("Verify after expansion the filesystem type is as expected")
cmd[1] = pod.Name
lastOutput = e2ekubectl.RunKubectlOrDie(namespace, cmd...)
gomega.Expect(strings.Contains(lastOutput, ext4FSType)).NotTo(gomega.BeFalse())
if windowsEnv {
gomega.Expect(strings.Contains(lastOutput, ntfsFSType)).NotTo(gomega.BeFalse())
} else {
gomega.Expect(strings.Contains(lastOutput, ext4FSType)).NotTo(gomega.BeFalse())
}

ginkgo.By("Waiting for file system resize to finish")
pvclaim, err = waitForFSResize(pvclaim, client)
Expand All @@ -347,7 +363,8 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
expectEqual(len(pvcConditions), 0, "pvc should not have conditions")

ginkgo.By("Verify filesystem size for mount point /mnt/volume1 after expansion")
fsSize, err := getFSSizeMb(f, pod)
// fsSize, err := getFSSizeMb(f, pod)
fsSize, err := getFileSystemSizeForOsType(f, client, pod)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
// Filesystem size may be smaller than the size of the block volume.
// Here since filesystem was already formatted on the original volume,
Expand Down Expand Up @@ -435,7 +452,11 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
_ = getPVCFromSupervisorCluster(svcPVCName)

scParameters := make(map[string]string)
scParameters[scParamFsType] = ext4FSType
if windowsEnv {
scParameters[scParamFsType] = ntfsFSType
} else {
scParameters[scParamFsType] = ext4FSType
}
scParameters[svStorageClassName] = storagePolicyName
storageclassNewGC, err := createStorageClass(clientNewGc,
scParameters, nil, v1.PersistentVolumeReclaimDelete, "", true, "")
Expand Down Expand Up @@ -468,7 +489,12 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
gomega.Expect(volumeID).NotTo(gomega.BeEmpty())

ginkgo.By("Creating the PV")
pvNew := getPersistentVolumeSpec(svcPVCName, v1.PersistentVolumeReclaimDelete, nil, ext4FSType)
var pvNew *v1.PersistentVolume
if windowsEnv {
pvNew = getPersistentVolumeSpec(svcPVCName, v1.PersistentVolumeReclaimDelete, nil, ntfsFSType)
} else {
pvNew = getPersistentVolumeSpec(svcPVCName, v1.PersistentVolumeReclaimDelete, nil, ext4FSType)
}
pvNew.Annotations = pvtemp.Annotations
pvNew.Spec.StorageClassName = pvtemp.Spec.StorageClassName
pvNew.Spec.CSI = pvtemp.Spec.CSI
Expand Down Expand Up @@ -557,10 +583,17 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
framework.TestContext.KubeConfig = oldKubeConfig
}()

cmd2 = []string{"exec", pod.Name, fmt.Sprintf("--namespace=%v", namespaceNewGC),
"--", "/bin/sh", "-c", "df -Tkm | grep /mnt/volume1"}
if windowsEnv {
cmd2 = []string{"exec", pod.Name, "--namespace=" + namespace, "powershell.exe", "cat", "/mnt/volume1/fstype.txt"}
} else {
cmd2 = []string{"exec", pod.Name, "--namespace=" + namespace, "--", "/bin/sh", "-c", "df -Tkm | grep /mnt/volume1"}
}
lastOutput := e2ekubectl.RunKubectlOrDie(namespaceNewGC, cmd2...)
gomega.Expect(strings.Contains(lastOutput, ext4FSType)).NotTo(gomega.BeFalse())
if windowsEnv {
gomega.Expect(strings.Contains(lastOutput, ntfsFSType)).NotTo(gomega.BeFalse())
} else {
gomega.Expect(strings.Contains(lastOutput, ext4FSType)).NotTo(gomega.BeFalse())
}

ginkgo.By("Waiting for file system resize to finish")
pvcNew, err = waitForFSResize(pvcNew, clientNewGc)
Expand Down Expand Up @@ -676,10 +709,15 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
ginkgo.By("Verify the volume is accessible and filesystem type is as expected")
cmd[1] = pod.Name
lastOutput := e2ekubectl.RunKubectlOrDie(namespace, cmd...)
gomega.Expect(strings.Contains(lastOutput, ext4FSType)).NotTo(gomega.BeFalse())
if windowsEnv {
gomega.Expect(strings.Contains(lastOutput, ntfsFSType)).NotTo(gomega.BeFalse())
} else {
gomega.Expect(strings.Contains(lastOutput, ext4FSType)).NotTo(gomega.BeFalse())
}

ginkgo.By("Check filesystem size for mount point /mnt/volume1 before expansion")
originalFsSize, err := getFSSizeMb(f, pod)
// originalFsSize, err := getFSSizeMb(f, pod)
originalFsSize, err := getFileSystemSizeForOsType(f, client, pod)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

defer func() {
Expand Down Expand Up @@ -743,7 +781,8 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
expectEqual(len(pvcConditions), 0, "pvc should not have conditions")

ginkgo.By("Verify filesystem size for mount point /mnt/volume1 after expansion")
fsSize, err := getFSSizeMb(f, pod)
// fsSize, err := getFSSizeMb(f, pod)
fsSize, err := getFileSystemSizeForOsType(f, client, pod)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
// Filesystem size may be smaller than the size of the block volume.
// Here since filesystem was already formatted on the original volume,
Expand Down Expand Up @@ -884,7 +923,11 @@ var _ = ginkgo.Describe("[csi-guest] Volume Expansion Tests with reclaimation po
isGC2PVCreated = false

scParameters := make(map[string]string)
scParameters[scParamFsType] = ext4FSType
if windowsEnv {
scParameters[scParamFsType] = ntfsFSType
} else {
scParameters[scParamFsType] = ext4FSType
}
scParameters[svStorageClassName] = storagePolicyName
storageclassInGC1, err := createStorageClass(client,
scParameters, nil, v1.PersistentVolumeReclaimDelete, "", true, "")
Expand Down
Loading

0 comments on commit 90dfbf8

Please sign in to comment.