From 1e35260d923eac911164278dd0205a18f7c09663 Mon Sep 17 00:00:00 2001 From: Karl Isenberg Date: Mon, 14 Dec 2015 14:37:40 -0800 Subject: [PATCH 1/2] Backport contrib/mesos/ci to release-1.1 --- contrib/mesos/ci/build-release.sh | 38 ++++++++++++ contrib/mesos/ci/build.sh | 36 ++++++++++++ contrib/mesos/ci/run-with-cluster.sh | 86 ++++++++++++++++++++++++++++ contrib/mesos/ci/run.sh | 56 ++++++++++++++++++ contrib/mesos/ci/test-conformance.sh | 44 ++++++++++++++ contrib/mesos/ci/test-e2e.sh | 34 +++++++++++ contrib/mesos/ci/test-integration.sh | 34 +++++++++++ contrib/mesos/ci/test-smoke.sh | 34 +++++++++++ contrib/mesos/ci/test-unit.sh | 34 +++++++++++ 9 files changed, 396 insertions(+) create mode 100755 contrib/mesos/ci/build-release.sh create mode 100755 contrib/mesos/ci/build.sh create mode 100755 contrib/mesos/ci/run-with-cluster.sh create mode 100755 contrib/mesos/ci/run.sh create mode 100755 contrib/mesos/ci/test-conformance.sh create mode 100755 contrib/mesos/ci/test-e2e.sh create mode 100755 contrib/mesos/ci/test-integration.sh create mode 100755 contrib/mesos/ci/test-smoke.sh create mode 100755 contrib/mesos/ci/test-unit.sh diff --git a/contrib/mesos/ci/build-release.sh b/contrib/mesos/ci/build-release.sh new file mode 100755 index 000000000000..baa675f1a751 --- /dev/null +++ b/contrib/mesos/ci/build-release.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Cleans output files/images and builds a full release from scratch +# +# Prerequisite: +# ./cluster/mesos/docker/test/build.sh +# +# Example Usage: +# ./contrib/mesos/ci/build-release.sh + +set -o errexit +set -o nounset +set -o pipefail +set -o errtrace + +KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) + +"${KUBE_ROOT}/contrib/mesos/ci/run.sh" make clean + +export KUBERNETES_CONTRIB=mesos +export KUBE_RELEASE_RUN_TESTS="${KUBE_RELEASE_RUN_TESTS:-N}" +export KUBE_SKIP_CONFIRMATIONS=Y + +"${KUBE_ROOT}/build/release.sh" diff --git a/contrib/mesos/ci/build.sh b/contrib/mesos/ci/build.sh new file mode 100755 index 000000000000..1155a0b402dd --- /dev/null +++ b/contrib/mesos/ci/build.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Cleans output files/images and builds linux binaries from scratch +# +# Prerequisite: +# ./cluster/mesos/docker/test/build.sh +# +# Example Usage: +# ./contrib/mesos/ci/build.sh + +set -o errexit +set -o nounset +set -o pipefail +set -o errtrace + +TEST_ARGS="$@" + +KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) + +export KUBERNETES_CONTRIB=mesos + +"${KUBE_ROOT}/contrib/mesos/ci/run.sh" make clean all ${TEST_ARGS} diff --git a/contrib/mesos/ci/run-with-cluster.sh b/contrib/mesos/ci/run-with-cluster.sh new file mode 100755 index 000000000000..8b11e6f6975d --- /dev/null +++ b/contrib/mesos/ci/run-with-cluster.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Deploys a test cluster, runs the specified command, and destroys the test cluster. +# Runs all commands inside the mesosphere/kubernetes-mesos-test docker image (built on demand). +# Uses the mesos/docker cluster provider. +# +# Prerequisite: +# ./cluster/mesos/docker/test/build.sh +# +# Example Usage: +# ./contrib/mesos/ci/run-with-cluster.sh ./cluster/test-smoke.sh -v=2 + +set -o errexit +set -o nounset +set -o pipefail +set -o errtrace + +RUN_CMD="$@" +[ -z "${RUN_CMD:-}" ] && echo "No command supplied" && exit 1 + +KUBERNETES_PROVIDER="mesos/docker" + +MESOS_DOCKER_WORK_DIR="${MESOS_DOCKER_WORK_DIR:-${HOME}/tmp/kubernetes}" + +KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) + +# Clean (test artifacts) +echo "Cleaning work dir" +echo "${MESOS_DOCKER_WORK_DIR}" +rm -rf "${MESOS_DOCKER_WORK_DIR}" +mkdir -p "${MESOS_DOCKER_WORK_DIR}" + +echo "Detecting docker client" +# Mount docker client binary to avoid client/compose/daemon version conflicts +if [ -n "${DOCKER_MACHINE_NAME:-}" ] && which docker-machine; then + # On a Mac with docker-machine, use the binary in the VM, not the host binary + DOCKER_BIN_PATH="$(docker-machine ssh "${DOCKER_MACHINE_NAME}" which docker)" +else + DOCKER_BIN_PATH="$(which docker)" +fi +echo "${DOCKER_BIN_PATH}" + +# Clean (k8s output & images), Build, Kube-Up, Test, Kube-Down +cd "${KUBE_ROOT}" +exec docker run \ + --rm \ + -v "${KUBE_ROOT}:/go/src/github.com/GoogleCloudPlatform/kubernetes" \ + -v "/var/run/docker.sock:/var/run/docker.sock" \ + -v "${DOCKER_BIN_PATH}:/usr/bin/docker" \ + -v "${MESOS_DOCKER_WORK_DIR}/auth:${MESOS_DOCKER_WORK_DIR}/auth" \ + -v "${MESOS_DOCKER_WORK_DIR}/log:${MESOS_DOCKER_WORK_DIR}/log" \ + -v "${MESOS_DOCKER_WORK_DIR}/mesosslave1/mesos:${MESOS_DOCKER_WORK_DIR}/mesosslave1/mesos" \ + -v "${MESOS_DOCKER_WORK_DIR}/mesosslave2/mesos:${MESOS_DOCKER_WORK_DIR}/mesosslave2/mesos" \ + -v "${MESOS_DOCKER_WORK_DIR}/overlay:${MESOS_DOCKER_WORK_DIR}/overlay" \ + -v "${MESOS_DOCKER_WORK_DIR}/reports:${MESOS_DOCKER_WORK_DIR}/reports" \ + -e "MESOS_DOCKER_WORK_DIR=${MESOS_DOCKER_WORK_DIR}" \ + -e "MESOS_DOCKER_IMAGE_DIR=/var/tmp/kubernetes" \ + -e "MESOS_DOCKER_OVERLAY_DIR=${MESOS_DOCKER_WORK_DIR}/overlay" \ + -e "KUBERNETES_CONTRIB=mesos" \ + -e "KUBERNETES_PROVIDER=mesos/docker" \ + -e "USER=root" \ + -e "E2E_REPORT_DIR=${MESOS_DOCKER_WORK_DIR}/reports" \ + -t $(tty &>/dev/null && echo "-i") \ + mesosphere/kubernetes-mesos-test \ + -ceux "\ + make clean all && \ + trap 'timeout 5m ./cluster/kube-down.sh' EXIT && \ + ./cluster/kube-down.sh && \ + ./cluster/kube-up.sh && \ + trap \"test \\\$? != 0 && export MESOS_DOCKER_DUMP_LOGS=true; cd \${PWD} && timeout 5m ./cluster/kube-down.sh\" EXIT && \ + ${RUN_CMD} + " diff --git a/contrib/mesos/ci/run.sh b/contrib/mesos/ci/run.sh new file mode 100755 index 000000000000..9673d2848003 --- /dev/null +++ b/contrib/mesos/ci/run.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Runs the specified command in the test container (mesosphere/kubernetes-mesos-test). +# +# Prerequisite: +# ./cluster/mesos/docker/test/build.sh +# +# Example Usage: +# ./contrib/mesos/ci/run.sh make test + +set -o errexit +set -o nounset +set -o pipefail +set -o errtrace + +RUN_CMD="$@" +[ -z "${RUN_CMD:-}" ] && echo "No command supplied" && exit 1 + +KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) + +echo "Detecting docker client" +# Mount docker client binary to avoid client/compose/daemon version conflicts +if [ -n "${DOCKER_MACHINE_NAME:-}" ] && which docker-machine; then + # On a Mac with docker-machine, use the binary in the VM, not the host binary + DOCKER_BIN_PATH="$(docker-machine ssh "${DOCKER_MACHINE_NAME}" which docker)" +else + DOCKER_BIN_PATH="$(which docker)" +fi +echo "${DOCKER_BIN_PATH}" + +# Clean (k8s output & images) & Build +cd "${KUBE_ROOT}" +exec docker run \ + --rm \ + -v "${KUBE_ROOT}:/go/src/github.com/GoogleCloudPlatform/kubernetes" \ + -v "/var/run/docker.sock:/var/run/docker.sock" \ + -v "${DOCKER_BIN_PATH}:/usr/bin/docker" \ + -e "KUBERNETES_CONTRIB=mesos" \ + -e "USER=root" \ + -t $(tty &>/dev/null && echo "-i") \ + mesosphere/kubernetes-mesos-test \ + -ceux "${RUN_CMD}" diff --git a/contrib/mesos/ci/test-conformance.sh b/contrib/mesos/ci/test-conformance.sh new file mode 100755 index 000000000000..ff030c228533 --- /dev/null +++ b/contrib/mesos/ci/test-conformance.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Deploys a test cluster, runs the conformance tests, and destroys the test cluster. +# +# Prerequisite: +# ./cluster/mesos/docker/test/build.sh +# +# Example Usage: +# ./contrib/mesos/ci/test-conformance.sh -v=2 + +set -o errexit +set -o nounset +set -o pipefail +set -o errtrace + +TEST_ARGS="$@" + +KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) + +TEST_CMD="KUBECONFIG=~/.kube/config hack/conformance-test.sh" +if [ -n "${CONFORMANCE_BRANCH}" ]; then + # create a CONFORMANCE_BRANCH clone in a subdirectory + TEST_CMD=" +git fetch https://github.com/kubernetes/kubernetes --tags -q ${CONFORMANCE_BRANCH} && +git branch -f ${CONFORMANCE_BRANCH} FETCH_HEAD && +git clone -s -b ${CONFORMANCE_BRANCH} . conformance && +cd conformance && make all && ${TEST_CMD}" +fi + +"${KUBE_ROOT}/contrib/mesos/ci/run-with-cluster.sh" ${TEST_CMD} ${TEST_ARGS} diff --git a/contrib/mesos/ci/test-e2e.sh b/contrib/mesos/ci/test-e2e.sh new file mode 100755 index 000000000000..d796a8816ddf --- /dev/null +++ b/contrib/mesos/ci/test-e2e.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Deploys a test cluster, runs the e2e tests, and destroys the test cluster. +# +# Prerequisite: +# ./cluster/mesos/docker/test/build.sh +# +# Example Usage: +# ./contrib/mesos/ci/test-e2e.sh -v=2 + +set -o errexit +set -o nounset +set -o pipefail +set -o errtrace + +TEST_ARGS="$@" + +KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) + +"${KUBE_ROOT}/contrib/mesos/ci/run-with-cluster.sh" ./cluster/test-e2e.sh ${TEST_ARGS} \ No newline at end of file diff --git a/contrib/mesos/ci/test-integration.sh b/contrib/mesos/ci/test-integration.sh new file mode 100755 index 000000000000..f9beaf11460c --- /dev/null +++ b/contrib/mesos/ci/test-integration.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Cleans & runs the integration tests in the test container (mesosphere/kubernetes-mesos-test). +# +# Prerequisite: +# ./cluster/mesos/docker/test/build.sh +# +# Example Usage: +# ./contrib/mesos/ci/test-integration.sh + +set -o errexit +set -o nounset +set -o pipefail +set -o errtrace + +TEST_ARGS="$@" + +KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) + +"${KUBE_ROOT}/contrib/mesos/ci/run.sh" make clean test_integration ${TEST_ARGS} diff --git a/contrib/mesos/ci/test-smoke.sh b/contrib/mesos/ci/test-smoke.sh new file mode 100755 index 000000000000..79ba47390cea --- /dev/null +++ b/contrib/mesos/ci/test-smoke.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Deploys a test cluster, runs the smoke tests, and destroys the test cluster. +# +# Prerequisite: +# ./cluster/mesos/docker/test/build.sh +# +# Example Usage: +# ./contrib/mesos/ci/test-smoke.sh -v=2 + +set -o errexit +set -o nounset +set -o pipefail +set -o errtrace + +TEST_ARGS="$@" + +KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) + +"${KUBE_ROOT}/contrib/mesos/ci/run-with-cluster.sh" ./cluster/test-smoke.sh ${TEST_ARGS} \ No newline at end of file diff --git a/contrib/mesos/ci/test-unit.sh b/contrib/mesos/ci/test-unit.sh new file mode 100755 index 000000000000..943026bfb49d --- /dev/null +++ b/contrib/mesos/ci/test-unit.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Cleans & runs the unit tests in the test container (mesosphere/kubernetes-mesos-test). +# +# Prerequisite: +# ./cluster/mesos/docker/test/build.sh +# +# Example Usage: +# ./contrib/mesos/ci/test-unit.sh + +set -o errexit +set -o nounset +set -o pipefail +set -o errtrace + +TEST_ARGS="$@" + +KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) + +"${KUBE_ROOT}/contrib/mesos/ci/run.sh" make clean test ${TEST_ARGS} From ffa56551eec0358ec02ca7a080ef2f2f784bff9e Mon Sep 17 00:00:00 2001 From: Karl Isenberg Date: Mon, 14 Dec 2015 14:54:11 -0800 Subject: [PATCH 2/2] Backport smoke/conformance test script changes - Skip [Skipped] tests when testing for conformance #17180 - Add cluster/test-conformance.sh script #17997 - Support passing args to cluster/test-smoke.sh #15404 - Support annotated tags in conformance test version detection #17839 --- cluster/test-conformance.sh | 30 ++++++++++++++++++++++++++++++ cluster/test-smoke.sh | 4 +++- hack/conformance-test.sh | 6 +++--- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100755 cluster/test-conformance.sh diff --git a/cluster/test-conformance.sh b/cluster/test-conformance.sh new file mode 100755 index 000000000000..291a05b5b51c --- /dev/null +++ b/cluster/test-conformance.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Conformance Tests a running Kubernetes cluster. +# Validates that the cluster was deployed, is accessible, and at least +# satisfies end-to-end tests marked as being a part of the conformance suite. +# Emphasis on broad coverage and being non-destructive over thoroughness. + +set -o errexit +set -o nounset +set -o pipefail + +KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. + +TEST_ARGS="$@" + +exec "${KUBE_ROOT}/hack/conformance-test.sh" ${TEST_ARGS} diff --git a/cluster/test-smoke.sh b/cluster/test-smoke.sh index 85c9504c770c..2535bb3b20c0 100755 --- a/cluster/test-smoke.sh +++ b/cluster/test-smoke.sh @@ -25,6 +25,8 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. +TEST_ARGS="$@" + SMOKE_TEST_FOCUS_REGEX="Guestbook.application" -exec "${KUBE_ROOT}/cluster/test-e2e.sh" -ginkgo.focus="${SMOKE_TEST_FOCUS_REGEX}" +exec "${KUBE_ROOT}/cluster/test-e2e.sh" -ginkgo.focus="${SMOKE_TEST_FOCUS_REGEX}" ${TEST_ARGS} diff --git a/hack/conformance-test.sh b/hack/conformance-test.sh index 9786a1080f18..670ca65ae47d 100755 --- a/hack/conformance-test.sh +++ b/hack/conformance-test.sh @@ -61,6 +61,7 @@ # a new column for conformance at that new version, and notify # community. +TEST_ARGS="$@" : ${KUBECONFIG:?"Must set KUBECONFIG before running conformance test."} echo "Conformance test using current-context of ${KUBECONFIG}" @@ -70,7 +71,7 @@ echo -n "Conformance test SHA:" HEAD_SHA=$(git rev-parse HEAD) echo $HEAD_SHA echo "Conformance test version tag(s):" -git show-ref | grep $HEAD_SHA | grep refs/tags +git tag --points-at $HEAD_SHA echo echo "Conformance test checking conformance with Kubernetes version 1.0" @@ -83,5 +84,4 @@ echo "Conformance test checking conformance with Kubernetes version 1.0" declare -x KUBERNETES_CONFORMANCE_TEST="y" declare -x NUM_MINIONS=4 -hack/ginkgo-e2e.sh -ginkgo.focus='\[Conformance\]' -exit $? +exec hack/ginkgo-e2e.sh -ginkgo.focus='\[Conformance\]' -ginkgo.skip='\[Skipped\]' ${TEST_ARGS}