diff --git a/test/env.sh b/test/env.sh index c8e7d9d6f..1683488ee 100644 --- a/test/env.sh +++ b/test/env.sh @@ -21,6 +21,8 @@ : "${TEST_REGEX:=smoke}" # Regex to skip Test Cases : "${SKIP_REGEX:=}" +# Set to DEBUG_RUN:=True to skip tear down of test environment in case of test failure +: "${DEBUG_RUN:=False}" # Docker registry to use to push the test images to and pull from in the cluster if [ -z "${PRIVATE_REGISTRY}" ]; then diff --git a/test/run-tests.sh b/test/run-tests.sh index 9b04c6994..15304b260 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -118,8 +118,13 @@ if [[ -z "${TEST_TO_SKIP}" ]]; then echo "TEST_TO_SKIP not set. Changing to default" export TEST_TO_SKIP="${SKIP_REGEX}" fi -echo "Skipping following test :: ${TEST_TO_SKIP}" +if [[ -z "${DEBUG}" ]]; then + echo "DEBUG not set. Changing to default" + export DEBUG="${DEBUG_RUN}" +fi + +echo "Skipping following test :: ${TEST_TO_SKIP}" # Running only smoke test cases by default or value passed through TEST_FOCUS env variable. To run different test packages add/remove path from focus argument or TEST_FOCUS variable ginkgo -v -progress -r -keepGoing -nodes=${CLUSTER_NODES} --noisyPendings=false --reportPassed --focus="${TEST_TO_RUN}" --skip="${TEST_TO_SKIP}" ${topdir}/test/ -- -commit-hash=${COMMIT_HASH} -operator-image=${PRIVATE_SPLUNK_OPERATOR_IMAGE} -splunk-image=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} \ No newline at end of file diff --git a/test/testenv/deployment.go b/test/testenv/deployment.go index 86a3d7a4a..3704d9d72 100644 --- a/test/testenv/deployment.go +++ b/test/testenv/deployment.go @@ -72,7 +72,7 @@ func (d *Deployment) popCleanupFunc() (cleanupFunc, error) { // Teardown teardowns the deployment resources func (d *Deployment) Teardown() error { - if d.testenv.SkipTeardown { + if d.testenv.SkipTeardown && d.testenv.debug == "True" { d.testenv.Log.Info("deployment teardown is skipped!\n") return nil } diff --git a/test/testenv/testenv.go b/test/testenv/testenv.go index 248dcb0c0..dd62b044b 100644 --- a/test/testenv/testenv.go +++ b/test/testenv/testenv.go @@ -142,6 +142,7 @@ type TestEnv struct { kubeClient client.Client Log logr.Logger cleanupFuncs []cleanupFunc + debug string } func init() { @@ -194,6 +195,7 @@ func NewTestEnv(name, commitHash, operatorImage, splunkImage, licenseFilePath st licenseCMName: envName, licenseFilePath: licenseFilePath, s3IndexSecret: "splunk-s3-index-" + envName, + debug: os.Getenv("DEBUG"), } testenv.Log = logf.Log.WithValues("testenv", testenv.name) @@ -294,7 +296,7 @@ func (testenv *TestEnv) setup() error { // Teardown cleanup the resources use in this testenv func (testenv *TestEnv) Teardown() error { - if testenv.SkipTeardown { + if testenv.SkipTeardown && testenv.debug == "True" { testenv.Log.Info("testenv teardown is skipped!\n") return nil }