Skip to content

Commit

Permalink
Use knative.dev/test-infra (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaodaiG authored and knative-prow-robot committed Jul 31, 2019
1 parent 71c39e8 commit 9f203f2
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 91 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/knative/build v0.7.0 // indirect
github.com/knative/pkg v0.0.0-20190617142447-13b093adc272
github.com/knative/serving v0.6.0
github.com/knative/test-infra v0.0.0-20190702025031-91d37e4abc30
github.com/knative/test-infra v0.0.0-20190702025031-91d37e4abc30 // indirect
github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/modern-go/reflect2 v1.0.1 // indirect
Expand All @@ -39,5 +39,6 @@ require (
k8s.io/cli-runtime v0.0.0-20190325194458-f2b4781c3ae1
k8s.io/client-go v0.0.0-20190226174127-78295b709ec6
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 // indirect
knative.dev/test-infra v0.0.0-20190730202142-17f2331e80ad
sigs.k8s.io/yaml v1.1.0
)
33 changes: 18 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,6 @@ github.com/knative/serving v0.5.2 h1:jsmeIN7B6oDHrK0jmtFRf7hWWr+KrjXVHuArK8jo5Nw
github.com/knative/serving v0.5.2/go.mod h1:ljvMfwQy2qanaM/8xnBSK4Mz3Vv2NawC2fo5kFRJS1A=
github.com/knative/serving v0.6.0 h1:2SOr1jAvrUPO1y0mJvpiTe3bJTSMd2tKXflmHCM0MAA=
github.com/knative/serving v0.6.0/go.mod h1:ljvMfwQy2qanaM/8xnBSK4Mz3Vv2NawC2fo5kFRJS1A=
github.com/knative/test-infra v0.0.0-20190404172656-4ce16d390c55 h1:2tpTEN6OydMWVmkKJC3iVNrYbA+iHNL9qjLXe7hocfE=
github.com/knative/test-infra v0.0.0-20190404172656-4ce16d390c55/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
github.com/knative/test-infra v0.0.0-20190509163238-a721698dbe49 h1:TEv7xkUjVofC2lqiSNeYjOYhC3XosGAfr0HG8x/lpC0=
github.com/knative/test-infra v0.0.0-20190509163238-a721698dbe49/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
github.com/knative/test-infra v0.0.0-20190516041915-e83cf0ab6b1d h1:o0QEmZJb46wFefSHgM8k3JtINpAH/KN5oe2bsFkDVOI=
github.com/knative/test-infra v0.0.0-20190516041915-e83cf0ab6b1d/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
github.com/knative/test-infra v0.0.0-20190517181617-d1bb39bbca6e h1:Is4Ki1oQhYD3Twfdzpk2U/vI/5hSPh9277bI1AK+28o=
github.com/knative/test-infra v0.0.0-20190517181617-d1bb39bbca6e/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
github.com/knative/test-infra v0.0.0-20190529123930-7d0c44fb03a9 h1:2kupVzyk+zet/S5bHMAQLxt1rQzqTsJd+vUXp7tIYcI=
github.com/knative/test-infra v0.0.0-20190529123930-7d0c44fb03a9/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
github.com/knative/test-infra v0.0.0-20190531180034-a3c073a2fea1 h1:Y2QunZIzGuyvBNfWNpwK9/AAgu2P+Aa+k/3ykATGw30=
github.com/knative/test-infra v0.0.0-20190531180034-a3c073a2fea1/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
github.com/knative/test-infra v0.0.0-20190624052103-517330119155 h1:ceTQvUNU19Vc13TlSNo6u0F0pHak9wcGJQ+gv0X4KlE=
github.com/knative/test-infra v0.0.0-20190624052103-517330119155/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
github.com/knative/test-infra v0.0.0-20190702025031-91d37e4abc30 h1:giPqryO6DJHa/b4eHxhOOcr2KiEs3g6k6IVsPTMdKZM=
github.com/knative/test-infra v0.0.0-20190702025031-91d37e4abc30/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
Expand Down Expand Up @@ -404,6 +389,24 @@ k8s.io/kube-openapi v0.0.0-20190510232812-a01b7d5d6c22 h1:f0BTap/vrgs21vVbJ1ySds
k8s.io/kube-openapi v0.0.0-20190510232812-a01b7d5d6c22/go.mod h1:iU+ZGYsNlvU9XKUSso6SQfKTCCw7lFduMZy26Mgr2Fw=
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 h1:5sW+fEHvlJI3Ngolx30CmubFulwH28DhKjGf70Xmtco=
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208/go.mod h1:nfDlWeOsu3pUf4yWGL+ERqohP4YsZcBJXWMK+gkzOA4=
knative.dev/test-infra v0.0.0-20190404172656-4ce16d390c55 h1:2tpTEN6OydMWVmkKJC3iVNrYbA+iHNL9qjLXe7hocfE=
knative.dev/test-infra v0.0.0-20190404172656-4ce16d390c55/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
knative.dev/test-infra v0.0.0-20190509163238-a721698dbe49 h1:TEv7xkUjVofC2lqiSNeYjOYhC3XosGAfr0HG8x/lpC0=
knative.dev/test-infra v0.0.0-20190509163238-a721698dbe49/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
knative.dev/test-infra v0.0.0-20190516041915-e83cf0ab6b1d h1:o0QEmZJb46wFefSHgM8k3JtINpAH/KN5oe2bsFkDVOI=
knative.dev/test-infra v0.0.0-20190516041915-e83cf0ab6b1d/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
knative.dev/test-infra v0.0.0-20190517181617-d1bb39bbca6e h1:Is4Ki1oQhYD3Twfdzpk2U/vI/5hSPh9277bI1AK+28o=
knative.dev/test-infra v0.0.0-20190517181617-d1bb39bbca6e/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
knative.dev/test-infra v0.0.0-20190529123930-7d0c44fb03a9 h1:2kupVzyk+zet/S5bHMAQLxt1rQzqTsJd+vUXp7tIYcI=
knative.dev/test-infra v0.0.0-20190529123930-7d0c44fb03a9/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
knative.dev/test-infra v0.0.0-20190531180034-a3c073a2fea1 h1:Y2QunZIzGuyvBNfWNpwK9/AAgu2P+Aa+k/3ykATGw30=
knative.dev/test-infra v0.0.0-20190531180034-a3c073a2fea1/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
knative.dev/test-infra v0.0.0-20190624052103-517330119155 h1:ceTQvUNU19Vc13TlSNo6u0F0pHak9wcGJQ+gv0X4KlE=
knative.dev/test-infra v0.0.0-20190624052103-517330119155/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
knative.dev/test-infra v0.0.0-20190702025031-91d37e4abc30 h1:giPqryO6DJHa/b4eHxhOOcr2KiEs3g6k6IVsPTMdKZM=
knative.dev/test-infra v0.0.0-20190702025031-91d37e4abc30/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
knative.dev/test-infra v0.0.0-20190730202142-17f2331e80ad h1:pXN0DA06tXwn4vgzIqJ13rf4U412rS+fRRww1JWJ+o4=
knative.dev/test-infra v0.0.0-20190730202142-17f2331e80ad/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
sigs.k8s.io/structured-merge-diff v0.0.0-20181214233322-d43a45b8663b/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
sigs.k8s.io/structured-merge-diff v0.0.0-20190426204423-ea680f03cc65/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
Expand Down
2 changes: 1 addition & 1 deletion hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Documentation about this script and how to use it can be found
# at https://github.com/knative/test-infra/tree/master/ci

source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/release.sh
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/release.sh
source $(dirname $0)/build-flags.sh

function build_release() {
Expand Down
2 changes: 1 addition & 1 deletion hack/verify-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -o errexit
set -o nounset
set -o pipefail

source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/library.sh
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/library.sh

# Needed later
go install golang.org/x/tools/cmd/goimports
Expand Down
2 changes: 1 addition & 1 deletion pkg/dummy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package pkg
import (
"testing"

_ "github.com/knative/test-infra/scripts"
_ "knative.dev/test-infra/scripts"
)

func TestDummy(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e-smoke-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# project $PROJECT_ID, start Knative serving, run the tests and delete
# the cluster.

source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/e2e-tests.sh
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/e2e-tests.sh

# Helper functions.

Expand Down
2 changes: 1 addition & 1 deletion test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# $KNATIVE_VERSION with a valid release, e.g. 0.6.0, Knative serving
# of this specified version will be installed in the Kubernetes cluster, and
# all the tests will run against Knative serving of this specific version.
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/e2e-tests.sh
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/e2e-tests.sh

# Helper functions.

Expand Down
2 changes: 1 addition & 1 deletion test/presubmit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export DISABLE_MD_LINTING=1

export GO111MODULE=on
export KNATIVE_VERSION=${KNATIVE_VERSION:-latest}
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/presubmit-tests.sh
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/presubmit-tests.sh

# We use the default build, unit and integration test runners.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ skipped.
### Sample presubmit test script

```bash
source vendor/github.com/knative/test-infra/scripts/presubmit-tests.sh
source vendor/knative.dev/test-infra/scripts/presubmit-tests.sh

function post_build_tests() {
echo "Cleaning up after build tests"
Expand Down Expand Up @@ -197,7 +197,7 @@ test cluster is created in a specific region, `us-west2`.
# This test requires a cluster in LA
E2E_CLUSTER_REGION=us-west2

source vendor/github.com/knative/test-infra/scripts/e2e-tests.sh
source vendor/knative.dev/test-infra/scripts/e2e-tests.sh

function knative_setup() {
start_latest_knative_serving
Expand Down Expand Up @@ -281,7 +281,7 @@ This is a helper script for Knative release scripts. To use it:
### Sample release script

```bash
source vendor/github.com/knative/test-infra/scripts/release.sh
source vendor/knative.dev/test-infra/scripts/release.sh

function build_release() {
# config/ contains the manifests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function go_test_e2e() {
local go_options=""
(( EMIT_METRICS )) && test_options="-emitmetrics"
[[ ! " $@" == *" -tags="* ]] && go_options="-tags=e2e"
report_go_test -v -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 Down Expand Up @@ -214,12 +214,15 @@ function create_test_cluster() {
[[ -n "${GCP_PROJECT}" ]] && test_cmd_args+=" --gcp-project ${GCP_PROJECT}"
[[ -n "${E2E_SCRIPT_CUSTOM_FLAGS[@]}" ]] && test_cmd_args+=" ${E2E_SCRIPT_CUSTOM_FLAGS[@]}"
local extra_flags=()
# If using boskos, save time and let it tear down the cluster
(( ! IS_BOSKOS )) && extra_flags+=(--down)
if (( IS_BOSKOS )); then # Add arbitrary duration, wait for Boskos projects acquisition before error out
extra_flags+=(--boskos-wait-duration=20m)
else # Only let kubetest tear down the cluster if not using Boskos, it's done by Janitor if using Boskos
extra_flags+=(--down)
fi

# Set a minimal kubernetes environment that satisfies kubetest
# TODO(adrcunha): Remove once https://github.com/kubernetes/test-infra/issues/13029 is fixed.
local kubedir="$(mktemp -d --tmpdir kubernetes.XXXXXXXXXX)"
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function dump_app_logs() {
for pod in $(get_app_pods "$1" "$2")
do
echo ">>> Pod: $pod"
kubectl -n "$2" logs "$pod" -c "$1"
kubectl -n "$2" logs "$pod" --all-containers
done
}

Expand Down Expand Up @@ -299,28 +299,72 @@ function acquire_cluster_admin_role() {
$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.
function capture_output() {
local report="$1"
shift
"$@" 2>&1 | tee "${report}"
local failed=( ${PIPESTATUS[@]} )
[[ ${failed[0]} -eq 0 ]] && failed=${failed[1]} || failed=${failed[0]}
return ${failed}
}

# Create a JUnit XML for a test.
# Parameters: $1 - check class name as an identifier (e.g. BuildTests)
# $2 - check name as an identifier (e.g., GoBuild)
# $3 - failure message (can contain newlines), optional (means success)
function create_junit_xml() {
local xml="$(mktemp ${ARTIFACTS}/junit_XXXXXXXX.xml)"
local failure=""
if [[ "$3" != "" ]]; then
# Transform newlines into HTML code.
# Also escape `<` and `>` as here: https://github.com/golang/go/blob/50bd1c4d4eb4fac8ddeb5f063c099daccfb71b26/src/encoding/json/encode.go#L48,
# this is temporary solution for fixing https://github.com/knative/test-infra/issues/1204,
# which should be obsolete once Test-infra 2.0 is in place
local msg="$(echo -n "$3" | sed 's/$/\&#xA;/g' | sed 's/</\\u003c/' | sed 's/>/\\u003e/' | tr -d '\n')"
failure="<failure message=\"Failed\" type=\"\">${msg}</failure>"
fi
cat << EOF > "${xml}"
<testsuites>
<testsuite tests="1" failures="1" time="0.000" name="$1">
<testcase classname="" name="$2" time="0.0">
${failure}
</testcase>
</testsuite>
</testsuites>
EOF
}

# Runs a go test and generate a junit summary.
# Parameters: $1... - parameters to go test
function report_go_test() {
# Run tests in verbose mode to capture details.
# go doesn't like repeating -v, so remove if passed.
local args=" $@ "
local go_test="go test -race -v ${args/ -v / }"
local go_test="go test -v ${args/ -v / }"
# Just run regular go tests if not on Prow.
echo "Running tests with '${go_test}'"
local report=$(mktemp)
${go_test} | tee ${report}
local failed=( ${PIPESTATUS[@]} )
[[ ${failed[0]} -eq 0 ]] && failed=${failed[1]} || failed=${failed[0]}
local report="$(mktemp)"
capture_output "${report}" ${go_test}
local failed=$?
echo "Finished run, return code is ${failed}"
# Install go-junit-report if necessary.
run_go_tool github.com/jstemmer/go-junit-report go-junit-report --help > /dev/null 2>&1
local xml=$(mktemp ${ARTIFACTS}/junit_XXXXXXXX.xml)
cat ${report} \
| go-junit-report \
| sed -e "s#\"github.com/knative/${REPO_NAME}/#\"#g" \
| sed -e "s#\"\(github\.com/knative\|knative\.dev\)/${REPO_NAME}/#\"#g" \
> ${xml}
echo "XML report written to ${xml}"
if [[ -n "$(grep '<testsuites></testsuites>' ${xml})" ]]; then
# XML report is empty, something's wrong; use the output as failure reason
create_junit_xml _go_tests "GoTests" "$(cat ${report})"
fi
# Capture and report any race condition errors
local race_errors="$(sed -n '/^WARNING: DATA RACE$/,/^==================$/p' ${report})"
create_junit_xml _go_tests "DataRaceAnalysis" "${race_errors}"
if (( ! IS_PROW )); then
# Keep the suffix, so files are related.
local logfile=${xml/junit_/go_test_}
Expand Down Expand Up @@ -376,7 +420,7 @@ function update_licenses() {
cd ${REPO_ROOT_DIR} || return 1
local dst=$1
shift
run_go_tool github.com/knative/test-infra/tools/dep-collector dep-collector $@ > ./${dst}
run_go_tool knative.dev/test-infra/tools/dep-collector dep-collector $@ > ./${dst}
}

# Run dep-collector to check for forbidden liceses.
Expand All @@ -386,7 +430,7 @@ function check_licenses() {
rm -fr ${GOPATH}/src/github.com/google/licenseclassifier
go get -u github.com/google/licenseclassifier
# Check that we don't have any forbidden licenses in our images.
run_go_tool github.com/knative/test-infra/tools/dep-collector dep-collector -check $@
run_go_tool knative.dev/test-infra/tools/dep-collector dep-collector -check $@
}

# Run the given linter on the given files, checking it exists first.
Expand Down Expand Up @@ -467,7 +511,7 @@ function remove_broken_symlinks() {
target="${target##* -> }"
[[ ${target} == /* ]] || target="./${target}"
target="$(cd `dirname ${link}` && cd ${target%/*} && echo $PWD/${target##*/})"
if [[ ${target} != *github.com/knative/* ]]; then
if [[ ${target} != *github.com/knative/* && ${target} != *knative.dev/* ]]; then
unlink ${link}
continue
fi
Expand Down Expand Up @@ -517,7 +561,7 @@ function get_latest_knative_yaml_source() {
# These MUST come last.

readonly _TEST_INFRA_SCRIPTS_DIR="$(dirname $(get_canonical_path ${BASH_SOURCE[0]}))"
readonly REPO_NAME_FORMATTED="Knative $(capitalize ${REPO_NAME//-/})"
readonly REPO_NAME_FORMATTED="Knative $(capitalize ${REPO_NAME//-/ })"

# Public latest nightly or release yaml files.
readonly KNATIVE_SERVING_RELEASE="$(get_latest_knative_yaml_source "serving" "serving")"
Expand Down
Loading

0 comments on commit 9f203f2

Please sign in to comment.