From 5740c7afbf42f744e6446b1e152a68508f6bf8db Mon Sep 17 00:00:00 2001 From: Wojciech Tyczynski Date: Mon, 24 Jul 2017 12:10:22 +0200 Subject: [PATCH] Fix ha_master tests --- cluster/gce/util.sh | 18 ++++++++---------- test/e2e/lifecycle/ha_master.go | 16 ++++++---------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index 86cff60a3bf..c430cb6d2a1 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -2035,8 +2035,7 @@ function test-setup() { detect-project if [[ ${MULTIZONE:-} == "true" && -n ${E2E_ZONES:-} ]]; then - for KUBE_GCE_ZONE in ${E2E_ZONES} - do + for KUBE_GCE_ZONE in ${E2E_ZONES}; do KUBE_GCE_ZONE="${KUBE_GCE_ZONE}" KUBE_USE_EXISTING_MASTER="${KUBE_USE_EXISTING_MASTER:-}" "${KUBE_ROOT}/cluster/kube-up.sh" KUBE_USE_EXISTING_MASTER="true" # For subsequent zones we use the existing master done @@ -2092,15 +2091,14 @@ function test-teardown() { "${NODE_TAG}-${INSTANCE_PREFIX}-http-alt" \ "${NODE_TAG}-${INSTANCE_PREFIX}-nodeports" if [[ ${MULTIZONE:-} == "true" && -n ${E2E_ZONES:-} ]]; then - local zones=( ${E2E_ZONES} ) - # tear them down in reverse order, finally tearing down the master too. - for ((zone_num=${#zones[@]}-1; zone_num>0; zone_num--)) - do - KUBE_GCE_ZONE="${zones[zone_num]}" KUBE_USE_EXISTING_MASTER="true" "${KUBE_ROOT}/cluster/kube-down.sh" - done - KUBE_GCE_ZONE="${zones[0]}" KUBE_USE_EXISTING_MASTER="false" "${KUBE_ROOT}/cluster/kube-down.sh" + local zones=( ${E2E_ZONES} ) + # tear them down in reverse order, finally tearing down the master too. + for ((zone_num=${#zones[@]}-1; zone_num>0; zone_num--)); do + KUBE_GCE_ZONE="${zones[zone_num]}" KUBE_USE_EXISTING_MASTER="true" "${KUBE_ROOT}/cluster/kube-down.sh" + done + KUBE_GCE_ZONE="${zones[0]}" KUBE_USE_EXISTING_MASTER="false" "${KUBE_ROOT}/cluster/kube-down.sh" else - "${KUBE_ROOT}/cluster/kube-down.sh" + "${KUBE_ROOT}/cluster/kube-down.sh" fi } diff --git a/test/e2e/lifecycle/ha_master.go b/test/e2e/lifecycle/ha_master.go index 89899379426..a9912d5f874 100644 --- a/test/e2e/lifecycle/ha_master.go +++ b/test/e2e/lifecycle/ha_master.go @@ -32,8 +32,7 @@ import ( func addMasterReplica(zone string) error { framework.Logf(fmt.Sprintf("Adding a new master replica, zone: %s", zone)) - v, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-grow-cluster.sh"), zone, "true", "true", "false") - framework.Logf("%s", v) + _, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-grow-cluster.sh"), zone, "true", "true", "false") if err != nil { return err } @@ -42,8 +41,7 @@ func addMasterReplica(zone string) error { func removeMasterReplica(zone string) error { framework.Logf(fmt.Sprintf("Removing an existing master replica, zone: %s", zone)) - v, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-shrink-cluster.sh"), zone, "true", "false", "false") - framework.Logf("%s", v) + _, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-shrink-cluster.sh"), zone, "true", "false", "false") if err != nil { return err } @@ -52,8 +50,7 @@ func removeMasterReplica(zone string) error { func addWorkerNodes(zone string) error { framework.Logf(fmt.Sprintf("Adding worker nodes, zone: %s", zone)) - v, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-grow-cluster.sh"), zone, "true", "false", "true") - framework.Logf("%s", v) + _, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-grow-cluster.sh"), zone, "true", "false", "true") if err != nil { return err } @@ -62,8 +59,7 @@ func addWorkerNodes(zone string) error { func removeWorkerNodes(zone string) error { framework.Logf(fmt.Sprintf("Removing worker nodes, zone: %s", zone)) - v, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-shrink-cluster.sh"), zone, "true", "true", "true") - framework.Logf("%s", v) + _, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-shrink-cluster.sh"), zone, "true", "true", "true") if err != nil { return err } @@ -82,7 +78,7 @@ func createNewRC(c clientset.Interface, ns string, name string) { } func findRegionForZone(zone string) string { - region, err := exec.Command("gcloud", "compute", "zones", "list", zone, "--quiet", "--format=[no-heading](region)").CombinedOutput() + region, err := exec.Command("gcloud", "compute", "zones", "list", zone, "--quiet", "--format=csv[no-heading](region)").CombinedOutput() framework.ExpectNoError(err) if string(region) == "" { framework.Failf("Region not found; zone: %s", zone) @@ -92,7 +88,7 @@ func findRegionForZone(zone string) string { func findZonesForRegion(region string) []string { output, err := exec.Command("gcloud", "compute", "zones", "list", "--filter=region="+region, - "--quiet", "--format=[no-heading](name)").CombinedOutput() + "--quiet", "--format=csv[no-heading](name)").CombinedOutput() framework.ExpectNoError(err) zones := strings.Split(string(output), "\n") return zones