Skip to content

Commit

Permalink
Add an E2E test to ensure standard Knative install works (knative#4244)
Browse files Browse the repository at this point in the history
* Add an E2E test to ensure standard Knative install works

* Update test/e2e-smoke-tests.sh

Co-Authored-By: mattmoor-sockpuppet <[email protected]>
  • Loading branch information
2 people authored and knative-prow-robot committed Jun 12, 2019
1 parent 3506a2e commit db1f6b6
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 93 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions hack/update-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sed -n '11,41p' vendor/bitbucket.org/ww/goautoneg/README.txt > vendor/bitbucket.

rm -rf $(find vendor/ -name 'OWNERS')
rm -rf $(find vendor/ -name '*_test.go')
rm -fr vendor/github.com/knative/test-infra/devstats

update_licenses third_party/VENDOR-LICENSE "./cmd/*"
remove_broken_symlinks ./vendor
73 changes: 24 additions & 49 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,10 @@ E2E_MAX_CLUSTER_NODES=${E2E_MAX_CLUSTER_NODES:-4}
# This script provides helper methods to perform cluster actions.
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/e2e-tests.sh

# Choose a correct istio-crds.yaml file.
# - $1 specifies Istio version.
function istio_crds_yaml() {
local istio_version="$1"
echo "./third_party/istio-${istio_version}/istio-crds.yaml"
}

# Choose a correct cert-manager.yaml file.
# - $1 specifies cert-manager version.
function cert_manager_yaml() {
local cert_manager_version="$1"
echo "./third_party/cert-manager-${cert_manager_version}/cert-manager.yaml"
}

# Choose a correct istio.yaml file.
# - $1 specifies Istio version.
# - $2 specifies whether we should use mesh.
function istio_yaml() {
local istio_version="$1"
local istio_mesh=$2
local suffix=""
if [[ $istio_mesh -eq 0 ]]; then
suffix="-lean"
fi
echo "./third_party/istio-${istio_version}/istio${suffix}.yaml"
}
# Default Istio configuration to install: 1.1-latest, no mesh, cert manager 0.6.1.
ISTIO_VERSION="1.1-latest"
ISTIO_MESH=0
CERT_MANAGER_VERSION="0.6.1"

# Current YAMLs used to install Knative Serving.
INSTALL_RELEASE_YAML=""
Expand Down Expand Up @@ -150,23 +128,10 @@ function install_knative_serving_standard() {
fi
fi

# Decide the Istio configuration to install.
if [[ -z "$ISTIO_VERSION" ]]; then
# Defaults to 1.1-latest
ISTIO_VERSION=1.1-latest
fi
if [[ -z "$ISTIO_MESH" ]]; then
# Defaults to not using sidecar.
ISTIO_MESH=0
fi
INSTALL_ISTIO_CRD_YAML="$(istio_crds_yaml $ISTIO_VERSION)"
INSTALL_ISTIO_YAML="$(istio_yaml $ISTIO_VERSION $ISTIO_MESH)"

if [[ -z "$CERT_MANAGER_VERSION" ]]; then
# Defaults to 0.6.1
CERT_MANAGER_VERSION=0.6.1
fi
INSTALL_CERT_MANAGER_YAML="$(cert_manager_yaml $CERT_MANAGER_VERSION)"
local istio_base="./third_party/istio-${ISTIO_VERSION}"
INSTALL_ISTIO_CRD_YAML="${istio_base}/istio-crds.yaml"
(( ISTIO_MESH )) && INSTALL_ISTIO_YAML="${istio_base}/istio.yaml" || INSTALL_ISTIO_YAML="${istio_base}/istio-lean.yaml"
INSTALL_CERT_MANAGER_YAML="./third_party/cert-manager-${CERT_MANAGER_VERSION}/cert-manager.yaml"

echo ">> Installing Knative serving"
echo "Istio CRD YAML: ${INSTALL_ISTIO_CRD_YAML}"
Expand Down Expand Up @@ -250,7 +215,7 @@ function knative_teardown() {
else
echo ">> Uninstalling Knative serving"
echo "Istio YAML: ${INSTALL_ISTIO_YAML}"
echo "Cert-Manager CRD YAML: ${INSTALL_CERT_MANAGER_CRD_YAML}"
echo "Cert-Manager YAML: ${INSTALL_CERT_MANAGER_YAML}"
echo "Knative YAML: ${INSTALL_RELEASE_YAML}"
echo ">> Bringing down Serving"
ko delete --ignore-not-found=true -f "${INSTALL_RELEASE_YAML}" || return 1
Expand All @@ -270,10 +235,6 @@ function knative_teardown() {
function test_setup() {
echo ">> Creating test resources (test/config/)"
ko apply -f test/config/ || return 1
echo ">> Creating test namespaces"
kubectl create namespace serving-tests
kubectl create namespace serving-tests-alt

${REPO_ROOT_DIR}/test/upload-test-images.sh || return 1
wait_until_pods_running knative-serving || return 1
wait_until_pods_running istio-system || return 1
Expand All @@ -287,9 +248,23 @@ function test_setup() {
function test_teardown() {
echo ">> Removing test resources (test/config/)"
ko delete --ignore-not-found=true --now -f test/config/
echo ">> Removing test namespaces"
echo ">> Ensuring test namespaces are clean"
kubectl delete all --all --ignore-not-found --now --timeout 60s -n serving-tests
kubectl delete --ignore-not-found --now --timeout 60s namespace serving-tests
kubectl delete all --all --ignore-not-found --now --timeout 60s -n serving-tests-alt
kubectl delete --ignore-not-found --now --timeout 60s namespace serving-tests-alt
}

# Dump more information when test fails.
function dump_extra_cluster_state() {
echo ">>> Routes:"
kubectl get routes -o yaml --all-namespaces
echo ">>> Configurations:"
kubectl get configurations -o yaml --all-namespaces
echo ">>> Revisions:"
kubectl get revisions -o yaml --all-namespaces

for app in controller webhook autoscaler activator; do
dump_app_logs ${app} knative-serving
done
}
52 changes: 52 additions & 0 deletions test/e2e-smoke-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

# Copyright 2019 The Knative Authors
#
# 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.

# This script runs the end-to-end tests against Knative Serving built from source.
# It is started by prow for each PR. For convenience, it can also be executed manually.

# If you already have a Knative cluster setup and kubectl pointing
# to it, call this script with the --run-tests arguments and it will use
# the cluster and run the tests.

# Calling this script without arguments will create a new cluster in
# project $PROJECT_ID, start knative in it, run the tests and delete the
# cluster.

source $(dirname $0)/e2e-common.sh

function knative_setup() {
# Build serving, create $SERVING_YAML
build_knative_from_source
start_knative_serving "${SERVING_YAML}"
}

# Script entry point.

initialize $@

# Ensure Knative Serving can be uninstalled/reinstalled cleanly
subheader "Uninstalling Knative Serving"
kubectl delete --ignore-not-found=true -f ${SERVING_YAML} || fail_test
wait_until_object_does_not_exist namespaces knative-serving || fail_test

subheader "Reinstalling Knative Serving"
start_knative_serving "${SERVING_YAML}" || fail_test

# Run smoke test
subheader "Running smoke test"
go_test_e2e ./test/e2e -run HelloWorld || fail_test

success
13 changes: 0 additions & 13 deletions test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@ source $(dirname $0)/e2e-common.sh

# Helper functions.

function dump_extra_cluster_state() {
echo ">>> Routes:"
kubectl get routes -o yaml --all-namespaces
echo ">>> Configurations:"
kubectl get configurations -o yaml --all-namespaces
echo ">>> Revisions:"
kubectl get revisions -o yaml --all-namespaces

for app in controller webhook autoscaler activator; do
dump_app_logs ${app} knative-serving
done
}

function knative_setup() {
install_knative_serving
}
Expand Down
28 changes: 20 additions & 8 deletions vendor/github.com/knative/test-infra/scripts/e2e-tests.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit db1f6b6

Please sign in to comment.