From 7ae0d7aa264b93c0a3e241d8a09557d1ef972982 Mon Sep 17 00:00:00 2001 From: Andy Zheng Date: Thu, 24 Mar 2016 10:42:46 -0700 Subject: [PATCH] Support differentiation of OS distro in e2e tests --- cluster/gce/trusty/master.yaml | 5 ++++- hack/ginkgo-e2e.sh | 1 + hack/verify-flags/known-flags.txt | 1 + test/e2e/addon_update.go | 18 ++++++++++++++++-- test/e2e/e2e.go | 1 + test/e2e/util.go | 1 + 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/cluster/gce/trusty/master.yaml b/cluster/gce/trusty/master.yaml index ca4bc4ee2fda9..07ad66ff07f9a 100644 --- a/cluster/gce/trusty/master.yaml +++ b/cluster/gce/trusty/master.yaml @@ -219,8 +219,11 @@ script export TOKEN_DIR="/etc/srv/kubernetes" export kubelet_kubeconfig_file="/var/lib/kubelet/kubeconfig" export TRUSTY_MASTER="true" + if [ -n "${TEST_ADDON_CHECK_INTERVAL_SEC:-}" ]; then + export TEST_ADDON_CHECK_INTERVAL_SEC=${TEST_ADDON_CHECK_INTERVAL_SEC} + fi # Run the script to start and monitoring addon manifest changes. - exec /var/lib/cloud/scripts/kubernetes/kube-addons.sh + exec /var/lib/cloud/scripts/kubernetes/kube-addons.sh 1>>/var/log/kube-addons.log 2>&1 end script # Wait for 10s to start it again. diff --git a/hack/ginkgo-e2e.sh b/hack/ginkgo-e2e.sh index 81dd8acaa2f17..44cb80d02cbf6 100755 --- a/hack/ginkgo-e2e.sh +++ b/hack/ginkgo-e2e.sh @@ -104,6 +104,7 @@ export PATH=$(dirname "${e2e_test}"):"${PATH}" --repo-root="${KUBE_ROOT}" \ --node-instance-group="${NODE_INSTANCE_GROUP:-}" \ --prefix="${KUBE_GCE_INSTANCE_PREFIX:-e2e}" \ + ${KUBE_OS_DISTRIBUTION:+"--os-distro=${KUBE_OS_DISTRIBUTION}"} \ ${NUM_NODES:+"--num-nodes=${NUM_NODES}"} \ ${E2E_CLEAN_START:+"--clean-start=true"} \ ${E2E_MIN_STARTUP_PODS:+"--minStartupPods=${E2E_MIN_STARTUP_PODS}"} \ diff --git a/hack/verify-flags/known-flags.txt b/hack/verify-flags/known-flags.txt index 1a19f57e9ab0c..24db57f457564 100644 --- a/hack/verify-flags/known-flags.txt +++ b/hack/verify-flags/known-flags.txt @@ -273,6 +273,7 @@ oidc-groups-claim oidc-username-claim only-idl oom-score-adj +os-distro out-version outofdisk-transition-frequency output-base diff --git a/test/e2e/addon_update.go b/test/e2e/addon_update.go index 116485dd6b8ee..4e496c15451ca 100644 --- a/test/e2e/addon_update.go +++ b/test/e2e/addon_update.go @@ -210,13 +210,27 @@ var _ = Describe("Addon update", func() { // Reduce the addon update intervals so that we have faster response // to changes in the addon directory. // do not use "service" command because it clears the environment variables - sshExecAndVerify(sshClient, "sudo TEST_ADDON_CHECK_INTERVAL_SEC=1 /etc/init.d/kube-addons restart") + switch testContext.OSDistro { + case "debian": + sshExecAndVerify(sshClient, "sudo TEST_ADDON_CHECK_INTERVAL_SEC=1 /etc/init.d/kube-addons restart") + case "trusty": + sshExecAndVerify(sshClient, "sudo initctl restart kube-addons TEST_ADDON_CHECK_INTERVAL_SEC=1") + default: + Failf("Unsupported OS distro type %s", testContext.OSDistro) + } }) AfterEach(func() { if sshClient != nil { // restart addon_update with the default options - sshExec(sshClient, "sudo /etc/init.d/kube-addons restart") + switch testContext.OSDistro { + case "debian": + sshExec(sshClient, "sudo /etc/init.d/kube-addons restart") + case "trusty": + sshExec(sshClient, "sudo initctl restart kube-addons") + default: + Failf("Unsupported OS distro type %s", testContext.OSDistro) + } sshClient.Close() } }) diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index 593f547cce434..fd296e044bb18 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -72,6 +72,7 @@ func RegisterFlags() { flag.StringVar(&testContext.OutputDir, "e2e-output-dir", "/tmp", "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.") flag.StringVar(&testContext.ReportDir, "report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.") flag.StringVar(&testContext.prefix, "prefix", "e2e", "A prefix to be added to cloud resources created during testing.") + flag.StringVar(&testContext.OSDistro, "os-distro", "debian", "The OS distribution of cluster VM instances (debian, trusty, or coreos).") // TODO: Flags per provider? Rename gce-project/gce-zone? flag.StringVar(&cloudConfig.MasterName, "kube-master", "", "Name of the kubernetes master. Only required if provider is gce or gke") diff --git a/test/e2e/util.go b/test/e2e/util.go index 04375fe7c19cd..70277a25eea09 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -186,6 +186,7 @@ type TestContextType struct { MinStartupPods int UpgradeTarget string PrometheusPushGateway string + OSDistro string VerifyServiceAccount bool DeleteNamespace bool CleanStart bool