X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fbash%2Ffunction%2Fcommon.sh;h=44149ca6e156d197fa1ccdda246dd3eb1c52596b;hb=8e06304165ccf50418027f65605b237eaf14aca7;hp=2082c1ea8589962b9d9e44efa918d3d9f40b90ef;hpb=be96921d6e1e70f519a1df8adf8892c4722d26f5;p=csit.git diff --git a/resources/libraries/bash/function/common.sh b/resources/libraries/bash/function/common.sh index 2082c1ea85..44149ca6e1 100644 --- a/resources/libraries/bash/function/common.sh +++ b/resources/libraries/bash/function/common.sh @@ -93,6 +93,12 @@ function activate_docker_topology () { cat ${WORKING_TOPOLOGY} | grep -v password || { die "Topology read failed!" } + + # Subfunctions to update data that may depend on topology reserved. + set_environment_variables || die + select_tags || die + compose_robot_arguments || die + } @@ -257,6 +263,10 @@ function common_dirs () { function compose_robot_arguments () { + # This function is called by run_tests function. + # The reason is that some jobs (bisect) perform reservation multiple times, + # so WORKING_TOPOLOGY can be different each time. + # # Variables read: # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed. # - DUT - CSIT test/ subdirectory, set while processing tags. @@ -274,6 +284,8 @@ function compose_robot_arguments () { ROBOT_ARGS=("--loglevel" "TRACE") ROBOT_ARGS+=("--variable" "TOPOLOGY_PATH:${WORKING_TOPOLOGY}") + # TODO: The rest does not need to be recomputed on each reservation. + # Refactor TEST_CODE so this part can be called only once. case "${TEST_CODE}" in *"device"*) ROBOT_ARGS+=("--suite" "tests.${DUT}.device") @@ -717,6 +729,9 @@ function reserve_and_cleanup_testbed () { # When cleanup fails, remove from topologies and keep retrying # until all topologies are removed. # + # Multiple other functions are called from here, + # as they set variables that depend on reserved topology data. + # # Variables read: # - TOPOLOGIES - Array of paths to topology yaml to attempt reservation on. # - PYTHON_SCRIPTS_DIR - Path to directory holding the reservation script. @@ -785,6 +800,11 @@ function reserve_and_cleanup_testbed () { echo "Sleeping ${sleep_time}" sleep "${sleep_time}" || die "Sleep failed." done + + # Subfunctions to update data that may depend on topology reserved. + set_environment_variables || die + select_tags || die + compose_robot_arguments || die } @@ -792,12 +812,23 @@ function run_robot () { # Run robot with options based on input variables. # + # Testbed has to be reserved already, + # as some data may have changed between reservations, + # for example excluded NICs. + # # Variables read: # - CSIT_DIR - Path to existing root of local CSIT git repository. # - ARCHIVE_DIR - Path to store robot result files in. # - ROBOT_ARGS, EXPANDED_TAGS - See compose_robot_arguments.sh # - GENERATED_DIR - Tests are assumed to be generated under there. + # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed. + # - DUT - CSIT test/ subdirectory, set while processing tags. + # - TAGS - Array variable holding selected tag boolean expressions. + # - TOPOLOGIES_TAGS - Tag boolean expression filtering tests for topology. + # - TEST_CODE - The test selection string from environment or argument. # Variables set: + # - ROBOT_ARGS - String holding part of all arguments for robot. + # - EXPANDED_TAGS - Array of string robot arguments compiled from tags. # - ROBOT_EXIT_STATUS - Exit status of most recent robot invocation. # Functions called: # - die - Print to stderr and exit. @@ -864,6 +895,9 @@ function select_arch_os () { function select_tags () { + # Only to be called from the reservation function, + # as resulting tags may change based on topology data. + # # Variables read: # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed. # - TEST_CODE - String affecting test selection, usually jenkins job name. @@ -954,7 +988,8 @@ function select_tags () { awk_nics_sub_cmd+='gsub("xl710","40ge2p1xl710");' awk_nics_sub_cmd+='gsub("x520-da2","10ge2p1x520");' awk_nics_sub_cmd+='gsub("cx556a","100ge2p1cx556a");' - awk_nics_sub_cmd+='gsub("cx7veat","200ge2p1cx7veat");' + awk_nics_sub_cmd+='gsub("2p1cx7veat","200ge2p1cx7veat");' + awk_nics_sub_cmd+='gsub("6p3cx7veat","200ge6p3cx7veat");' awk_nics_sub_cmd+='gsub("cx6dx","100ge2p1cx6dx");' awk_nics_sub_cmd+='gsub("e810cq","100ge2p1e810cq");' awk_nics_sub_cmd+='gsub("e822cq","25ge2p1e822cq");' @@ -1275,6 +1310,9 @@ function set_environment_variables () { # Depending on testbed topology, overwrite defaults set in the # resources/libraries/python/Constants.py file # + # Only to be called from the reservation function, + # as resulting values may change based on topology data. + # # Variables read: # - TEST_CODE - String affecting test selection, usually jenkins job name. # Variables set: