X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fbash%2Ffunction%2Fcommon.sh;h=491b47fb481bb6692b0fe035f68ce14e9319e979;hb=a31a47b1b497efffbcbb92004d32885a84f4ff4f;hp=4a560ff98cf132cc7185890f739f1159d09063ec;hpb=6f1ff57c83763556450e8bfcb4571a9c017abe70;p=csit.git diff --git a/resources/libraries/bash/function/common.sh b/resources/libraries/bash/function/common.sh index 4a560ff98c..491b47fb48 100644 --- a/resources/libraries/bash/function/common.sh +++ b/resources/libraries/bash/function/common.sh @@ -182,19 +182,6 @@ function check_prerequisites () { fi } -function cleanup_topo () { - - # Variables read: - # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed. - # - PYTHON_SCRIPTS_DIR - Path to directory holding the reservation script. - - set -exuo pipefail - - python "${PYTHON_SCRIPTS_DIR}/topo_cleanup.py" -t "${WORKING_TOPOLOGY}" - # Not using "|| die" as some callers might want to ignore errors, - # e.g. in teardowns, such as unreserve. -} - function common_dirs () { @@ -239,6 +226,9 @@ function common_dirs () { TOOLS_DIR=$(readlink -e "${RESOURCES_DIR}/tools") || { die "Readlink failed." } + DOC_GEN_DIR=$(readlink -e "${TOOLS_DIR}/doc_gen") || { + die "Readlink failed." + } PYTHON_SCRIPTS_DIR=$(readlink -e "${TOOLS_DIR}/scripts") || { die "Readlink failed." } @@ -467,6 +457,10 @@ function get_test_code () { NODENESS="3n" FLAVOR="skx" ;; + *"2n-clx"*) + NODENESS="2n" + FLAVOR="clx" + ;; *"2n-dnv"*) NODENESS="2n" FLAVOR="dnv" @@ -508,8 +502,8 @@ function get_test_tag_string () { *"device"*) # On parsing error, ${trigger} stays empty. trigger="$(echo "${GERRIT_EVENT_COMMENT_TEXT}" \ - | grep -oE '(devicetest$|devicetest[[:space:]].+$)')" \ - || true + | grep -oE '(devicetest$|devicetest[[:space:]].+$)' \ + || true)" # Set test tags as string. TEST_TAG_STRING="${trigger#$"devicetest"}" ;; @@ -553,36 +547,6 @@ function installed () { } -function remove_topo () { - - # Remove the argument from list of available topologies. - # - # Just a de-duplicated block of code - # - # Argument: - # - ${1} - The topology item to remove. Required. - # Variable read and re-written: - # - TOPOLOGIES - Array of paths to topologies, with failed cleanups removed. - - set -exuo pipefail - - warn "Testbed ${topo} seems unsuitable, removing from the list." - - # Build new topology array. - # TOPOLOGIES=("${TOPOLOGIES[@]/$topo}") - # does not really work, see: - # https://stackoverflow.com/questions/16860877/remove-an-element-from-a-bash-array - - new_topologies=() - for item in "${TOPOLOGIES[@]}"; do - if [[ "${item}" != "${1}" ]]; then - new_topologies+=("${item}") - fi - done - TOPOLOGIES=("${new_topologies[@]}") -} - - function reserve_and_cleanup_testbed () { # Reserve physical testbed, perform cleanup, register trap to unreserve. @@ -594,13 +558,12 @@ function reserve_and_cleanup_testbed () { # - PYTHON_SCRIPTS_DIR - Path to directory holding the reservation script. # - BUILD_TAG - Any string suitable as filename, identifying # test run executing this function. May be unset. - # - BUILD_URL - Any string suitable as URL, identifying - # test run executing this function. May be unset. # Variables set: # - TOPOLOGIES - Array of paths to topologies, with failed cleanups removed. # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed. # Functions called: # - die - Print to stderr and exit. + # - ansible_hosts - Perform an action using ansible, see ansible.sh # Traps registered: # - EXIT - Calls cancel_all for ${WORKING_TOPOLOGY}. @@ -611,7 +574,6 @@ function reserve_and_cleanup_testbed () { set +e scrpt="${PYTHON_SCRIPTS_DIR}/topo_reservation.py" opts=("-t" "${topo}" "-r" "${BUILD_TAG:-Unknown}") - opts+=("-u" "${BUILD_URL:-Unknown}") python "${scrpt}" "${opts[@]}" result="$?" set -e @@ -630,7 +592,7 @@ function reserve_and_cleanup_testbed () { } # Cleanup check. set +e - cleanup_topo + ansible_hosts "cleanup" result="$?" set -e if [[ "${result}" == "0" ]]; then @@ -638,11 +600,6 @@ function reserve_and_cleanup_testbed () { fi warn "Testbed cleanup failed: ${topo}" untrap_and_unreserve_testbed "Fail of unreserve after cleanup." - # WORKING_TOPOLOGY is now empty again. - remove_topo "${topo}" - elif [[ "${result}" != "2" ]]; then - # 1 or unexpected return code, testbed is probably unusable. - remove_topo "${topo}" fi # Else testbed is accessible but currently reserved, moving on. done @@ -787,6 +744,12 @@ function select_tags () { *"3n-tsh"*) default_nic="nic_intel-x520-da2" ;; + *"3n-skx"* | *"2n-skx"* | *"2n-clx"*) + default_nic="nic_intel-xxv710" + ;; + *"3n-hsw"* | *"mrr-daily-master") + default_nic="nic_intel-xl710" + ;; *) default_nic="nic_intel-x710" ;; @@ -837,6 +800,9 @@ function select_tags () { # Not enough nic_intel-xxv710 to support double link tests. test_tag_array+=("!3_node_double_link_topoANDnic_intel-xxv710") ;; + *"2n-clx"*) + test_tag_array+=("!ipsechw") + ;; *"2n-dnv"*) test_tag_array+=("!ipsechw") test_tag_array+=("!memif") @@ -897,6 +863,12 @@ function select_tags () { if [[ "${tag}" == "!"* ]]; then # Exclude tags are not prefixed. TAGS+=("${tag}") + elif [[ "${tag}" == " "* || "${tag}" == *"perftest"* ]]; then + # Badly formed tag expressions can trigger way too much tests. + set -x + warn "The following tag expression hints at bad trigger: ${tag}" + warn "Possible cause: Multiple triggers in a single comment." + die "Aborting to avoid triggering too many tests." elif [[ "${tag}" != "" && "${tag}" != "#"* ]]; then # Empty and comment lines are skipped. # Other lines are normal tags, they are to be prefixed. @@ -942,6 +914,10 @@ function select_topology () { TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*3n_skx*.yaml ) TOPOLOGIES_TAGS="3_node_*_link_topo" ;; + "2n_clx") + TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*2n_clx*.yaml ) + TOPOLOGIES_TAGS="2_node_*_link_topo" + ;; "2n_dnv") TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*2n_dnv*.yaml ) TOPOLOGIES_TAGS="2_node_single_link_topo" @@ -1049,6 +1025,7 @@ function untrap_and_unreserve_testbed () { # - EXIT - Failure to untrap is reported, but ignored otherwise. # Functions called: # - die - Print to stderr and exit. + # - ansible_hosts - Perform an action using ansible, see ansible.sh set -xo pipefail set +eu # We do not want to exit early in a "teardown" function. @@ -1058,7 +1035,7 @@ function untrap_and_unreserve_testbed () { set -eu warn "Testbed looks unreserved already. Trap removal failed before?" else - cleanup_topo || true + ansible_hosts "cleanup" || true python "${PYTHON_SCRIPTS_DIR}/topo_reservation.py" -c -t "${wt}" || { die "${1:-FAILED TO UNRESERVE, FIX MANUALLY.}" 2 }