mirror of https://github.com/knative/docs.git
[master] Auto-update dependencies (#2745)
Produced via: `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh` /assign dprotaso grantr samodell /cc dprotaso grantr samodell
This commit is contained in:
parent
1ba98b3b61
commit
112e27a736
2
go.mod
2
go.mod
|
@ -19,7 +19,7 @@ require (
|
|||
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
|
||||
gopkg.in/go-playground/webhooks.v3 v3.13.0
|
||||
gopkg.in/yaml.v2 v2.3.0
|
||||
knative.dev/test-infra v0.0.0-20200826192206-b4adbd18e3fe
|
||||
knative.dev/test-infra v0.0.0-20200914203402-489e9e80675b
|
||||
)
|
||||
|
||||
replace go.opencensus.io => go.opencensus.io v0.20.2
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1849,8 +1849,8 @@ knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxP
|
|||
knative.dev/test-infra v0.0.0-20200513011557-d03429a76034/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
|
||||
knative.dev/test-infra v0.0.0-20200519015156-82551620b0a9/go.mod h1:A5b2OAXTOeHT3hHhVQm3dmtbuWvIDP7qzgtqxA3/2pE=
|
||||
knative.dev/test-infra v0.0.0-20200707183444-aed09e56ddc7/go.mod h1:RjYAhXnZqeHw9+B0zsbqSPlae0lCvjekO/nw5ZMpLCs=
|
||||
knative.dev/test-infra v0.0.0-20200826192206-b4adbd18e3fe h1:fHJNwbFZ6sWRC0NqIDlgLQOebMNOyCIPCT1uAs+YJNs=
|
||||
knative.dev/test-infra v0.0.0-20200826192206-b4adbd18e3fe/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc=
|
||||
knative.dev/test-infra v0.0.0-20200914203402-489e9e80675b h1:nA50WBTXgAcXmhb8iuupWJ1At8Ga1q9phE8juNc0wmI=
|
||||
knative.dev/test-infra v0.0.0-20200914203402-489e9e80675b/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc=
|
||||
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
|
||||
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
|
||||
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
|
||||
|
|
|
@ -110,28 +110,9 @@ main "$@"
|
|||
|
||||
This is a helper script for Knative E2E test scripts. To use it:
|
||||
|
||||
1. [optional] Customize the test cluster. Set the following environment
|
||||
variables if the default values don't fit your needs:
|
||||
|
||||
- `E2E_GCP_PROJECT_ID`: GCP project ID for creating the clusters, defaults to
|
||||
none.
|
||||
- `E2E_GKE_CLUSTER_REGION`: Cluster region, defaults to `us-central1`.
|
||||
- `E2E_GKE_CLUSTER_BACKUP_REGIONS`: Space-separated list of regions to retry
|
||||
test cluster creation in case of stockout. Defaults to `us-west1 us-east1`.
|
||||
- `E2E_GKE_CLUSTER_ZONE`: Cluster zone (e.g., `a`), defaults to none (i.e.
|
||||
use a regional cluster).
|
||||
- `E2E_GKE_CLUSTER_BACKUP_ZONES`: Space-separated list of zones to retry test
|
||||
cluster creation in case of stockout. If defined,
|
||||
`E2E_GKE_CLUSTER_BACKUP_REGIONS` will be ignored thus it defaults to none.
|
||||
- `E2E_GKE_CLUSTER_MACHINE`: Cluster node machine type, defaults to
|
||||
`e2-standard-4}`.
|
||||
- `E2E_MIN_CLUSTER_NODES`: Minimum number of nodes in the cluster when
|
||||
autoscaling, defaults to 1.
|
||||
- `E2E_MAX_CLUSTER_NODES`: Maximum number of nodes in the cluster when
|
||||
autoscaling, defaults to 3.
|
||||
- `E2E_GKE_SCOPES`: Scopes for the GKE node instances, defaults to
|
||||
`cloud-platform`.
|
||||
- `E2E_CLUSTER_VERSION`: Version for the cluster, defaults to `latest`.
|
||||
1. [optional] Customize the test cluster. Pass the flags as described
|
||||
[here](../kntest/pkg/kubetest2/gke/README.md) to the `initialize` function
|
||||
call if the default values don't fit your needs.
|
||||
|
||||
1. Source the script.
|
||||
|
||||
|
@ -163,7 +144,7 @@ This is a helper script for Knative E2E test scripts. To use it:
|
|||
of items to skip in the command line if the flag was parsed successfully. For
|
||||
example, return 1 for a simple flag, and 2 for a flag with a parameter.
|
||||
|
||||
1. Call the `initialize()` function passing `$@` (without quotes).
|
||||
1. Call the `initialize()` function passing `"$@"`.
|
||||
|
||||
1. Write logic for the end-to-end tests. Run all go tests using `go_test_e2e()`
|
||||
(or `report_go_test()` if you need a more fine-grained control) and call
|
||||
|
@ -173,8 +154,8 @@ This is a helper script for Knative E2E test scripts. To use it:
|
|||
|
||||
**Notes:**
|
||||
|
||||
1. Calling your script without arguments will create a new cluster in the GCP
|
||||
project `$E2E_GCP_PROJECT_ID` and run the tests against it.
|
||||
1. Calling your script without arguments will create a new cluster in your
|
||||
current GCP project and run the tests against it.
|
||||
|
||||
1. Calling your script with `--run-tests` and the variable `KO_DOCKER_REPO` set
|
||||
will immediately start the tests against the cluster currently configured for
|
||||
|
@ -195,9 +176,6 @@ test cluster is created in a specific region, `us-west2`.
|
|||
|
||||
```bash
|
||||
|
||||
# This test requires a cluster in LA
|
||||
E2E_CLUSTER_REGION=us-west2
|
||||
|
||||
source vendor/knative.dev/test-infra/scripts/e2e-tests.sh
|
||||
|
||||
function knative_setup() {
|
||||
|
@ -217,7 +195,8 @@ function parse_flags() {
|
|||
|
||||
WAIT_FOR_KNATIVE=1
|
||||
|
||||
initialize $@
|
||||
# This test requires a cluster in LA
|
||||
initialize $@ --region=us-west2
|
||||
|
||||
# TODO: use go_test_e2e to run the tests.
|
||||
kubectl get pods || fail_test
|
||||
|
|
|
@ -51,11 +51,8 @@ function setup_test_cluster() {
|
|||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
header "Test cluster setup"
|
||||
kubectl get nodes
|
||||
|
||||
header "Setting up test cluster"
|
||||
|
||||
kubectl get nodes
|
||||
# Set the actual project the test cluster resides in
|
||||
# It will be a project assigned by Boskos if test is running on Prow,
|
||||
# otherwise will be ${E2E_GCP_PROJECT_ID} set up by user.
|
||||
|
@ -63,21 +60,17 @@ function setup_test_cluster() {
|
|||
export E2E_PROJECT_ID
|
||||
readonly E2E_PROJECT_ID
|
||||
|
||||
local k8s_user
|
||||
k8s_user=$(gcloud config get-value core/account)
|
||||
local k8s_cluster
|
||||
k8s_cluster=$(kubectl config current-context)
|
||||
|
||||
is_protected_cluster "${k8s_cluster}" && \
|
||||
abort "kubeconfig context set to ${k8s_cluster}, which is forbidden"
|
||||
|
||||
# If cluster admin role isn't set, this is a brand new cluster
|
||||
# Setup the admin role and also KO_DOCKER_REPO if it is a GKE cluster
|
||||
if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" && "${k8s_cluster}" =~ ^gke_.* ]]; then
|
||||
acquire_cluster_admin_role "${k8s_user}" "${E2E_CLUSTER_NAME}" "${E2E_GKE_CLUSTER_REGION}" "${E2E_GKE_CLUSTER_ZONE}"
|
||||
# Incorporate an element of randomness to ensure that each run properly publishes images.
|
||||
export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${REPO_NAME}-e2e-img/${RANDOM}
|
||||
fi
|
||||
# Acquire cluster admin role for the current user.
|
||||
acquire_cluster_admin_role "${k8s_cluster}"
|
||||
|
||||
# Setup KO_DOCKER_REPO if it is a GKE cluster. Incorporate an element of randomness to ensure that each run properly publishes images.
|
||||
[[ "${k8s_cluster}" =~ ^gke_.* ]] && export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${REPO_NAME}-e2e-img/${RANDOM}
|
||||
|
||||
# Safety checks
|
||||
is_protected_gcr "${KO_DOCKER_REPO}" && \
|
||||
|
@ -92,7 +85,7 @@ function setup_test_cluster() {
|
|||
export KO_DATA_PATH="${REPO_ROOT_DIR}/.git"
|
||||
|
||||
# Do not run teardowns if we explicitly want to skip them.
|
||||
(( ! SKIP_TEARDOWNS )) && trap teardown_test_resources EXIT
|
||||
(( ! SKIP_TEARDOWNS )) && add_trap teardown_test_resources EXIT
|
||||
|
||||
# Handle failures ourselves, so we can dump useful info.
|
||||
set +o errexit
|
||||
|
@ -130,18 +123,19 @@ function fail_test() {
|
|||
SKIP_TEARDOWNS=0
|
||||
SKIP_ISTIO_ADDON=0
|
||||
E2E_SCRIPT=""
|
||||
CLOUD_PROVIDER="gke"
|
||||
|
||||
# Parse flags and initialize the test cluster.
|
||||
function initialize() {
|
||||
local run_tests=0
|
||||
local extra_kubetest2_flags=()
|
||||
local extra_cluster_creation_flags=()
|
||||
local custom_flags=()
|
||||
E2E_SCRIPT="$(get_canonical_path "$0")"
|
||||
local e2e_script_command=( "${E2E_SCRIPT}" "--run-tests" )
|
||||
|
||||
cd "${REPO_ROOT_DIR}"
|
||||
while [[ $# -ne 0 ]]; do
|
||||
local parameter=$1
|
||||
# TODO(chizhg): remove parse_flags logic if no repos are using it.
|
||||
# Try parsing flag as a custom one.
|
||||
if function_exists parse_flags; then
|
||||
parse_flags "$@"
|
||||
|
@ -163,12 +157,9 @@ function initialize() {
|
|||
# TODO(chizhg): remove this flag once the addons is defined as an env var.
|
||||
--skip-istio-addon) SKIP_ISTIO_ADDON=1 ;;
|
||||
*)
|
||||
[[ $# -ge 2 ]] || abort "missing parameter after $1"
|
||||
shift
|
||||
case ${parameter} in
|
||||
--kubetest2-flag) extra_kubetest2_flags+=("$1") ;;
|
||||
--cluster-creation-flag) extra_cluster_creation_flags+=("$1") ;;
|
||||
*) abort "unknown option ${parameter}" ;;
|
||||
--cloud-provider) shift; CLOUD_PROVIDER="$1" ;;
|
||||
*) custom_flags+=("$parameter") ;;
|
||||
esac
|
||||
esac
|
||||
shift
|
||||
|
@ -177,16 +168,16 @@ function initialize() {
|
|||
(( IS_PROW )) && [[ -z "${GCP_PROJECT_ID:-}" ]] && IS_BOSKOS=1
|
||||
|
||||
if (( SKIP_ISTIO_ADDON )); then
|
||||
extra_cluster_creation_flags+=("--addons=NodeLocalDNS")
|
||||
custom_flags+=("--addons=NodeLocalDNS")
|
||||
else
|
||||
extra_cluster_creation_flags+=("--addons=Istio,NodeLocalDNS")
|
||||
custom_flags+=("--addons=Istio,NodeLocalDNS")
|
||||
fi
|
||||
|
||||
readonly IS_BOSKOS
|
||||
readonly SKIP_TEARDOWNS
|
||||
|
||||
if (( ! run_tests )); then
|
||||
create_gke_test_cluster extra_kubetest2_flags extra_cluster_creation_flags e2e_script_command
|
||||
create_test_cluster "${CLOUD_PROVIDER}" custom_flags e2e_script_command
|
||||
else
|
||||
setup_test_cluster
|
||||
fi
|
||||
|
|
|
@ -19,34 +19,6 @@
|
|||
|
||||
source $(dirname "${BASH_SOURCE[0]}")/library.sh
|
||||
|
||||
# Test cluster parameters
|
||||
|
||||
# Configurable parameters
|
||||
export E2E_GCP_PROJECT_ID=${E2E_GCP_PROJECT_ID:-}
|
||||
# export E2E_GKE_CLUSTER_REGION and E2E_GKE_CLUSTER_ZONE as they're used in the cluster setup subprocess
|
||||
export E2E_GKE_CLUSTER_REGION=${E2E_GKE_CLUSTER_REGION:-us-central1}
|
||||
# By default we use regional clusters.
|
||||
export E2E_GKE_CLUSTER_ZONE=${E2E_GKE_CLUSTER_ZONE:-}
|
||||
|
||||
# Default backup regions in case of stockouts; by default we don't fall back to a different zone in the same region
|
||||
readonly E2E_GKE_CLUSTER_BACKUP_REGIONS=${E2E_GKE_CLUSTER_BACKUP_REGIONS:-us-west1 us-east1}
|
||||
readonly E2E_GKE_CLUSTER_BACKUP_ZONES=${E2E_GKE_CLUSTER_BACKUP_ZONES:-}
|
||||
|
||||
readonly E2E_GKE_ENVIRONMENT=${E2E_GKE_ENVIRONMENT:-prod}
|
||||
readonly E2E_GKE_COMMAND_GROUP=${E2E_GKE_COMMAND_GROUP:-beta}
|
||||
readonly E2E_GKE_CLUSTER_MACHINE=${E2E_GKE_CLUSTER_MACHINE:-e2-standard-4}
|
||||
readonly E2E_GKE_SCOPES=${E2E_GKE_SCOPES:-cloud-platform}
|
||||
|
||||
# Each knative repository may have a different cluster size requirement here,
|
||||
# so we allow calling code to set these parameters. If they are not set we
|
||||
# use some sane defaults.
|
||||
readonly E2E_MIN_CLUSTER_NODES=${E2E_MIN_CLUSTER_NODES:-1}
|
||||
readonly E2E_MAX_CLUSTER_NODES=${E2E_MAX_CLUSTER_NODES:-3}
|
||||
readonly E2E_CLUSTER_VERSION=${E2E_CLUSTER_VERSION:-latest}
|
||||
|
||||
readonly E2E_CLUSTER_NAME=$(build_resource_name e2e-cls)
|
||||
readonly E2E_GKE_NETWORK_NAME=$(build_resource_name e2e-net)
|
||||
|
||||
# Dumps the k8s api server metrics. Spins up a proxy, waits a little bit and
|
||||
# dumps the metrics to ${ARTIFACTS}/k8s.metrics.txt
|
||||
function dump_metrics() {
|
||||
|
@ -105,78 +77,39 @@ function dump_cluster_state() {
|
|||
echo "***************************************"
|
||||
}
|
||||
|
||||
# On a Prow job, save some metadata about the test for Testgrid.
|
||||
function save_metadata() {
|
||||
(( ! IS_PROW )) && return
|
||||
local geo_key="Region"
|
||||
local geo_value="${E2E_GKE_CLUSTER_REGION}"
|
||||
if [[ -n "${E2E_GKE_CLUSTER_ZONE}" ]]; then
|
||||
geo_key="Zone"
|
||||
geo_value="${E2E_GKE_CLUSTER_REGION}-${E2E_GKE_CLUSTER_ZONE}"
|
||||
# Sets the current user as cluster admin for the given cluster.
|
||||
# Parameters: $1 - cluster context name
|
||||
function acquire_cluster_admin_role() {
|
||||
if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" ]]; then
|
||||
if [[ "$1" =~ ^gke_.* ]]; then
|
||||
kubectl create clusterrolebinding cluster-admin-binding \
|
||||
--clusterrole=cluster-admin --user="$(gcloud config get-value core/account)"
|
||||
else
|
||||
kubectl create clusterrolebinding cluster-admin-binding-"${USER}" \
|
||||
--clusterrole=cluster-admin --user="${USER}"
|
||||
fi
|
||||
fi
|
||||
local cluster_version
|
||||
cluster_version="$(kubectl version --short=true)"
|
||||
run_kntest metadata set --key="E2E:${geo_key}" --value="${geo_value}"
|
||||
run_kntest metadata set --key="E2E:Machine" --value="${E2E_GKE_CLUSTER_MACHINE}"
|
||||
run_kntest metadata set --key="E2E:Version" --value="${cluster_version}"
|
||||
run_kntest metadata set --key="E2E:MinNodes" --value="${E2E_MIN_CLUSTER_NODES}"
|
||||
run_kntest metadata set --key="E2E:MaxNodes" --value="${E2E_MAX_CLUSTER_NODES}"
|
||||
}
|
||||
|
||||
# Create a GKE test cluster with kubetest2 and call the current script again.
|
||||
# Parameters: $1 - extra kubetest2 flags
|
||||
# $2 - extra cluster creation flags
|
||||
# $3 - test command to run by the kubetest2 tester
|
||||
function create_gke_test_cluster() {
|
||||
# Create a test cluster and run the tests if provided.
|
||||
# Parameters: $1 - cluster provider name, e.g. gke
|
||||
# $2 - custom flags supported by kntest
|
||||
# $3 - test command to run after cluster is created
|
||||
function create_test_cluster() {
|
||||
# Fail fast during setup.
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
local -n _extra_kubetest2_flags=$1
|
||||
local -n _extra_cluster_creation_flags=$2
|
||||
local -n _tester_command=$3
|
||||
|
||||
if function_exists cluster_setup; then
|
||||
cluster_setup || fail_test "cluster setup failed"
|
||||
fi
|
||||
|
||||
echo "Cluster will have a minimum of ${E2E_MIN_CLUSTER_NODES} and a maximum of ${E2E_MAX_CLUSTER_NODES} nodes."
|
||||
local _kubetest2_flags=(
|
||||
"gke"
|
||||
"--create-command=${E2E_GKE_COMMAND_GROUP} container clusters create --quiet --enable-autoscaling
|
||||
--min-nodes=${E2E_MIN_CLUSTER_NODES} --max-nodes=${E2E_MAX_CLUSTER_NODES}
|
||||
--cluster-version=${E2E_CLUSTER_VERSION}
|
||||
--scopes=${E2E_GKE_SCOPES} --enable-basic-auth --no-issue-client-certificate
|
||||
--no-enable-ip-alias --no-enable-autoupgrade
|
||||
${_extra_cluster_creation_flags[@]}"
|
||||
"--environment=${E2E_GKE_ENVIRONMENT}"
|
||||
"--cluster-name=${E2E_CLUSTER_NAME}"
|
||||
"--num-nodes=${E2E_MIN_CLUSTER_NODES}"
|
||||
"--machine-type=${E2E_GKE_CLUSTER_MACHINE}"
|
||||
"--network=${E2E_GKE_NETWORK_NAME}"
|
||||
"--ignore-gcp-ssh-key=true"
|
||||
--up
|
||||
)
|
||||
_kubetest2_flags+=( "${_extra_kubetest2_flags[@]}" )
|
||||
if (( ! IS_BOSKOS )); then
|
||||
local gcloud_project="${E2E_GCP_PROJECT_ID}"
|
||||
[[ -z "${gcloud_project}" ]] && gcloud_project="$(gcloud config get-value project)"
|
||||
_kubetest2_flags+=("--project=${gcloud_project}")
|
||||
echo "gcloud project is ${gcloud_project}"
|
||||
else
|
||||
echo "Using boskos for the test cluster"
|
||||
fi
|
||||
case "$1" in
|
||||
gke) create_gke_test_cluster "$2" "$3" "$4" ;;
|
||||
kind) create_kind_test_cluster "$2" "$3" "$4" ;;
|
||||
*) echo "unsupported provider: $1"; exit 1 ;;
|
||||
esac
|
||||
|
||||
if (( IS_BOSKOS )); then
|
||||
# Add arbitrary duration, wait for Boskos projects acquisition before error out
|
||||
_kubetest2_flags+=("--boskos-acquire-timeout-seconds=1200")
|
||||
elif (( ! SKIP_TEARDOWNS )); then
|
||||
# Only let kubetest2 tear down the cluster if not using Boskos and teardowns are not expected to be skipped,
|
||||
# it's done by Janitor if using Boskos
|
||||
_kubetest2_flags+=("--down")
|
||||
fi
|
||||
|
||||
# Create cluster and run the tests
|
||||
create_gke_test_cluster_with_retries _kubetest2_flags _tester_command
|
||||
local result="$?"
|
||||
# Ignore any errors below, this is a best-effort cleanup and shouldn't affect the test result.
|
||||
set +o errexit
|
||||
|
@ -187,56 +120,20 @@ function create_gke_test_cluster() {
|
|||
exit "${result}"
|
||||
}
|
||||
|
||||
# TODO(chizhg): move this to kubetest2 gke deployer.
|
||||
# Retry backup regions/zones if cluster creations failed due to stockout.
|
||||
# Parameters: $1 - kubetest2 flags other than geo flag
|
||||
# Create a KIND test cluster with kubetest2 and run the test command.
|
||||
# Parameters: $1 - extra cluster creation flags
|
||||
# $2 - test command to run by the kubetest2 tester
|
||||
function create_gke_test_cluster_with_retries() {
|
||||
local -n kubetest2_flags=$1
|
||||
local -n tester_command=$2
|
||||
local cluster_creation_log=/tmp/${REPO_NAME}-cluster_creation-log
|
||||
# zone_not_provided is a placeholder for e2e_cluster_zone to make for loop below work
|
||||
local zone_not_provided="zone_not_provided"
|
||||
|
||||
local e2e_cluster_regions=("${E2E_GKE_CLUSTER_REGION}")
|
||||
local e2e_cluster_zones=("${E2E_GKE_CLUSTER_ZONE}")
|
||||
|
||||
if [[ -n "${E2E_GKE_CLUSTER_BACKUP_ZONES}" ]]; then
|
||||
e2e_cluster_zones+=("${E2E_GKE_CLUSTER_BACKUP_ZONES}")
|
||||
elif [[ -n "${E2E_GKE_CLUSTER_BACKUP_REGIONS}" ]]; then
|
||||
e2e_cluster_regions+=("${E2E_GKE_CLUSTER_BACKUP_REGIONS}")
|
||||
e2e_cluster_zones=("${zone_not_provided}")
|
||||
else
|
||||
echo "No backup region/zone set, cluster creation will fail in case of stockout"
|
||||
fi
|
||||
|
||||
for e2e_cluster_region in "${e2e_cluster_regions[@]}"; do
|
||||
for e2e_cluster_zone in "${e2e_cluster_zones[@]}"; do
|
||||
E2E_GKE_CLUSTER_REGION=${e2e_cluster_region}
|
||||
E2E_GKE_CLUSTER_ZONE=${e2e_cluster_zone}
|
||||
[[ "${E2E_GKE_CLUSTER_ZONE}" == "${zone_not_provided}" ]] && E2E_GKE_CLUSTER_ZONE=""
|
||||
local cluster_creation_zone="${E2E_GKE_CLUSTER_REGION}"
|
||||
[[ -n "${E2E_GKE_CLUSTER_ZONE}" ]] && cluster_creation_zone="${E2E_GKE_CLUSTER_REGION}-${E2E_GKE_CLUSTER_ZONE}"
|
||||
|
||||
header "Creating test cluster ${E2E_CLUSTER_VERSION} in ${cluster_creation_zone}"
|
||||
if run_go_tool k8s-sigs.io/kubetest2 \
|
||||
kubetest2 "${kubetest2_flags[@]}" --region="${cluster_creation_zone}" \
|
||||
--test=exec -- "${tester_command[@]}" 2>&1 \
|
||||
| tee "${cluster_creation_log}"; then
|
||||
# Save some metadata about cluster creation for using in prow and testgrid
|
||||
save_metadata
|
||||
return 0
|
||||
fi
|
||||
# Retry if cluster creation failed because of:
|
||||
# - stockout (https://github.com/knative/test-infra/issues/592)
|
||||
# - latest GKE not available in this region/zone yet (https://github.com/knative/test-infra/issues/694)
|
||||
[[ -z "$(grep -Fo 'does not have enough resources available to fulfill' "${cluster_creation_log}")" \
|
||||
&& -z "$(grep -Fo 'ResponseError: code=400, message=No valid versions with the prefix' "${cluster_creation_log}")" \
|
||||
&& -z "$(grep -Po 'ResponseError: code=400, message=Master version "[0-9a-z\-\.]+" is unsupported' "${cluster_creation_log}")" \
|
||||
&& -z "$(grep -Po 'only \d+ nodes out of \d+ have registered; this is likely due to Nodes failing to start correctly' "${cluster_creation_log}")" ]] \
|
||||
&& return 1
|
||||
done
|
||||
done
|
||||
echo "No more region/zones to try, quitting"
|
||||
return 1
|
||||
function create_kind_test_cluster() {
|
||||
# TODO(chizhg): implement with kubetest2
|
||||
return 0
|
||||
}
|
||||
|
||||
# Create a GKE test cluster with kubetest2 and run the test command.
|
||||
# Parameters: $1 - custom flags defined in kntest
|
||||
# $2 - test command to run after the cluster is created (optional)
|
||||
function create_gke_test_cluster() {
|
||||
local -n _custom_flags=$1
|
||||
local -n _test_command=$2
|
||||
|
||||
run_kntest kubetest2 gke "${_custom_flags[@]}" --test-command="${_test_command[*]}"
|
||||
}
|
||||
|
|
|
@ -65,22 +65,6 @@ function abort() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
# Build a resource name based on $REPO_NAME, a suffix and $BUILD_NUMBER.
|
||||
# Restricts the name length to 40 chars (the limit for resource names in GCP).
|
||||
# Name will have the form $REPO_NAME-<PREFIX>$BUILD_NUMBER.
|
||||
# Parameters: $1 - name suffix
|
||||
function build_resource_name() {
|
||||
local prefix=${REPO_NAME}-$1
|
||||
local suffix=${BUILD_NUMBER}
|
||||
# Restrict suffix length to 20 chars
|
||||
if [[ -n "${suffix}" ]]; then
|
||||
suffix=${suffix:${#suffix}<20?0:-20}
|
||||
fi
|
||||
local name="${prefix:0:20}${suffix}"
|
||||
# Ensure name doesn't end with "-"
|
||||
echo "${name%-}"
|
||||
}
|
||||
|
||||
# Display a box banner.
|
||||
# Parameters: $1 - character to use for the box.
|
||||
# $2 - banner message.
|
||||
|
@ -327,44 +311,6 @@ function dump_app_logs() {
|
|||
done
|
||||
}
|
||||
|
||||
# Sets the given user as cluster admin.
|
||||
# Parameters: $1 - user
|
||||
# $2 - cluster name
|
||||
# $3 - cluster region
|
||||
# $4 - cluster zone, optional
|
||||
function acquire_cluster_admin_role() {
|
||||
echo "Acquiring cluster-admin role for user '$1'"
|
||||
local geoflag="--region=$3"
|
||||
[[ -n $4 ]] && geoflag="--zone=$3-$4"
|
||||
# Get the password of the admin and use it, as the service account (or the user)
|
||||
# might not have the necessary permission.
|
||||
local password=$(gcloud --format="value(masterAuth.password)" \
|
||||
container clusters describe $2 ${geoflag})
|
||||
if [[ -n "${password}" ]]; then
|
||||
# Cluster created with basic authentication
|
||||
kubectl config set-credentials cluster-admin \
|
||||
--username=admin --password=${password}
|
||||
else
|
||||
local cert=$(mktemp)
|
||||
local key=$(mktemp)
|
||||
echo "Certificate in ${cert}, key in ${key}"
|
||||
gcloud --format="value(masterAuth.clientCertificate)" \
|
||||
container clusters describe $2 ${geoflag} | base64 --decode > ${cert}
|
||||
gcloud --format="value(masterAuth.clientKey)" \
|
||||
container clusters describe $2 ${geoflag} | base64 --decode > ${key}
|
||||
kubectl config set-credentials cluster-admin \
|
||||
--client-certificate=${cert} --client-key=${key}
|
||||
fi
|
||||
kubectl config set-context $(kubectl config current-context) \
|
||||
--user=cluster-admin
|
||||
kubectl create clusterrolebinding cluster-admin-binding \
|
||||
--clusterrole=cluster-admin \
|
||||
--user=$1
|
||||
# Reset back to the default account
|
||||
gcloud container clusters get-credentials \
|
||||
$2 ${geoflag} --project $(gcloud config get-value project)
|
||||
}
|
||||
|
||||
# Run a command through tee and capture its output.
|
||||
# Parameters: $1 - file where the output will be stored.
|
||||
# $2... - command to run.
|
||||
|
|
|
@ -272,7 +272,7 @@ function run_integration_tests() {
|
|||
# Default integration test runner that runs all `test/e2e-*tests.sh`.
|
||||
function default_integration_test_runner() {
|
||||
local failed=0
|
||||
find test/ ! -name "$(printf "*\n*")" -name "e2e-*tests.sh" > tmp
|
||||
find test/ ! -name "$(printf "*\n*")" -name "e2e-*tests.sh" -maxdepth 1 > tmp
|
||||
while IFS= read -r e2e_test
|
||||
do
|
||||
echo "Running integration test ${e2e_test}"
|
||||
|
|
|
@ -298,7 +298,7 @@ gopkg.in/go-playground/webhooks.v3/github
|
|||
# gopkg.in/yaml.v2 v2.3.0
|
||||
## explicit
|
||||
gopkg.in/yaml.v2
|
||||
# knative.dev/test-infra v0.0.0-20200826192206-b4adbd18e3fe
|
||||
# knative.dev/test-infra v0.0.0-20200914203402-489e9e80675b
|
||||
## explicit
|
||||
knative.dev/test-infra/scripts
|
||||
# go.opencensus.io => go.opencensus.io v0.20.2
|
||||
|
|
Loading…
Reference in New Issue