Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions test/e2e/e2e.go → test/client/setup.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
Copyright 2020 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
Expand All @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package e2e
package client

import (
"testing"
Expand All @@ -20,6 +20,7 @@ import (
// Apparently just importing it is enough. @_@ side effects @_@.
// https://github.com/kubernetes/client-go/issues/242
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"

pkgTest "knative.dev/pkg/test"
"knative.dev/serving-operator/test"
)
Expand Down
26 changes: 11 additions & 15 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/e2e-tests.sh
# Latest serving release. This is intentionally hardcoded for now, but
# will need the ability to test against the latest successful serving
# CI runs in the future.
readonly LATEST_SERVING_RELEASE_VERSION=0.6.0
readonly LATEST_SERVING_RELEASE_VERSION=$(git describe --match "v[0-9]*" --abbrev=0)
# Istio version we test with
readonly ISTIO_VERSION=1.1.3
readonly ISTIO_VERSION="1.4.2"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to determine this dynamically? the version should be in a file in third_party/?

Copy link
Copy Markdown
Author

@houshengbo houshengbo Feb 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.4-latest is taken as default, if this param is not set.
HOWEVER, the directory is not available under the path, https://raw.githubusercontent.com/knative/serving, but it is available under the source code folder.
It only happens to this 1.X-latest directory, not to others like 1.4.2.
I have to set a specific version here to access via https://raw.githubusercontent.com/knative/serving/\<version>

# Test without Istio mesh enabled
readonly ISTIO_MESH=0
# Namespace used for tests
Expand All @@ -43,23 +43,16 @@ function istio_yaml() {
local istio_mesh=$2
local suffix=""
if [[ $istio_mesh -eq 0 ]]; then
suffix="-lean"
suffix="ci-no-mesh"
else
suffix="ci-mesh"
fi
echo "third_party/istio-${istio_version}/istio${suffix}.yaml"
echo "third_party/istio-${istio_version}/istio-${suffix}.yaml"
}

# Install Istio.
function install_istio() {
local base_url="https://raw.githubusercontent.com/knative/serving/v${LATEST_SERVING_RELEASE_VERSION}"
# 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 using mesh.
ISTIO_MESH=1
fi
local base_url="https://raw.githubusercontent.com/knative/serving/${LATEST_SERVING_RELEASE_VERSION}"
INSTALL_ISTIO_CRD_YAML="${base_url}/$(istio_crds_yaml $ISTIO_VERSION)"
INSTALL_ISTIO_YAML="${base_url}/$(istio_yaml $ISTIO_VERSION $ISTIO_MESH)"

Expand All @@ -76,10 +69,13 @@ function install_istio() {
kubectl apply -f "${INSTALL_ISTIO_YAML}" || return 1
}

function install_serving_operator() {
function create_namespace() {
echo ">> Creating test namespaces"
# All the custom resources and Knative Serving resources are created under this TEST_NAMESPACE.
kubectl create namespace $TEST_NAMESPACE
}

function install_serving_operator() {
header "Installing Knative Serving operator"
# Deploy the operator
ko apply -f config/
Expand Down
1 change: 1 addition & 0 deletions test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ source $(dirname $0)/e2e-common.sh

function knative_setup() {
install_istio || fail_test "Istio installation failed"
create_namespace
install_serving_operator
}

Expand Down
49 changes: 46 additions & 3 deletions test/e2e-upgrade-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,47 @@ source $(dirname $0)/e2e-common.sh
OPERATOR_DIR=$(dirname $0)/..
KNATIVE_SERVING_DIR=${OPERATOR_DIR}/..

function knative_setup() {
function install_latest_operator_release() {
header "Installing Knative Serving operator latest public release"
local full_url="https://github.com/knative/serving-operator/releases/download/${LATEST_SERVING_RELEASE_VERSION}/serving-operator.yaml"

local release_yaml="$(mktemp)"
wget "${full_url}" -O "${release_yaml}" \
|| fail_test "Unable to download latest Knative Serving Operator release."

install_istio || fail_test "Istio installation failed"
kubectl apply -f "${release_yaml}" || fail_test "Knative Serving Operator latest release installation failed"
create_custom_resource
wait_until_pods_running ${TEST_NAMESPACE}
}

function create_custom_resource() {
echo ">> Creating the custom resource of Knative Serving:"
cat <<EOF | kubectl apply -f -
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
name: knative-serving
namespace: ${TEST_NAMESPACE}
spec:
config:
defaults:
revision-timeout-seconds: "300" # 5 minutes
autoscaler:
stable-window: "60s"
deployment:
registriesSkippingTagResolving: "ko.local,dev.local"
logging:
loglevel.controller: "debug"
EOF
}

function knative_setup() {
create_namespace
install_latest_operator_release
}

function install_head() {
generate_latest_serving_manifest
install_serving_operator
}
Expand Down Expand Up @@ -74,12 +113,16 @@ function generate_latest_serving_manifest() {
# Skip installing istio as an add-on
initialize $@ --skip-istio-addon

TIMEOUT=20m

install_head

# If we got this far, the operator installed Knative Serving of the latest source code.
header "Running tests for Knative Serving Operator"
failed=0

# Run the integration tests
go_test_e2e -timeout=20m ./test/e2e || failed=1
# Run the postupgrade tests
go_test_e2e -tags=postupgrade -timeout=${TIMEOUT} ./test/upgrade || failed=1

# Require that tests succeeded.
(( failed )) && fail_test
Expand Down
Loading