mirror of https://github.com/knative/docs.git
Update test-infra to the latest version (#1335)
This commit is contained in:
parent
e2865cee40
commit
5e5ed5aa77
|
@ -116,14 +116,14 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:f27efa11fb1aec3e502e2ed95d9a1211a93f8a791b7da0a06fdade0d98de5008"
|
||||
digest = "1:4587a5308bf116649bf0891017d6ac2053ff5953714efa59096a26ef7bc6db03"
|
||||
name = "github.com/knative/test-infra"
|
||||
packages = [
|
||||
"scripts",
|
||||
"tools/dep-collector",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "75f6ca1c4dc3b3ae5dc1a1a433753957a9340e83"
|
||||
revision = "e83cf0ab6b1d7ea37ff65d279f745284ae0c77b2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5985ef4caf91ece5d54817c11ea25f182697534f8ae6521eadcd628c142ac4b6"
|
||||
|
|
|
@ -172,7 +172,7 @@ This is a helper script for Knative E2E test scripts. To use it:
|
|||
will immediately start the tests against the cluster currently configured for
|
||||
`kubectl`.
|
||||
|
||||
1. By default Istio is installed on the cluster via Addon, using `--skip-istio` if
|
||||
1. By default Istio is installed on the cluster via Addon, use `--skip-istio-addon` if
|
||||
you choose not to have it preinstalled.
|
||||
|
||||
1. You can force running the tests against a specific GKE cluster version by using
|
||||
|
@ -228,7 +228,7 @@ This is a helper script for Knative release scripts. To use it:
|
|||
environment variable `VALIDATION_TESTS` to the executable to run.
|
||||
|
||||
1. Write logic for building the release in a function named `build_release()`.
|
||||
Set the environment variable `YAMLS_TO_PUBLISH` to the list of yaml files created,
|
||||
Set the environment variable `ARTIFACTS_TO_PUBLISH` to the list of files created,
|
||||
space separated. Use the following boolean (0 is false, 1 is true) and string
|
||||
environment variables for the logic:
|
||||
|
||||
|
@ -267,7 +267,7 @@ source vendor/github.com/knative/test-infra/scripts/release.sh
|
|||
function build_release() {
|
||||
# config/ contains the manifests
|
||||
ko resolve ${KO_FLAGS} -f config/ > release.yaml
|
||||
YAMLS_TO_PUBLISH="release.yaml"
|
||||
ARTIFACTS_TO_PUBLISH="release.yaml"
|
||||
}
|
||||
|
||||
main $@
|
||||
|
|
|
@ -189,6 +189,7 @@ function create_test_cluster() {
|
|||
local gcloud_project="${GCP_PROJECT}"
|
||||
[[ -z "${gcloud_project}" ]] && gcloud_project="$(gcloud config get-value project)"
|
||||
echo "gcloud project is ${gcloud_project}"
|
||||
echo "gcloud user is $(gcloud config get-value core/account)"
|
||||
(( IS_BOSKOS )) && echo "Using boskos for the test cluster"
|
||||
[[ -n "${GCP_PROJECT}" ]] && echo "GCP project for test cluster is ${GCP_PROJECT}"
|
||||
echo "Test script is ${E2E_SCRIPT}"
|
||||
|
@ -258,7 +259,7 @@ function create_test_cluster_with_retries() {
|
|||
# Exit if test succeeded
|
||||
[[ "$(get_test_return_code)" == "0" ]] && return
|
||||
# If test failed not because of cluster creation stockout, return
|
||||
[[ -z "$(grep -Eio 'does not have enough resources available to fulfill the request' ${cluster_creation_log})" ]] && return
|
||||
[[ -z "$(grep -Eio 'does not have enough resources available to fulfill' ${cluster_creation_log})" ]] && return
|
||||
done
|
||||
done
|
||||
}
|
||||
|
@ -349,7 +350,7 @@ function fail_test() {
|
|||
RUN_TESTS=0
|
||||
EMIT_METRICS=0
|
||||
SKIP_KNATIVE_SETUP=0
|
||||
SKIP_ISTIO=0
|
||||
SKIP_ISTIO_ADDON=0
|
||||
GCP_PROJECT=""
|
||||
E2E_SCRIPT=""
|
||||
E2E_CLUSTER_VERSION=""
|
||||
|
@ -385,7 +386,7 @@ function initialize() {
|
|||
--run-tests) RUN_TESTS=1 ;;
|
||||
--emit-metrics) EMIT_METRICS=1 ;;
|
||||
--skip-knative-setup) SKIP_KNATIVE_SETUP=1 ;;
|
||||
--skip-istio) SKIP_ISTIO=1 ;;
|
||||
--skip-istio-addon) SKIP_ISTIO_ADDON=1 ;;
|
||||
*)
|
||||
[[ $# -ge 2 ]] || abort "missing parameter after $1"
|
||||
shift
|
||||
|
@ -415,7 +416,7 @@ function initialize() {
|
|||
is_protected_gcr ${KO_DOCKER_REPO} && \
|
||||
abort "\$KO_DOCKER_REPO set to ${KO_DOCKER_REPO}, which is forbidden"
|
||||
|
||||
(( SKIP_ISTIO )) || GKE_ADDONS="--addons=Istio"
|
||||
(( SKIP_ISTIO_ADDON )) || GKE_ADDONS="--addons=Istio"
|
||||
|
||||
readonly RUN_TESTS
|
||||
readonly EMIT_METRICS
|
||||
|
|
|
@ -22,14 +22,6 @@
|
|||
readonly SERVING_GKE_VERSION=gke-latest
|
||||
readonly SERVING_GKE_IMAGE=cos
|
||||
|
||||
# Public latest stable nightly images and yaml files.
|
||||
readonly KNATIVE_BASE_YAML_SOURCE=https://storage.googleapis.com/knative-nightly/@/latest
|
||||
readonly KNATIVE_ISTIO_CRD_YAML=${KNATIVE_BASE_YAML_SOURCE/@/serving}/istio-crds.yaml
|
||||
readonly KNATIVE_ISTIO_YAML=${KNATIVE_BASE_YAML_SOURCE/@/serving}/istio.yaml
|
||||
readonly KNATIVE_SERVING_RELEASE=${KNATIVE_BASE_YAML_SOURCE/@/serving}/serving.yaml
|
||||
readonly KNATIVE_BUILD_RELEASE=${KNATIVE_BASE_YAML_SOURCE/@/build}/build.yaml
|
||||
readonly KNATIVE_EVENTING_RELEASE=${KNATIVE_BASE_YAML_SOURCE/@/eventing}/release.yaml
|
||||
|
||||
# Conveniently set GOPATH if unset
|
||||
if [[ -z "${GOPATH:-}" ]]; then
|
||||
export GOPATH="$(go env GOPATH)"
|
||||
|
@ -133,7 +125,7 @@ function wait_until_pods_running() {
|
|||
[[ ${status[0]} -lt 1 ]] && all_ready=0 && break
|
||||
[[ ${status[1]} -lt 1 ]] && all_ready=0 && break
|
||||
[[ ${status[0]} -ne ${status[1]} ]] && all_ready=0 && break
|
||||
done <<< $(echo "${pods}" | grep -v Completed)
|
||||
done <<< "$(echo "${pods}" | grep -v Completed)"
|
||||
if (( all_ready )); then
|
||||
echo -e "\nAll pods are up:\n${pods}"
|
||||
return 0
|
||||
|
@ -450,8 +442,32 @@ function get_canonical_path() {
|
|||
echo "$(cd ${path%/*} && echo $PWD/${path##*/})"
|
||||
}
|
||||
|
||||
# Return the base url we use to build the actual knative yaml sources.
|
||||
function get_knative_base_yaml_source() {
|
||||
local knative_base_yaml_source="https://storage.googleapis.com/knative-nightly/@/latest"
|
||||
# Get the branch name from Prow's env var by default, see https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md.
|
||||
local branch_name="${PULL_BASE_REF}"
|
||||
if (( ! IS_PROW )); then
|
||||
# If the test job is not running on Prow, we get the branch name directly via git command.
|
||||
branch_name="$(git rev-parse --abbrev-ref HEAD)"
|
||||
fi
|
||||
# If it's a release branch, we should have a different knative_base_yaml_source.
|
||||
if [[ $branch_name =~ ^release-[0-9\.]+$ ]]; then
|
||||
# Get the latest tag name for the current branch, which is likely formatted as v0.5.0
|
||||
local tag_name="$(git describe --tags --abbrev=0)"
|
||||
knative_base_yaml_source="https://storage.googleapis.com/knative-releases/@/previous/${tag_name}"
|
||||
fi
|
||||
echo "${knative_base_yaml_source}"
|
||||
}
|
||||
|
||||
# Initializations that depend on previous functions.
|
||||
# These MUST come last.
|
||||
|
||||
readonly _TEST_INFRA_SCRIPTS_DIR="$(dirname $(get_canonical_path ${BASH_SOURCE[0]}))"
|
||||
readonly REPO_NAME_FORMATTED="Knative $(capitalize ${REPO_NAME//-/})"
|
||||
|
||||
# Public latest nightly or release yaml files.
|
||||
readonly KNATIVE_BASE_YAML_SOURCE="$(get_knative_base_yaml_source)"
|
||||
readonly KNATIVE_SERVING_RELEASE="${KNATIVE_BASE_YAML_SOURCE/@/serving}/serving.yaml"
|
||||
readonly KNATIVE_BUILD_RELEASE="${KNATIVE_BASE_YAML_SOURCE/@/build}/build.yaml"
|
||||
readonly KNATIVE_EVENTING_RELEASE="${KNATIVE_BASE_YAML_SOURCE/@/eventing}/release.yaml"
|
||||
|
|
|
@ -37,14 +37,15 @@ function banner() {
|
|||
|
||||
# Tag images in the yaml files if $TAG is not empty.
|
||||
# $KO_DOCKER_REPO is the registry containing the images to tag with $TAG.
|
||||
# Parameters: $1..$n - yaml files to parse for images.
|
||||
# Parameters: $1..$n - files to parse for images (non .yaml files are ignored).
|
||||
function tag_images_in_yamls() {
|
||||
[[ -z ${TAG} ]] && return 0
|
||||
local SRC_DIR="${GOPATH}/src/"
|
||||
local DOCKER_BASE="${KO_DOCKER_REPO}/${REPO_ROOT_DIR/$SRC_DIR}"
|
||||
local GEO_REGIONS="${GEO_REPLICATION[@]} "
|
||||
echo "Tagging images under '${DOCKER_BASE}' with ${TAG}"
|
||||
echo "Tagging any images under '${DOCKER_BASE}' with ${TAG}"
|
||||
for file in $@; do
|
||||
[[ "${file##*.}" != "yaml" ]] && continue
|
||||
echo "Inspecting ${file}"
|
||||
for image in $(grep -o "${DOCKER_BASE}/[a-z\./-]\+@sha256:[0-9a-f]\+" ${file}); do
|
||||
for region in "" ${GEO_REGIONS// /. }; do
|
||||
|
@ -54,17 +55,17 @@ function tag_images_in_yamls() {
|
|||
done
|
||||
}
|
||||
|
||||
# Copy the given yaml files to the $RELEASE_GCS_BUCKET bucket's "latest" directory.
|
||||
# Copy the given files to the $RELEASE_GCS_BUCKET bucket's "latest" directory.
|
||||
# If $TAG is not empty, also copy them to $RELEASE_GCS_BUCKET bucket's "previous" directory.
|
||||
# Parameters: $1..$n - yaml files to copy.
|
||||
function publish_yamls() {
|
||||
# Parameters: $1..$n - files to copy.
|
||||
function publish_to_gcs() {
|
||||
function verbose_gsutil_cp {
|
||||
local DEST="gs://${RELEASE_GCS_BUCKET}/$1/"
|
||||
shift
|
||||
echo "Publishing [$@] to ${DEST}"
|
||||
gsutil -m cp $@ ${DEST}
|
||||
}
|
||||
# Before publishing the YAML files, cleanup the `latest` dir if it exists.
|
||||
# Before publishing the files, cleanup the `latest` dir if it exists.
|
||||
local latest_dir="gs://${RELEASE_GCS_BUCKET}/latest"
|
||||
if [[ -n "$(gsutil ls ${latest_dir} 2> /dev/null)" ]]; then
|
||||
echo "Cleaning up '${latest_dir}' first"
|
||||
|
@ -88,6 +89,7 @@ RELEASE_GCS_BUCKET=""
|
|||
KO_FLAGS=""
|
||||
VALIDATION_TESTS="./test/presubmit-tests.sh"
|
||||
YAMLS_TO_PUBLISH=""
|
||||
ARTIFACTS_TO_PUBLISH=""
|
||||
FROM_NIGHTLY_RELEASE=""
|
||||
FROM_NIGHTLY_RELEASE_GCS=""
|
||||
export KO_DOCKER_REPO=""
|
||||
|
@ -259,7 +261,7 @@ function build_from_nightly_release() {
|
|||
for yaml in ${yamls_dir}/*.yaml; do
|
||||
sed -i -e "s#${NIGHTLY_GCR}#${RELEASE_GCR}#" "${yaml}"
|
||||
done
|
||||
YAMLS_TO_PUBLISH="$(find ${yamls_dir} -name '*.yaml' -printf '%p ')"
|
||||
ARTIFACTS_TO_PUBLISH="$(find ${yamls_dir} -name '*.yaml' -printf '%p ')"
|
||||
echo "Copying nightly images"
|
||||
copy_nightly_images_to_release_gcr "${NIGHTLY_GCR}" "${FROM_NIGHTLY_RELEASE}"
|
||||
# Create a release branch from the nightly release tag.
|
||||
|
@ -461,6 +463,16 @@ function run_validation_tests() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Publishes the generated artifacts to GCS, GitHub, etc.
|
||||
# Parameters: $1..$n - files to add to the release.
|
||||
function publish_artifacts() {
|
||||
(( ! PUBLISH_RELEASE )) && return
|
||||
tag_images_in_yamls ${ARTIFACTS_TO_PUBLISH}
|
||||
publish_to_gcs ${ARTIFACTS_TO_PUBLISH}
|
||||
publish_to_github ${ARTIFACTS_TO_PUBLISH}
|
||||
banner "New release published successfully"
|
||||
}
|
||||
|
||||
# Entry point for a release script.
|
||||
function main() {
|
||||
function_exists build_release || abort "function 'build_release()' not defined"
|
||||
|
@ -509,22 +521,19 @@ function main() {
|
|||
else
|
||||
build_from_source
|
||||
fi
|
||||
[[ -z "${YAMLS_TO_PUBLISH}" ]] && abort "no manifests were generated"
|
||||
# Ensure no empty YAML file will be published.
|
||||
for yaml in ${YAMLS_TO_PUBLISH}; do
|
||||
[[ -s ${yaml} ]] || abort "YAML file ${yaml} is empty"
|
||||
# TODO(adrcunha): Remove once all repos use ARTIFACTS_TO_PUBLISH.
|
||||
[[ -z "${ARTIFACTS_TO_PUBLISH}" ]] && ARTIFACTS_TO_PUBLISH="${YAMLS_TO_PUBLISH}"
|
||||
[[ -z "${ARTIFACTS_TO_PUBLISH}" ]] && abort "no artifacts were generated"
|
||||
# Ensure no empty file will be published.
|
||||
for artifact in ${ARTIFACTS_TO_PUBLISH}; do
|
||||
[[ -s ${artifact} ]] || abort "Artifact ${artifact} is empty"
|
||||
done
|
||||
echo "New release built successfully"
|
||||
if (( PUBLISH_RELEASE )); then
|
||||
tag_images_in_yamls ${YAMLS_TO_PUBLISH}
|
||||
publish_yamls ${YAMLS_TO_PUBLISH}
|
||||
publish_to_github ${YAMLS_TO_PUBLISH}
|
||||
banner "New release published successfully"
|
||||
fi
|
||||
publish_artifacts
|
||||
}
|
||||
|
||||
# Publishes a new release on GitHub, also git tagging it (unless this is not a versioned release).
|
||||
# Parameters: $1..$n - YAML files to add to the release.
|
||||
# Parameters: $1..$n - files to add to the release.
|
||||
function publish_to_github() {
|
||||
(( PUBLISH_TO_GITHUB )) || return 0
|
||||
local title="${REPO_NAME_FORMATTED} release ${TAG}"
|
||||
|
@ -532,10 +541,10 @@ function publish_to_github() {
|
|||
local description="$(mktemp)"
|
||||
local attachments_dir="$(mktemp -d)"
|
||||
local commitish=""
|
||||
# Copy each YAML to a separate dir
|
||||
for yaml in $@; do
|
||||
cp ${yaml} ${attachments_dir}/
|
||||
attachments+=("--attach=${yaml}#$(basename ${yaml})")
|
||||
# Copy files to a separate dir
|
||||
for artifact in $@; do
|
||||
cp ${artifact} ${attachments_dir}/
|
||||
attachments+=("--attach=${artifact}#$(basename ${artifact})")
|
||||
done
|
||||
echo -e "${title}\n" > ${description}
|
||||
if [[ -n "${RELEASE_NOTES}" ]]; then
|
||||
|
|
Loading…
Reference in New Issue