Skip to content
Permalink
Browse files

Bring down the syncer container in the e2e test to verify volume crea…

…tion
  • Loading branch information
chethanv28 committed Sep 26, 2019
1 parent cd98147 commit 48135025938cd222f0fda8e318e396f777a55e10
Showing with 31 additions and 14 deletions.
  1. +1 −1 tests/e2e/e2e_common.go
  2. +17 −13 tests/e2e/fullsynctest.go
  3. +13 −0 tests/e2e/util.go
@@ -26,6 +26,7 @@ import (

const (
envSharedDatastoreURL = "SHARED_VSPHERE_DATASTORE_URL"
envMasterNodeIP = "K8S_MASTER_NODE_IP"
envNonSharedStorageClassDatastoreURL = "NONSHARED_VSPHERE_DATASTORE_URL"
envInaccessibleZoneDatastoreURL = "INACCESSIBLE_ZONE_VSPHERE_DATASTORE_URL"
scParamDatastoreURL = "DatastoreURL"
@@ -58,7 +59,6 @@ const (
execCommand = "/bin/df -T /mnt/volume1 | /bin/awk 'FNR == 2 {print $2}' > /mnt/volume1/fstype && while true ; do sleep 2 ; done"
kubeSystemNamespace = "kube-system"
syncerContainerName = "vsphere-syncer"
csiControllerPodName = "vsphere-csi-controller-0"
)

// GetAndExpectStringEnvVar parses a string from env variable
@@ -69,7 +69,7 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
fcdName = "BasicStaticFCD"
stopVsanHealthOperation = "stop"
startVsanHealthOperation = "start"
vcenterPort = "22"
sshdPort = "22"
numberOfPVC = 5
)

@@ -140,7 +140,7 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
time.Sleep(time.Duration(pandoraSyncWaitTime) * time.Second)

ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host"))
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + vcenterPort
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + sshdPort
err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

@@ -187,7 +187,7 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
pv := pvs[0]

ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host"))
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + vcenterPort
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + sshdPort
err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

@@ -267,7 +267,7 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
}
gomega.Expect(datastore).NotTo(gomega.BeNil())
ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host"))
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + vcenterPort
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + sshdPort
err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

@@ -328,7 +328,7 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
}

ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host"))
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + vcenterPort
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + sshdPort
err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

@@ -439,7 +439,7 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())

ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host"))
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + vcenterPort
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + sshdPort
err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

@@ -524,7 +524,7 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
framework.ExpectNoError(framework.WaitOnPVandPVC(client, namespace, pv, pvc))

ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host"))
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + vcenterPort
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + sshdPort
err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

@@ -584,12 +584,13 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
ginkgo.By(fmt.Sprintf("Sleeping for %v seconds to allow newly created FCD:%s to sync with pandora", pandoraSyncWaitTime, fcdID))
time.Sleep(time.Duration(pandoraSyncWaitTime) * time.Second)

ginkgo.By(fmt.Sprintf("Kill the syncer container"))
testNamespace := f.Namespace.Name
f.Namespace.Name = kubeSystemNamespace
out := f.ExecCommandInContainer(csiControllerPodName, syncerContainerName, "kill", "-9", "1")
gomega.Expect(out).ShouldNot(gomega.ContainSubstring("failed"))
f.Namespace.Name = testNamespace
k8sMasterNode := GetAndExpectStringEnvVar(envMasterNodeIP)
masterNode := k8sMasterNode + ":" + sshdPort
stdout, err := invokeDockerCommand("ps -qf", "name="+syncerContainerName, masterNode)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
containerID := stdout
stdout, err = invokeDockerCommand("stop", containerID, masterNode)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

ginkgo.By(fmt.Sprintf("Creating the PV with the fcdID %s", fcdID))
staticPVLabels := make(map[string]string)
@@ -598,6 +599,9 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
pv, err = client.CoreV1().PersistentVolumes().Create(pv)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

stdout, err = invokeDockerCommand("start", containerID, masterNode)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

ginkgo.By(fmt.Sprintf("Sleeping for %v seconds to allow full sync finish", fullSyncWaitTime))
time.Sleep(time.Duration(fullSyncWaitTime) * time.Second)

@@ -354,6 +354,19 @@ func invokeVCenterServiceControl(command, service, host string) error {
return nil
}

// invokeDockerCommand invokes the given docker command for the given options on the given nodeVM over SSH.
func invokeDockerCommand(option string, container string, host string) (string, error) {
sshCmd := fmt.Sprintf("docker %s %s", option, container)
framework.Logf("Invoking command %v on vCenter host %v", sshCmd, host)
result, err := framework.SSH(sshCmd, host, framework.TestContext.Provider)
if err != nil || result.Code != 0 {
framework.LogSSHResult(result)
return "", fmt.Errorf("couldn't execute command: %s on vCenter host: %v", sshCmd, err)
}
framework.Logf("SSH RESULT %s", result.Stdout)
return result.Stdout, nil
}

// verifyVolumeTopology verifies that the Node Affinity rules in the volume
// match the topology constraints specified in the storage class
func verifyVolumeTopology(pv *v1.PersistentVolume, zoneValues []string, regionValues []string) (string, string, error) {

0 comments on commit 4813502

Please sign in to comment.
You can’t perform that action at this time.