From 2a1a820ea59eb979e72741a6fa7aa814c0b9f562 Mon Sep 17 00:00:00 2001 From: Sushanta Das Date: Thu, 19 Sep 2024 16:58:15 +0530 Subject: [PATCH] skip deleting ns --- hack/common.sh | 22 +++++++++++++++++++--- hack/run-test.sh | 7 ++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/hack/common.sh b/hack/common.sh index 67cb8b8081..c03a994630 100644 --- a/hack/common.sh +++ b/hack/common.sh @@ -1,14 +1,30 @@ #!/bin/bash +CATALOG_TEST_SKIP_CLEANUP=true +TEST_NS=${TEST_NS:-"konflux-ci"} + # Define a custom kubectl path if you like KUBECTL_CMD=${KUBECTL_CMD:-kubectl} +TEST_RESULT_FILE=/tmp/test-result + # Checks whether the given function exists. function function_exists() { [[ "$(type -t $1)" == "function" ]] } +# Set the return code that the test script will return. +# Parameters: $1 - return code (0-255) +function set_test_return_code() { + # kubetest teardown might fail and thus incorrectly report failure of the + # script, even if the tests pass. + # 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} +} + function detect_changed_e2e_test() { # detect for changes in hack dir # TODO: change PULL_BASE_SHA and PULL_PULL_SHA with values applicable for PAC/GA @@ -63,9 +79,9 @@ function show_failure() { function test_yaml_can_install() { # Validate that all the StepAction/Task CRDs in this repo are valid by creating them in a NS. - ns="test-ns" + ns=${TEST_NS} all_tasks="$*" - ${KUBECTL_CMD} create ns "${ns}" || true + #${KUBECTL_CMD} create ns "${ns}" || true local runtest for runtest in ${all_tasks}; do # remove task/ or stepaction/ from beginning @@ -112,7 +128,7 @@ function test_resource_creation() { version="$( echo $version | tr '.' '-' )" #local tns="${testname}-${version}" - local tns="build-templates-e2e" + local tns=${TEST_NS} local skipit= for ignore in ${TEST_TASKRUN_IGNORES};do diff --git a/hack/run-test.sh b/hack/run-test.sh index e3f0c3426f..090b184d8e 100755 --- a/hack/run-test.sh +++ b/hack/run-test.sh @@ -46,8 +46,9 @@ if [[ ! -d ${resourcedir}/tests ]];then exit 1 fi -#Need to link appstudio-pipeline SA with the TEST_NS namespace if not already -#${KUBECTL_CMD} create sa appstudio-pipeline -n $TEST_NS +#create appstudio-pipeline SA in the TEST_NS namespace if not already +if ! ${KUBECTL_CMD} get sa appstudio-pipeline -n $TEST_NS | grep 'appstudio-pipeline'; then + $KUBECTL_CMD create sa appstudio-pipeline -n $TEST_NS +fi -#test_resource_creation ${RESOURCE}/${NAME}/${VERSION}/tests $TEST_NS test_resource_creation ${RESOURCE}/${NAME}/${VERSION}/tests \ No newline at end of file