Skip to content

Commit

Permalink
Track floating deps at master (knative#932)
Browse files Browse the repository at this point in the history
* Track floating deps at master

* Update kn version command
  • Loading branch information
navidshaikh committed Jul 15, 2020
1 parent c255b32 commit 217a813
Show file tree
Hide file tree
Showing 414 changed files with 51,905 additions and 14,730 deletions.
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ go 1.14
require (
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v0.0.6
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.6.2
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073
github.com/spf13/viper v1.7.0
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
gotest.tools v2.2.0+incompatible
k8s.io/api v0.18.1
k8s.io/apimachinery v0.18.1
k8s.io/apimachinery v0.18.5
k8s.io/cli-runtime v0.17.6
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/code-generator v0.18.0
knative.dev/eventing v0.16.0
knative.dev/pkg v0.0.0-20200702222342-ea4d6e985ba0
knative.dev/serving v0.16.0
knative.dev/eventing v0.16.1-0.20200715062032-28f9f61e6131
knative.dev/pkg v0.0.0-20200714233132-cb1281d05cc8
knative.dev/serving v0.16.1-0.20200715073232-81d40bfc82a6
sigs.k8s.io/yaml v1.2.0
)

Expand Down
432 changes: 403 additions & 29 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hack/update-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -o pipefail

cd ${ROOT_DIR}

VERSION="release-16"
VERSION="master"

# The list of dependencies that we track at HEAD and periodically
# float forward in this repository.
Expand Down
6 changes: 3 additions & 3 deletions pkg/kn/commands/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ var GitRevision string
// update this var as we add more deps
var apiVersions = map[string][]string{
"serving": {
"serving.knative.dev/v1 (knative-serving v0.16.0)",
"serving.knative.dev/v1 (knative-serving v0.16.1-0.20200715073232-81d40bfc82a6)",
},
"eventing": {
"sources.knative.dev/v1alpha2 (knative-eventing v0.16.0)",
"eventing.knative.dev/v1beta1 (knative-eventing v0.16.0)",
"sources.knative.dev/v1alpha2 (knative-eventing v0.16.1-0.20200715062032-28f9f61e6131)",
"eventing.knative.dev/v1beta1 (knative-eventing v0.16.1-0.20200715062032-28f9f61e6131)",
},
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/test-infra/COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14ebc4a42974a95169fa9d65ccbb0b68661ae0ba
5a4c4cad53724b4e74412981008ae34252c2e086
14 changes: 5 additions & 9 deletions scripts/test-infra/dummy.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
/*
Copyright 2018 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
https://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.
*/

// Package scripts is a placeholder that allows us to pull the shell scripts
// via go mod vendor.
package scripts

import (
"fmt"
)

func main() {
fmt.Println("This is a dummy go file so `go dep` can be used with knative/test-infra/scripts")
fmt.Println("This file can be safely removed if one day this directory contains real, useful go code")
}
84 changes: 43 additions & 41 deletions scripts/test-infra/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# This is a helper script for Knative E2E test scripts.
# See README.md for instructions on how to use it.

source $(dirname ${BASH_SOURCE})/library.sh
source $(dirname "${BASH_SOURCE[0]}")/library.sh

# Build a resource name based on $E2E_BASE_NAME, a suffix and $BUILD_NUMBER.
# Restricts the name length to 40 chars (the limit for resource names in GCP).
Expand Down Expand Up @@ -82,7 +82,7 @@ function go_test_e2e() {
local test_options=""
local go_options=""
[[ ! " $@" == *" -tags="* ]] && go_options="-tags=e2e"
report_go_test -v -race -count=1 ${go_options} $@ ${test_options}
report_go_test -v -race -count=1 ${go_options} $@ "${test_options}"
}

# Dump info about the test cluster. If dump_extra_cluster_info() is defined, calls it too.
Expand All @@ -93,30 +93,32 @@ function dump_cluster_state() {
echo "*** Start of information dump ***"
echo "***************************************"

local output="${ARTIFACTS}/k8s.dump-$(basename ${E2E_SCRIPT}).txt"
local output="${ARTIFACTS}/k8s.dump-$(basename "${E2E_SCRIPT}").txt"
echo ">>> The dump is located at ${output}"

for crd in $(kubectl api-resources --verbs=list -o name | sort); do
local count="$(kubectl get $crd --all-namespaces --no-headers 2>/dev/null | wc -l)"
local count="$(kubectl get "$crd" --all-namespaces --no-headers 2>/dev/null | wc -l)"
echo ">>> ${crd} (${count} objects)"
if [[ "${count}" > "0" ]]; then
echo ">>> ${crd} (${count} objects)" >> ${output}
echo ">>> ${crd} (${count} objects)" >> "${output}"

echo ">>> Listing" >> ${output}
kubectl get ${crd} --all-namespaces >> ${output}
echo ">>> Listing" >> "${output}"
kubectl get "${crd}" --all-namespaces >> "${output}"

echo ">>> Details" >> ${output}
echo ">>> Details" >> "${output}"
if [[ "${crd}" == "secrets" ]]; then
echo "Secrets are ignored for security reasons" >> ${output}
elif [[ "${crd}" == "events" ]]; then
echo "events are ignored as making a lot of noise" >> ${output}
else
kubectl get ${crd} --all-namespaces -o yaml >> ${output}
kubectl get "${crd}" --all-namespaces -o yaml >> "${output}"
fi
fi
done

if function_exists dump_extra_cluster_state; then
echo ">>> Extra dump" >> ${output}
dump_extra_cluster_state >> ${output}
echo ">>> Extra dump" >> "${output}"
dump_extra_cluster_state >> "${output}"
fi
echo "***************************************"
echo "*** E2E TEST FAILED ***"
Expand All @@ -133,8 +135,8 @@ function save_metadata() {
geo_key="Zone"
geo_value="${E2E_CLUSTER_REGION}-${E2E_CLUSTER_ZONE}"
fi
local cluster_version="$(gcloud container clusters list --project=${E2E_PROJECT_ID} --format='value(currentMasterVersion)')"
cat << EOF > ${ARTIFACTS}/metadata.json
local cluster_version="$(gcloud container clusters list --project="${E2E_PROJECT_ID}" --format='value(currentMasterVersion)')"
cat << EOF > "${ARTIFACTS}"/metadata.json
{
"E2E:${geo_key}": "${geo_value}",
"E2E:Machine": "${E2E_CLUSTER_MACHINE}",
Expand All @@ -153,7 +155,7 @@ function resolve_k8s_version() {
if [[ "${target_version}" == "default" ]]; then
local version="$(gcloud container get-server-config \
--format='value(defaultClusterVersion)' \
--zone=$2)"
--zone="$2")"
[[ -z "${version}" ]] && return 1
E2E_CLUSTER_VERSION="${version}"
echo "Using default version, ${E2E_CLUSTER_VERSION}"
Expand All @@ -162,7 +164,7 @@ function resolve_k8s_version() {
# Fetch valid versions
local versions="$(gcloud container get-server-config \
--format='value(validMasterVersions)' \
--zone=$2)"
--zone="$2")"
[[ -z "${versions}" ]] && return 1
local gke_versions=($(echo -n "${versions//;/ }"))
echo "Available GKE versions in $2 are [${versions//;/, }]"
Expand All @@ -171,7 +173,7 @@ function resolve_k8s_version() {
E2E_CLUSTER_VERSION="${gke_versions[0]}"
echo "Using latest version, ${E2E_CLUSTER_VERSION}"
else
local latest="$(echo "${gke_versions[@]}" | tr ' ' '\n' | grep -E ^${target_version} | sort -V | tail -1)"
local latest="$(echo "${gke_versions[@]}" | tr ' ' '\n' | grep -E "^${target_version}" | sort -V | tail -1)"
if [[ -z "${latest}" ]]; then
echo "ERROR: version ${target_version} is not available"
return 1
Expand Down Expand Up @@ -213,9 +215,9 @@ function create_test_cluster() {
fi
# SSH keys are not used, but kubetest checks for their existence.
# Touch them so if they don't exist, empty files are create to satisfy the check.
mkdir -p $HOME/.ssh
touch $HOME/.ssh/google_compute_engine.pub
touch $HOME/.ssh/google_compute_engine
mkdir -p "$HOME"/.ssh
touch "$HOME"/.ssh/google_compute_engine.pub
touch "$HOME"/.ssh/google_compute_engine
# Assume test failed (see details in set_test_return_code()).
set_test_return_code 1
local gcloud_project="${GCP_PROJECT}"
Expand Down Expand Up @@ -244,13 +246,13 @@ function create_test_cluster() {
# TODO(adrcunha): Remove once https://github.com/kubernetes/test-infra/issues/13029 is fixed.
local kubedir="$(mktemp -d -t kubernetes.XXXXXXXXXX)"
local test_wrapper="${kubedir}/e2e-test.sh"
mkdir ${kubedir}/cluster
ln -s "$(which kubectl)" ${kubedir}/cluster/kubectl.sh
echo "#!/usr/bin/env bash" > ${test_wrapper}
echo "cd $(pwd) && set -x" >> ${test_wrapper}
echo "${E2E_SCRIPT} ${test_cmd_args}" >> ${test_wrapper}
chmod +x ${test_wrapper}
cd ${kubedir}
mkdir "${kubedir}"/cluster
ln -s "$(which kubectl)" "${kubedir}"/cluster/kubectl.sh
echo "#!/usr/bin/env bash" > "${test_wrapper}"
echo "cd $(pwd) && set -x" >> "${test_wrapper}"
echo "${E2E_SCRIPT} ${test_cmd_args}" >> "${test_wrapper}"
chmod +x "${test_wrapper}"
cd "${kubedir}"

# Create cluster and run the tests
create_test_cluster_with_retries "${CLUSTER_CREATION_ARGS[@]}" \
Expand All @@ -264,7 +266,7 @@ function create_test_cluster() {
local result=$(get_test_return_code)
echo "Artifacts were written to ${ARTIFACTS}"
echo "Test result code is ${result}"
exit ${result}
exit "${result}"
}

# Retry backup regions/zones if cluster creations failed due to stockout.
Expand Down Expand Up @@ -294,25 +296,25 @@ function create_test_cluster_with_retries() {
[[ "${E2E_CLUSTER_ZONE}" == "${zone_not_provided}" ]] && E2E_CLUSTER_ZONE=""
local cluster_creation_zone="${E2E_CLUSTER_REGION}"
[[ -n "${E2E_CLUSTER_ZONE}" ]] && cluster_creation_zone="${E2E_CLUSTER_REGION}-${E2E_CLUSTER_ZONE}"
resolve_k8s_version ${e2e_cluster_target_version} ${cluster_creation_zone} || return 1
resolve_k8s_version "${e2e_cluster_target_version}" "${cluster_creation_zone}" || return 1

header "Creating test cluster ${E2E_CLUSTER_VERSION} in ${cluster_creation_zone}"
# Don't fail test for kubetest, as it might incorrectly report test failure
# if teardown fails (for details, see success() below)
set +o errexit
export CLUSTER_API_VERSION=${E2E_CLUSTER_VERSION}
run_go_tool k8s.io/test-infra/kubetest \
kubetest "$@" --gcp-region=${cluster_creation_zone} 2>&1 | tee ${cluster_creation_log}
kubetest "$@" --gcp-region="${cluster_creation_zone}" 2>&1 | tee "${cluster_creation_log}"

# Exit if test succeeded
[[ "$(get_test_return_code)" == "0" ]] && return 0
# 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})" ]] \
[[ -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
Expand Down Expand Up @@ -343,23 +345,23 @@ function setup_test_cluster() {
local k8s_user=$(gcloud config get-value core/account)
local k8s_cluster=$(kubectl config current-context)

is_protected_cluster ${k8s_cluster} && \
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_CLUSTER_REGION} ${E2E_CLUSTER_ZONE}
acquire_cluster_admin_role "${k8s_user}" "${E2E_CLUSTER_NAME}" "${E2E_CLUSTER_REGION}" "${E2E_CLUSTER_ZONE}"
# Incorporate an element of randomness to ensure that each run properly publishes images.
export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${E2E_BASE_NAME}-e2e-img/${RANDOM}
fi

# Safety checks
is_protected_gcr ${KO_DOCKER_REPO} && \
is_protected_gcr "${KO_DOCKER_REPO}" && \
abort "\$KO_DOCKER_REPO set to ${KO_DOCKER_REPO}, which is forbidden"

# Use default namespace for all subsequent kubectl commands in this context
kubectl config set-context ${k8s_cluster} --namespace=default
kubectl config set-context "${k8s_cluster}" --namespace=default

echo "- gcloud project is ${E2E_PROJECT_ID}"
echo "- gcloud user is ${k8s_user}"
Expand Down Expand Up @@ -388,7 +390,7 @@ function setup_test_cluster() {
# Gets the exit of the test script.
# For more details, see set_test_return_code().
function get_test_return_code() {
echo $(cat ${TEST_RESULT_FILE})
echo $(cat "${TEST_RESULT_FILE}")
}

# Set the return code that the test script will return.
Expand All @@ -399,7 +401,7 @@ function set_test_return_code() {
# We store the real test result to return it later, ignoring any teardown
# failure in kubetest.
# TODO(adrcunha): Get rid of this workaround.
echo -n "$1"> ${TEST_RESULT_FILE}
echo -n "$1"> "${TEST_RESULT_FILE}"
}

# Signal (as return code and in the logs) that all E2E tests passed.
Expand Down Expand Up @@ -434,10 +436,10 @@ E2E_SCRIPT_CUSTOM_FLAGS=()

# Parse flags and initialize the test cluster.
function initialize() {
E2E_SCRIPT="$(get_canonical_path $0)"
E2E_SCRIPT="$(get_canonical_path "$0")"
E2E_CLUSTER_VERSION="${SERVING_GKE_VERSION}"

cd ${REPO_ROOT_DIR}
cd "${REPO_ROOT_DIR}"
while [[ $# -ne 0 ]]; do
local parameter=$1
# Try parsing flag as a custom one.
Expand Down
Loading

0 comments on commit 217a813

Please sign in to comment.