diff --git a/Makefile b/Makefile index edb8d226c16..8f8ddca830e 100644 --- a/Makefile +++ b/Makefile @@ -361,6 +361,7 @@ docker-test: ##@tests Run tests in a docker container with golang. test: test-unit ##@tests Run basic, short tests during development test-unit: export BUILD_TAGS ?= +test-unit: export UNIT_TEST_DRY_RUN ?= false test-unit: export UNIT_TEST_COUNT ?= 1 test-unit: export UNIT_TEST_FAILFAST ?= true test-unit: export UNIT_TEST_RERUN_FAILS ?= true diff --git a/_assets/ci/Jenkinsfile.tests b/_assets/ci/Jenkinsfile.tests index 4e5541c088f..e9b9175e9c1 100644 --- a/_assets/ci/Jenkinsfile.tests +++ b/_assets/ci/Jenkinsfile.tests @@ -35,6 +35,11 @@ pipeline { defaultValue: true, description: 'Should the job report test coverage to CodeClimate?' ) + booleanParam( + name: 'UNIT_TEST_DRY_RUN', + defaultValue: false, + description: 'Should the job report ignore the actual test run and just print the test plan?' + ) } options { @@ -72,6 +77,7 @@ pipeline { UNIT_TEST_RERUN_FAILS = "${params.UNIT_TEST_RERUN_FAILS}" UNIT_TEST_USE_DEVELOPMENT_LOGGER = "${params.UNIT_TEST_USE_DEVELOPMENT_LOGGER}" UNIT_TEST_REPORT_CODECLIMATE = "${params.UNIT_TEST_REPORT_CODECLIMATE}" + UNIT_TEST_DRY_RUN = "${params.UNIT_TEST_DRY_RUN}" } stages { diff --git a/_assets/scripts/run_unit_tests.sh b/_assets/scripts/run_unit_tests.sh index 4edf3690311..0c4430e93f1 100755 --- a/_assets/scripts/run_unit_tests.sh +++ b/_assets/scripts/run_unit_tests.sh @@ -47,6 +47,14 @@ run_test_for_packages() { local exit_code_file="exit_code_${iteration}.txt" local timeout="$(( single_timeout * count))m" + if [[ "${UNIT_TEST_DRY_RUN}" == 'true' ]]; then + echo -e "${GRN}Dry run ${iteration}. message:${RST} ${log_message}\n"\ + "${YLW}Dry run ${iteration}. packages:${RST} ${packages}\n"\ + "${YLW}Dry run ${iteration}. count:${RST} ${count}\n"\ + "${YLW}Dry run ${iteration}. timeout:${RST} ${timeout}" + return 0 + fi + echo -e "${GRN}Testing:${RST} ${log_message}. Iteration ${iteration}. -test.count=${count}. Timeout: ${timeout}" gotestsum_flags="${GOTESTSUM_EXTRAFLAGS}"