diff --git a/cmd/e2e/e2e.go b/cmd/e2e/e2e.go index c5e2edd0cd..5395eec739 100644 --- a/cmd/e2e/e2e.go +++ b/cmd/e2e/e2e.go @@ -51,7 +51,7 @@ func main() { util.InitFlags() goruntime.GOMAXPROCS(goruntime.NumCPU()) if *provider == "" { - glog.Error("e2e needs the have the --provider flag set") + glog.Info("The --provider flag is not set. Treating as a conformance test. Some tests may not be run.") os.Exit(1) } if *times <= 0 { diff --git a/hack/conformance-test.sh b/hack/conformance-test.sh new file mode 100755 index 0000000000..19dd370d81 --- /dev/null +++ b/hack/conformance-test.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Copyright 2015 Google Inc. 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. + +# The conformance test is provided to let users run an e2e test +# against an already-setup cluster for which there is no automated +# setup, teardown, and other cluster/... scripts. +# +# The user must export these environment variables: +# KUBE_MASTER_IP to the ip address of the master. +# AUTH_CONFIG to the argument of the "--auth_config=" flag. +# If certs required, set CERT_DIR. +# +# Example to test against a local vagrant cluster: +# declare -x AUTH_CONFIG="$HOME/.kubernetes_vagrant_auth" +# declare -x KUBE_MASTER_IP=10.245.1.2 +# hack/conformance-test.sh +if [[ -z "KUBE_MASTER_IP" ]]; then + echo "Must set KUBE_MASTER_IP before running conformance test." + exit 1 +fi +if [[ -z "AUTH_CONFIG" ]]; then + echo "Must set AUTH_CONFIG before running conformance test." + exit 1 +fi +hack/ginkgo-e2e.sh +exit $? diff --git a/hack/ginkgo-e2e.sh b/hack/ginkgo-e2e.sh index 53e29d6f0e..0f1b98298b 100755 --- a/hack/ginkgo-e2e.sh +++ b/hack/ginkgo-e2e.sh @@ -20,18 +20,7 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. -: ${KUBE_VERSION_ROOT:=${KUBE_ROOT}} -: ${KUBECTL:="${KUBE_VERSION_ROOT}/cluster/kubectl.sh"} -: ${KUBE_CONFIG_FILE:="config-test.sh"} - -export KUBECTL KUBE_CONFIG_FILE - -source "${KUBE_ROOT}/cluster/kube-env.sh" -source "${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh" - -prepare-e2e - -detect-master >/dev/null +# --- Find local test binaries. # Detect the OS name/arch so that we can find our binary case "$(uname -s)" in @@ -77,36 +66,71 @@ locations=( ) e2e=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 ) -if [[ "$KUBERNETES_PROVIDER" == "vagrant" ]]; then - # When we are using vagrant it has hard coded auth. We repeat that here so that - # we don't clobber auth that might be used for a publicly facing cluster. - auth_config=( - "--auth_config=$HOME/.kubernetes_vagrant_auth" - ) -elif [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then - # With GKE, our auth and certs are in gcloud's config directory. - detect-project &> /dev/null - cfg_dir="${GCLOUD_CONFIG_DIR}/${PROJECT}.${ZONE}.${CLUSTER_NAME}" - auth_config=( - "--auth_config=${cfg_dir}/kubernetes_auth" - "--cert_dir=${cfg_dir}" - ) -elif [[ "${KUBERNETES_PROVIDER}" == "gce" ]]; then - auth_config=( - "--kubeconfig=${HOME}/.kube/.kubeconfig" - ) -elif [[ "${KUBERNETES_PROVIDER}" == "aws" ]]; then - auth_config=( - "--auth_config=${HOME}/.kube/${INSTANCE_PREFIX}/kubernetes_auth" - ) -else - auth_config=() -fi +# --- Setup some env vars. -if [[ "$KUBERNETES_PROVIDER" == "libvirt-coreos" ]]; then - host="http://${KUBE_MASTER_IP-}:8080" +: ${KUBE_VERSION_ROOT:=${KUBE_ROOT}} +: ${KUBECTL:="${KUBE_VERSION_ROOT}/cluster/kubectl.sh"} +: ${KUBE_CONFIG_FILE:="config-test.sh"} + +export KUBECTL KUBE_CONFIG_FILE + +source "${KUBE_ROOT}/cluster/kube-env.sh" + +# ---- Do cloud-provider-specific setup +if [[ -z "$AUTH_CONFIG" ]]; then + echo "Setting up for KUBERNETES_PROVIDER=\"${KUBERNETES_PROVIDER}\"." + + source "${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh" + + prepare-e2e + + detect-master >/dev/null + + + if [[ "$KUBERNETES_PROVIDER" == "vagrant" ]]; then + # When we are using vagrant it has hard coded auth. We repeat that here so that + # we don't clobber auth that might be used for a publicly facing cluster. + auth_config=( + "--auth_config=$HOME/.kubernetes_vagrant_auth" + ) + elif [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then + # With GKE, our auth and certs are in gcloud's config directory. + detect-project &> /dev/null + cfg_dir="${GCLOUD_CONFIG_DIR}/${PROJECT}.${ZONE}.${CLUSTER_NAME}" + auth_config=( + "--auth_config=${cfg_dir}/kubernetes_auth" + "--cert_dir=${cfg_dir}" + ) + elif [[ "${KUBERNETES_PROVIDER}" == "gce" ]]; then + auth_config=( + "--kubeconfig=${HOME}/.kube/.kubeconfig" + ) + elif [[ "${KUBERNETES_PROVIDER}" == "aws" ]]; then + auth_config=( + "--auth_config=${HOME}/.kube/${INSTANCE_PREFIX}/kubernetes_auth" + ) + elif [[ "${KUBERNETES_PROVIDER}" == "conformance_test" ]]; then + auth_config=( + "--auth_config=${KUBERNETES_CONFORMANCE_TEST_AUTH_CONFIG:-}" + "--cert_dir=${KUBERNETES_CONFORMANCE_TEST_CERT_DIR:-}" + ) + else + auth_config=() + fi + + if [[ "$KUBERNETES_PROVIDER" == "libvirt-coreos" ]]; then + host="http://${KUBE_MASTER_IP-}:8080" + else + host="https://${KUBE_MASTER_IP-}" + fi else - host="https://${KUBE_MASTER_IP-}" + echo "Conformance Test. No cloud-provider-specific preparation." + KUBERNETES_PROVIDER="" + auth_config=( + "--auth_config=${AUTH_CONFIG:-}" + "--cert_dir=${CERT_DIR:-}" + ) + host="https://${KUBE_MASTER_IP-}" fi # Use the kubectl binary from the same directory as the e2e binary.