diff --git a/go.mod b/go.mod index a800bf109..0c0c08719 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( k8s.io/gengo v0.0.0-20221011193443-fad74ee6edd9 k8s.io/klog/v2 v2.80.2-0.20221028030830-9ae4992afb54 k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 - knative.dev/hack v0.0.0-20221114224536-b0354624aa29 + knative.dev/hack v0.0.0-20221115211737-de2ff401a852 sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index 1c257bc99..cd80b81cd 100644 --- a/go.sum +++ b/go.sum @@ -961,8 +961,8 @@ k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 h1:MQ8BAZPZlWk3S9K4a9NCkI k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1/go.mod h1:C/N6wCaBHeBHkHUesQOQy2/MZqGgMAFPqGsGQLdbZBU= k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 h1:GfD9OzL11kvZN5iArC6oTS7RTj7oJOIfnislxYlqTj8= k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -knative.dev/hack v0.0.0-20221114224536-b0354624aa29 h1:FUHfJXlY5e9wFuSf5JlMONy/fQbofS7hEBfOMXLHXso= -knative.dev/hack v0.0.0-20221114224536-b0354624aa29/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= +knative.dev/hack v0.0.0-20221115211737-de2ff401a852 h1:/uB4umKUahDlWbIC96rSETG2BYA0zwQ02SGuM9ZYdOo= +knative.dev/hack v0.0.0-20221115211737-de2ff401a852/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= pgregory.net/rapid v0.3.3 h1:jCjBsY4ln4Atz78QoBWxUEvAHaFyNDQg9+WU62aCn1U= pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/vendor/knative.dev/hack/README.md b/vendor/knative.dev/hack/README.md index 607bc897a..b3ad76c5a 100644 --- a/vendor/knative.dev/hack/README.md +++ b/vendor/knative.dev/hack/README.md @@ -123,6 +123,10 @@ This is a helper script for Knative E2E test scripts. To use it: when a test fails, and can dump extra information about the current state of the cluster (typically using `kubectl`). +1. [optional] Write the `on_success` function. It will be called when a test succeeds + +1. [optional] Write the `on_failure` function. It will be called when a test fails + 1. [optional] Write the `parse_flags()` function. It will be called whenever an unrecognized flag is passed to the script, allowing you to define your own flags. The function must return 0 if the flag is unrecognized, or the number diff --git a/vendor/knative.dev/hack/e2e-tests.sh b/vendor/knative.dev/hack/e2e-tests.sh index cb186a4e2..96290f9f3 100644 --- a/vendor/knative.dev/hack/e2e-tests.sh +++ b/vendor/knative.dev/hack/e2e-tests.sh @@ -21,13 +21,8 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/infra-library.sh" readonly TEST_RESULT_FILE=/tmp/${REPO_NAME}-e2e-result -# Flag whether test is using a boskos GCP project -IS_BOSKOS=0 - # Tear down the test resources. function teardown_test_resources() { - # On boskos, save time and don't teardown as the cluster will be destroyed anyway. - (( IS_BOSKOS )) && return header "Tearing down test environment" if function_exists test_teardown; then test_teardown @@ -89,10 +84,9 @@ function setup_test_cluster() { kubectl config set-context "${k8s_cluster}" --namespace=default echo "- Cluster is ${k8s_cluster}" - echo "- Docker is ${KO_DOCKER_REPO}" + echo "- KO_DOCKER_REPO is ${KO_DOCKER_REPO}" - # Do not run teardowns if we explicitly want to skip them. - (( ! SKIP_TEARDOWNS )) && add_trap teardown_test_resources EXIT + (( TEARDOWN )) && add_trap teardown_test_resources EXIT # Handle failures ourselves, so we can dump useful info. set +o errexit @@ -111,7 +105,7 @@ function success() { echo "**************************************" echo "*** E2E TESTS PASSED ***" echo "**************************************" - dump_metrics + function_exists on_success && on_success exit 0 } @@ -122,13 +116,18 @@ function fail_test() { if [[ "X${message:-}X" == "XX" ]]; then message='test failed' fi - add_trap "dump_cluster_state;dump_metrics" EXIT + function_exists on_failure && on_failure + (( ! SKIP_DUMP_ON_FAILURE )) && dump_cluster_state abort "${message}" } -SKIP_TEARDOWNS=0 +# Since create_test_cluster invokes the test script +# recursively we don't want to override these on the second +# invocation +TEARDOWN=${TEARDOWN:-0} +CLOUD_PROVIDER=${CLOUD_PROVIDER:-"gke"} +SKIP_DUMP_ON_FAILURE=${SKIP_DUMP_ON_FAILURE:-0} E2E_SCRIPT="" -CLOUD_PROVIDER="gke" # Parse flags and initialize the test cluster. function initialize() { @@ -153,7 +152,7 @@ function initialize() { # Skip parsed flag (and possibly argument) and continue # Also save it to it's passed through to the test script for ((i=1;i<=skip;i++)); do - # Avoid double-parsing + # Avoid double-parsing if (( parse_script_flags )); then e2e_script_command+=("$1") fi @@ -165,9 +164,10 @@ function initialize() { # Try parsing flag as a standard one. case ${parameter} in --run-tests) run_tests=1 ;; - --skip-teardowns) SKIP_TEARDOWNS=1 ;; - --skip-istio-addon) echo "--skip-istio-addon is no longer supported" - ;; # This flag is a noop + --teardown) TEARDOWN=1 ;; + --skip-teardowns) echo "--skip-teardowns is no longer supported - opt in with --teardown" ;; + --skip-dump-on-failure) SKIP_DUMP_ON_FAILURE=1 ;; + --skip-istio-addon) echo "--skip-istio-addon is no longer supported" ;; *) case ${parameter} in --cloud-provider) shift; CLOUD_PROVIDER="$1" ;; @@ -177,14 +177,13 @@ function initialize() { shift done - (( IS_PROW )) && [[ -z "${GCP_PROJECT_ID:-}" ]] && IS_BOSKOS=1 - if [[ "${CLOUD_PROVIDER}" == "gke" ]]; then custom_flags+=("--addons=NodeLocalDNS") fi - readonly IS_BOSKOS - readonly SKIP_TEARDOWNS + readonly SKIP_DUMP_ON_FAILURE + readonly TEARDOWN + readonly CLOUD_PROVIDER if (( ! run_tests )); then create_test_cluster "${CLOUD_PROVIDER}" custom_flags e2e_script_command diff --git a/vendor/modules.txt b/vendor/modules.txt index 4ec268993..fb1672704 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1118,7 +1118,7 @@ k8s.io/utils/net k8s.io/utils/pointer k8s.io/utils/strings/slices k8s.io/utils/trace -# knative.dev/hack v0.0.0-20221114224536-b0354624aa29 +# knative.dev/hack v0.0.0-20221115211737-de2ff401a852 ## explicit; go 1.18 knative.dev/hack # sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2