@@ -92,7 +92,7 @@ psm::lb::get_tests() {
9292# ######################################
9393psm::lb::run_test () {
9494 local test_name=" ${1:? ${FUNCNAME[0]} missing the test name argument} "
95- psm::tools::print_test_flags " ${test_name} "
95+ psm::run::finalize_test_flags " ${test_name} "
9696 psm::tools::run_verbose python -m " tests.${test_name} " " ${PSM_TEST_FLAGS[@]} "
9797}
9898
@@ -139,7 +139,7 @@ psm::security::run_test() {
139139 PSM_TEST_FLAGS+=(" --nocheck_local_certs" )
140140 fi
141141
142- psm::tools::print_test_flags " ${test_name} "
142+ psm::run::finalize_test_flags " ${test_name} "
143143 psm::tools::run_verbose python -m " tests.${test_name} " " ${PSM_TEST_FLAGS[@]} "
144144}
145145
@@ -178,7 +178,7 @@ psm::url_map::run_test() {
178178 PSM_TEST_FLAGS+=(
179179 " --flagfile=config/url-map.cfg"
180180 )
181- psm::tools::print_test_flags " ${test_name} "
181+ psm::run::finalize_test_flags " ${test_name} "
182182 psm::tools::run_verbose python -m " tests.${test_name} " " ${PSM_TEST_FLAGS[@]} "
183183}
184184
@@ -223,7 +223,7 @@ psm::csm::run_test() {
223223 PSM_TEST_FLAGS+=(
224224 " --flagfile=config/common-csm.cfg"
225225 )
226- psm::tools::print_test_flags " ${test_name} "
226+ psm::run::finalize_test_flags " ${test_name} "
227227 psm::tools::run_verbose python -m " tests.${test_name} " " ${PSM_TEST_FLAGS[@]} "
228228}
229229
@@ -317,7 +317,7 @@ psm::run::test() {
317317 # Test driver usage: https://github.com/grpc/psm-interop#basic-usage
318318 local test_suite=" ${1:? ${FUNCNAME[0]} missing the test suite argument} "
319319 local test_name=" ${2:? ${FUNCNAME[0]} missing the test name argument} "
320- local out_dir=" ${TEST_XML_OUTPUT_DIR} /${test_name} "
320+ local out_dir=" ${TEST_XML_OUTPUT_DIR:-/ tmp / psm } /${test_name} "
321321 local test_log=" ${out_dir} /sponge_log.log"
322322 mkdir -p " ${out_dir} "
323323
@@ -350,6 +350,33 @@ psm::run::test() {
350350 " psm::${test_suite} ::run_test" " ${test_name} " | & tee -a " ${test_log} "
351351}
352352
353+ # ######################################
354+ # Appends extra flags (if any) to the end of PSM_TEST_FLAGS, prints the flag list.
355+ # Globals:
356+ # PSM_TEST_FLAGS: The array with flags for the test
357+ # PSM_EXTRA_FLAGS: Space-separated string with extra flags to append
358+ # Arguments:
359+ # Test case name
360+ # Outputs:
361+ # Prints the list of test flags to the stdout
362+ # ######################################
363+ psm::run::finalize_test_flags () {
364+ local test_name=" ${1:? ${FUNCNAME[0]} missing the test name argument} "
365+
366+ # Append extra flags
367+ # TODO(sergiitk): replace BAZEL_FLAGS with PSM_EXTRA_FLAGS when allowed_env_vars configured
368+ if [[ -n " ${BAZEL_FLAGS} " ]]; then
369+ declare -a extra_flags
370+ IFS=' ' read -r -a extra_flags <<< " ${BAZEL_FLAGS}"
371+ PSM_TEST_FLAGS+=(" ${extra_flags[@]} " )
372+ fi
373+
374+ psm::tools::log " Test driver flags for ${test_name} :"
375+ printf -- " %s\n" " ${PSM_TEST_FLAGS[@]} "
376+ echo
377+ }
378+
379+
353380# --- Common test setup logic -----------
354381
355382psm::setup::generic_test_suite () {
@@ -362,8 +389,19 @@ psm::setup::generic_test_suite() {
362389
363390psm::setup::get_tests () {
364391 local test_suite=" ${1:? ${FUNCNAME[0]} missing the test suite argument} "
365- # TODO(sergiitk): allow to override TESTS from an env var
366- " psm::${test_suite} ::get_tests"
392+
393+ # TODO(sergiitk): replace BAZEL_TESTS with PSM_TESTS when allowed_env_vars configured
394+ if [[ -n " ${BAZEL_TESTS} " ]]; then
395+ # Test list overridden in env var.
396+ IFS=' ' read -r -a TESTS <<< " ${BAZEL_TESTS}"
397+ if (( ${# TESTS[@]} == 0 )) ; then
398+ psm::tools::log " Error: test list overridden, but no tests specified"
399+ exit 1
400+ fi
401+ else
402+ " psm::${test_suite} ::get_tests"
403+ fi
404+
367405 psm::tools::log " Tests in ${test_suite} test suite:"
368406 printf -- " - %s\n" " ${TESTS[@]} "
369407 echo
@@ -560,13 +598,6 @@ psm::tools::log() {
560598 echo " $@ "
561599}
562600
563- psm::tools::print_test_flags () {
564- local test_name=" ${1:? ${FUNCNAME[0]} missing the test name argument} "
565- psm::tools::log " Test driver flags for ${test_name} :"
566- printf -- " %s\n" " ${PSM_TEST_FLAGS[@]} "
567- echo
568- }
569-
570601# --- "Unsorted" methods --------------
571602# TODO(sergiitk): all methods should be using "psm::" package name,
572603# see https://google.github.io/styleguide/shellguide.html#function-names
0 commit comments