Skip to content

Commit

Permalink
Bring down the syncer container in the e2e test to verify volume crea…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
chethanv28 committed Sep 26, 2019
1 parent cd98147 commit 4813502
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/e2e_common.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (


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


// GetAndExpectStringEnvVar parses a string from env variable // GetAndExpectStringEnvVar parses a string from env variable
Expand Down
30 changes: 17 additions & 13 deletions tests/e2e/fullsynctest.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
fcdName = "BasicStaticFCD" fcdName = "BasicStaticFCD"
stopVsanHealthOperation = "stop" stopVsanHealthOperation = "stop"
startVsanHealthOperation = "start" startVsanHealthOperation = "start"
vcenterPort = "22" sshdPort = "22"
numberOfPVC = 5 numberOfPVC = 5
) )


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


ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host")) 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) err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred()) gomega.Expect(err).NotTo(gomega.HaveOccurred())


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


ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host")) 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) err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred()) gomega.Expect(err).NotTo(gomega.HaveOccurred())


Expand Down Expand Up @@ -267,7 +267,7 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
} }
gomega.Expect(datastore).NotTo(gomega.BeNil()) gomega.Expect(datastore).NotTo(gomega.BeNil())
ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host")) 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) err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred()) gomega.Expect(err).NotTo(gomega.HaveOccurred())


Expand Down Expand Up @@ -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")) 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) err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred()) gomega.Expect(err).NotTo(gomega.HaveOccurred())


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


ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host")) 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) err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred()) gomega.Expect(err).NotTo(gomega.HaveOccurred())


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


ginkgo.By(fmt.Sprintln("Stopping vsan-health on the vCenter host")) 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) err = invokeVCenterServiceControl(stopVsanHealthOperation, vsanhealthServiceName, vcAddress)
gomega.Expect(err).NotTo(gomega.HaveOccurred()) gomega.Expect(err).NotTo(gomega.HaveOccurred())


Expand Down Expand Up @@ -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)) 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) time.Sleep(time.Duration(pandoraSyncWaitTime) * time.Second)


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


ginkgo.By(fmt.Sprintf("Creating the PV with the fcdID %s", fcdID)) ginkgo.By(fmt.Sprintf("Creating the PV with the fcdID %s", fcdID))
staticPVLabels := make(map[string]string) staticPVLabels := make(map[string]string)
Expand All @@ -598,6 +599,9 @@ var _ bool = ginkgo.Describe("[csi-block-e2e] full-sync-test", func() {
pv, err = client.CoreV1().PersistentVolumes().Create(pv) pv, err = client.CoreV1().PersistentVolumes().Create(pv)
gomega.Expect(err).NotTo(gomega.HaveOccurred()) 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)) ginkgo.By(fmt.Sprintf("Sleeping for %v seconds to allow full sync finish", fullSyncWaitTime))
time.Sleep(time.Duration(fullSyncWaitTime) * time.Second) time.Sleep(time.Duration(fullSyncWaitTime) * time.Second)


Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/util.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -354,6 +354,19 @@ func invokeVCenterServiceControl(command, service, host string) error {
return nil 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 // verifyVolumeTopology verifies that the Node Affinity rules in the volume
// match the topology constraints specified in the storage class // match the topology constraints specified in the storage class
func verifyVolumeTopology(pv *v1.PersistentVolume, zoneValues []string, regionValues []string) (string, string, error) { func verifyVolumeTopology(pv *v1.PersistentVolume, zoneValues []string, regionValues []string) (string, string, error) {
Expand Down

0 comments on commit 4813502

Please sign in to comment.