1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
16 # This library defines functions used by multiple entry scripts.
17 # Keep functions ordered alphabetically, please.
19 # TODO: Add a link to bash style guide.
20 # TODO: Consider putting every die into a {} block,
21 # the code might become more readable (but longer).
24 function activate_docker_topology () {
25 # Create virtual vpp-device topology. Output of the function is topology
26 # file describing created environment saved to a file.
29 # - BASH_FUNCTION_DIR - Path to existing directory this file is located in.
30 # - TOPOLOGIES - Available topologies.
31 # - NODENESS - Node multiplicity of desired testbed.
32 # - FLAVOR - Node flavor string, usually describing the processor.
34 # - WORKING_TOPOLOGY - Path to topology file.
38 source "${BASH_FUNCTION_DIR}/device.sh" || {
42 device_image="$(< ${CSIT_DIR}/VPP_DEVICE_IMAGE)"
43 case_text="${NODENESS}_${FLAVOR}"
44 case "${case_text}" in
46 # We execute reservation over csit-shim-dcr (ssh) which runs sourced
47 # script's functions. Env variables are read from ssh output
48 # back to localhost for further processing.
49 hostname=$(grep search /etc/resolv.conf | cut -d' ' -f3)
50 ssh="ssh root@${hostname} -p 6022"
51 run="activate_wrapper ${NODENESS} ${FLAVOR} ${device_image}"
52 env_vars=$(${ssh} "$(declare -f); ${run}") || {
53 die "Topology reservation via shim-dcr failed!"
56 source <(echo "$env_vars" | grep -v /usr/bin/docker) || {
62 # We execute reservation on localhost. Sourced script automatially
63 # sets environment variables for further processing.
64 activate_wrapper "${NODENESS}" "${FLAVOR}" "${device_image}" || die
67 die "Unknown specification: ${case_text}!"
70 trap 'deactivate_docker_topology' EXIT || {
71 die "Trap attempt failed, please cleanup manually. Aborting!"
74 # Replace all variables in template with those in environment.
75 source <(echo 'cat <<EOF >topo.yml'; cat ${TOPOLOGIES[0]}; echo EOF;) || {
76 die "Topology file create failed!"
79 WORKING_TOPOLOGY="/tmp/topology.yaml"
80 mv topo.yml "${WORKING_TOPOLOGY}" || {
81 die "Topology move failed!"
83 cat ${WORKING_TOPOLOGY} | grep -v password || {
84 die "Topology read failed!"
89 function activate_virtualenv () {
94 # - ${1} - Non-empty path to existing directory for creating virtualenv in.
96 # - CSIT_DIR - Path to existing root of local CSIT git repository.
98 # - ENV_DIR - Path to the created virtualenv subdirectory.
100 # - PYTHONPATH - CSIT_DIR, as CSIT Python scripts usually need this.
102 # - die - Print to stderr and exit.
104 # TODO: Do we really need to have ENV_DIR available as a global variable?
106 if [[ "${1-}" == "" ]]; then
107 die "Root location of virtualenv to create is not specified."
110 rm -rf "${ENV_DIR}" || die "Failed to clean previous virtualenv."
112 pip install --upgrade virtualenv || {
113 die "Virtualenv package install failed."
115 virtualenv "${ENV_DIR}" || {
116 die "Virtualenv creation failed."
119 source "${ENV_DIR}/bin/activate" || die "Virtualenv activation failed."
121 pip install -r "${CSIT_DIR}/requirements.txt" || {
122 die "CSIT requirements installation failed."
125 # Most CSIT Python scripts assume PYTHONPATH is set and exported.
126 export PYTHONPATH="${CSIT_DIR}" || die "Export failed."
130 function check_download_dir () {
134 # Fail if there are no files visible in ${DOWNLOAD_DIR}.
135 # TODO: Do we need this as a function, if it is (almost) a one-liner?
138 # - DOWNLOAD_DIR - Path to directory pybot takes the build to test from.
140 # - ${DOWNLOAD_DIR} - Has to be non-empty to proceed.
142 # - die - Print to stderr and exit.
144 if [[ ! "$(ls -A "${DOWNLOAD_DIR}")" ]]; then
145 die "No artifacts downloaded!"
150 function cleanup_topo () {
155 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
156 # - PYTHON_SCRIPTS_DIR - Path to directory holding the reservation script.
158 python "${PYTHON_SCRIPTS_DIR}/topo_cleanup.py" -t "${WORKING_TOPOLOGY}"
159 # Not using "|| die" as some callers might want to ignore errors,
160 # e.g. in teardowns, such as unreserve.
164 function common_dirs () {
169 # - BASH_FUNCTION_DIR - Path to existing directory this file is located in.
170 # - CSIT_DIR - Path to existing root of local CSIT git repository.
171 # - TOPOLOGIES_DIR - Path to existing directory with available tpologies.
172 # - RESOURCES_DIR - Path to existing CSIT subdirectory "resources".
173 # - TOOLS_DIR - Path to existing resources subdirectory "tools".
174 # - PYTHON_SCRIPTS_DIR - Path to existing tools subdirectory "scripts".
175 # - ARCHIVE_DIR - Path to created CSIT subdirectory "archive".
176 # - DOWNLOAD_DIR - Path to created CSIT subdirectory "download_dir".
178 # - die - Print to stderr and exit.
180 BASH_FUNCTION_DIR="$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")" || {
181 die "Some error during localizing this source directory."
183 # Current working directory could be in a different repo, e.g. VPP.
184 pushd "${BASH_FUNCTION_DIR}" || die "Pushd failed"
185 CSIT_DIR="$(readlink -e "$(git rev-parse --show-toplevel)")" || {
186 die "Readlink or git rev-parse failed."
188 popd || die "Popd failed."
189 TOPOLOGIES_DIR="$(readlink -e "${CSIT_DIR}/topologies/available")" || {
190 die "Readlink failed."
192 RESOURCES_DIR="$(readlink -e "${CSIT_DIR}/resources")" || {
193 die "Readlink failed."
195 TOOLS_DIR="$(readlink -e "${RESOURCES_DIR}/tools")" || {
196 die "Readlink failed."
198 PYTHON_SCRIPTS_DIR="$(readlink -e "${TOOLS_DIR}/scripts")" || {
199 die "Readlink failed."
202 ARCHIVE_DIR="$(readlink -f "${CSIT_DIR}/archive")" || {
203 die "Readlink failed."
205 mkdir -p "${ARCHIVE_DIR}" || die "Mkdir failed."
206 DOWNLOAD_DIR="$(readlink -f "${CSIT_DIR}/download_dir")" || {
207 die "Readlink failed."
209 mkdir -p "${DOWNLOAD_DIR}" || die "Mkdir failed."
213 function compose_pybot_arguments () {
218 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
219 # - DUT - CSIT test/ subdirectory, set while processing tags.
220 # - TAGS - Array variable holding selected tag boolean expressions.
221 # - TOPOLOGIES_TAGS - Tag boolean expression filtering tests for topology.
222 # - TEST_CODE - The test selection string from environment or argument.
224 # - PYBOT_ARGS - String holding part of all arguments for pybot.
225 # - EXPANDED_TAGS - Array of strings pybot arguments compiled from tags.
227 # No explicit check needed with "set -u".
228 PYBOT_ARGS=("--loglevel" "TRACE")
229 PYBOT_ARGS+=("--variable" "TOPOLOGY_PATH:${WORKING_TOPOLOGY}")
231 case "${TEST_CODE}" in
233 PYBOT_ARGS+=("--suite" "tests.${DUT}.device")
236 PYBOT_ARGS+=("--suite" "tests.${DUT}.func")
239 PYBOT_ARGS+=("--suite" "tests.${DUT}.perf")
242 die "Unknown specification: ${TEST_CODE}"
246 for tag in "${TAGS[@]}"; do
247 if [[ ${tag} == "!"* ]]; then
248 EXPANDED_TAGS+=("--exclude" "${tag#$"!"}")
250 EXPANDED_TAGS+=("--include" "${TOPOLOGIES_TAGS}AND${tag}")
256 function copy_archives () {
261 # - WORKSPACE - Jenkins workspace, copy only if the value is not empty.
262 # Can be unset, then it speeds up manual testing.
263 # - ARCHIVE_DIR - Path to directory with content to be copied.
264 # Directories updated:
265 # - ${WORKSPACE}/archives/ - Created if does not exist.
266 # Content of ${ARCHIVE_DIR}/ is copied here.
268 # - die - Print to stderr and exit.
270 # We will create additional archive if workspace variable is set.
271 # This way if script is running in jenkins all will be
272 # automatically archived to logs.fd.io.
273 if [[ -n "${WORKSPACE-}" ]]; then
274 mkdir -p "${WORKSPACE}/archives/" || die "Archives dir create failed."
275 cp -rf "${ARCHIVE_DIR}"/* "${WORKSPACE}/archives" || die "Copy failed."
280 function deactivate_docker_topology () {
281 # Deactivate virtual vpp-device topology by removing containers.
284 # - NODENESS - Node multiplicity of desired testbed.
285 # - FLAVOR - Node flavor string, usually describing the processor.
289 case_text="${NODENESS}_${FLAVOR}"
290 case "${case_text}" in
292 hostname=$(grep search /etc/resolv.conf | cut -d' ' -f3)
293 ssh="ssh root@${hostname} -p 6022"
294 env_vars="$(env | grep CSIT_ | tr '\n' ' ' )"
295 ${ssh} "$(declare -f); deactivate_wrapper ${env_vars}" || {
296 die "Topology cleanup via shim-dcr failed!"
301 clean_environment || {
302 die "Topology cleanup locally failed!"
307 die "Unknown specification: ${case_text}!"
313 # Print the message to standard error end exit with error code specified
314 # by the second argument.
317 # - The default error message.
319 # - ${1} - The whole error message, be sure to quote. Optional
320 # - ${2} - the code to exit with, default: 1.
324 warn "${1:-Unspecified run-time error occurred!}"
329 function die_on_pybot_error () {
333 # Source this fragment if you want to abort on any failed test case.
336 # - PYBOT_EXIT_STATUS - Set by a pybot running fragment.
338 # - die - Print to stderr and exit.
340 if [[ "${PYBOT_EXIT_STATUS}" != "0" ]]; then
341 die "${PYBOT_EXIT_STATUS}" "Test failures are present!"
346 function get_test_code () {
351 # - ${1} - Optional, argument of entry script (or empty as unset).
352 # Test code value to override job name from environment.
354 # - JOB_NAME - String affecting test selection, default if not argument.
356 # - TEST_CODE - The test selection string from environment or argument.
357 # - NODENESS - Node multiplicity of desired testbed.
358 # - FLAVOR - Node flavor string, usually describing the processor.
360 TEST_CODE="${1-}" || die "Reading optional argument failed, somehow."
361 if [[ -z "${TEST_CODE}" ]]; then
362 TEST_CODE="${JOB_NAME-}" || die "Reading job name failed, somehow."
365 case "${TEST_CODE}" in
383 # Fallback to 3-node Haswell by default (backward compatibility)
391 function get_test_tag_string () {
396 # - GERRIT_EVENT_TYPE - Event type set by gerrit, can be unset.
397 # - GERRIT_EVENT_COMMENT_TEXT - Comment text, read for "comment-added" type.
398 # - TEST_CODE - The test selection string from environment or argument.
400 # - TEST_TAG_STRING - The string following "perftest" in gerrit comment,
403 # TODO: ci-management scripts no longer need to perform this.
406 if [[ "${GERRIT_EVENT_TYPE-}" == "comment-added" ]]; then
407 case "${TEST_CODE}" in
409 # On parsing error, ${trigger} stays empty.
410 trigger="$(echo "${GERRIT_EVENT_COMMENT_TEXT}" \
411 | grep -oE '(devicetest$|devicetest[[:space:]].+$)')" \
413 # Set test tags as string.
414 TEST_TAG_STRING="${trigger#$"devicetest"}"
417 # On parsing error, ${trigger} stays empty.
418 trigger="$(echo "${GERRIT_EVENT_COMMENT_TEXT}" \
419 | grep -oE '(perftest$|perftest[[:space:]].+$)')" \
421 # Set test tags as string.
422 TEST_TAG_STRING="${trigger#$"perftest"}"
425 die "Unknown specification: ${TEST_CODE}"
431 function reserve_testbed () {
435 # Reserve physical testbed, perform cleanup, register trap to unreserve.
438 # - TOPOLOGIES - Array of paths to topology yaml to attempt reservation on.
439 # - PYTHON_SCRIPTS_DIR - Path to directory holding the reservation script.
441 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
443 # - die - Print to stderr and exit.
445 # - EXIT - Calls cancel_all for ${WORKING_TOPOLOGY}.
448 for topo in "${TOPOLOGIES[@]}"; do
450 python "${PYTHON_SCRIPTS_DIR}/topo_reservation.py" -t "${topo}"
453 if [[ "${result}" == "0" ]]; then
454 WORKING_TOPOLOGY="${topo}"
455 echo "Reserved: ${WORKING_TOPOLOGY}"
456 trap "untrap_and_unreserve_testbed" EXIT || {
457 message="TRAP ATTEMPT AND UNRESERVE FAILED, FIX MANUALLY."
458 untrap_and_unreserve_testbed "${message}" || {
459 die "Teardown should have died, not failed."
461 die "Trap attempt failed, unreserve succeeded. Aborting."
464 die "Testbed cleanup failed."
470 if [[ -n "${WORKING_TOPOLOGY-}" ]]; then
471 # Exit the infinite while loop if we made a reservation.
475 # Wait ~3minutes before next try.
476 sleep_time="$[ ( $RANDOM % 20 ) + 180 ]s" || {
477 die "Sleep time calculation failed."
479 echo "Sleeping ${sleep_time}"
480 sleep "${sleep_time}" || die "Sleep failed."
485 function run_pybot () {
489 # Currently, VPP-1361 causes occasional test failures.
490 # If real result is more important than time, we can retry few times.
491 # TODO: We should be retrying on test case level instead.
494 # - ${1} - Optional number of pybot invocations to try to avoid failures.
497 # - CSIT_DIR - Path to existing root of local CSIT git repository.
498 # - ARCHIVE_DIR - Path to store robot result files in.
499 # - PYBOT_ARGS, EXPANDED_TAGS - See compose_pybot_arguments.sh
501 # - PYBOT_EXIT_STATUS - Exit status of most recent pybot invocation.
503 # - die - Print to stderr and exit.
505 # Set ${tries} as an integer variable, to fail on non-numeric input.
506 local -i "tries" || die "Setting type of variable failed."
507 tries="${1:-1}" || die "Argument evaluation failed."
508 all_options=("--outputdir" "${ARCHIVE_DIR}" "${PYBOT_ARGS[@]}")
509 all_options+=("${EXPANDED_TAGS[@]}")
512 if [[ "${tries}" -le 0 ]]; then
515 tries="$((${tries} - 1))"
517 pushd "${CSIT_DIR}" || die "Change directory operation failed."
519 # TODO: Make robot tests not require "$(pwd)" == "${CSIT_DIR}".
520 pybot "${all_options[@]}" "${CSIT_DIR}/tests/"
521 PYBOT_EXIT_STATUS="$?"
523 popd || die "Change directory operation failed."
524 if [[ "${PYBOT_EXIT_STATUS}" == "0" ]]; then
531 function select_tags () {
536 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
537 # - TEST_CODE - String affecting test selection, usually jenkins job name.
538 # - TEST_TAG_STRING - String selecting tags, from gerrit comment.
540 # - TOPOLOGIES_DIR - Path to existing directory with available tpologies.
542 # - TAGS - Array of processed tag boolean expressions.
545 # All topologies NICs
546 available=$(grep -hoPR "model: \K.*" "${TOPOLOGIES_DIR}"/* | sort -u)
547 # Selected topology NICs
548 reserved=$(grep -hoPR "model: \K.*" "${WORKING_TOPOLOGY}" | sort -u)
549 # All topologies NICs - Selected topology NICs
550 exclude_nics=($(comm -13 <(echo "${reserved}") <(echo "${available}")))
552 case "${TEST_CODE}" in
553 # Select specific performance tests based on jenkins job type variable.
555 test_tag_array=("ndrpdrAND64bAND1c"
559 test_tag_array=(# vic
560 "mrrANDnic_cisco-vic-1227AND64b"
561 "mrrANDnic_cisco-vic-1385AND64b"
563 "mrrANDmemifANDethAND64b"
564 "mrrANDmemifANDethANDimix"
568 "mrrANDip4baseAND64b"
570 "mrrANDip4fwdANDfib_2mAND64b"
572 "mrrANDip4fwdANDfib_200kANDnic_intel-*710AND64b"
574 "mrrANDip4fwdANDfib_20kANDnic_intel-*710AND64b"
576 "mrrANDip4fwdANDacl1AND10k_flowsAND64b"
577 "mrrANDip4fwdANDacl50AND10k_flowsAND64b"
579 "mrrANDip4fwdANDnat44ANDbaseAND64b"
580 "mrrANDip4fwdANDnat44ANDsrc_user_4000AND64b"
582 "mrrANDip4fwdANDfeatureANDnic_intel-*710AND64b"
583 # TODO: Remove when tags in
584 # tests/vpp/perf/ip4/*-ipolicemarkbase-*.robot
586 "mrrANDip4fwdANDpolice_markANDnic_intel-*710AND64b"
588 "mrrANDip4fwdANDencapANDip6unrlayANDip4ovrlayANDnic_intel-x520-da2AND64b"
589 "mrrANDip4fwdANDencapANDnic_intel-*710AND64b"
590 "mrrANDl2ovrlayANDencapANDnic_intel-*710AND64b"
592 "mrrANDip6baseANDethAND78b"
594 "mrrANDip6fwdANDfeatureANDnic_intel-*710AND78b"
596 "mrrANDip6fwdANDfib_2mANDnic_intel-*710AND78b"
598 "mrrANDip6fwdANDfib_200kANDnic_intel-*710AND78b"
600 "mrrANDip6fwdANDfib_20kANDnic_intel-*710AND78b"
602 "mrrANDip6fwdANDencapANDnic_intel-x520-da2AND78b"
604 "mrrANDl2xcfwdANDbaseAND64b"
606 "mrrANDl2xcANDacl1AND10k_flowsAND64b"
607 "mrrANDl2xcANDacl50AND10k_flowsAND64b"
609 "mrrANDl2xcANDfib_2mAND64b"
610 # l2xc scale FIB 200k
611 "mrrANDl2xcANDfib_200kANDnic_intel-*710AND64b"
613 "mrrANDl2xcANDfib_20kANDnic_intel-*710AND64b"
615 "mrrANDl2bdmaclrnANDbaseAND64b"
617 "mrrANDl2bdmaclrnANDacl1AND10k_flowsAND64b"
618 "mrrANDl2bdmaclrnANDacl50AND10k_flowsAND64b"
620 "mrrANDl2bdmaclrnANDfib_1mAND64b"
621 # l2bd scale FIB 200k
622 "mrrANDl2bdmaclrnANDfib_100kANDnic_intel-*710AND64b"
624 "mrrANDl2bdmaclrnANDfib_10kANDnic_intel-*710AND64b"
626 "mrrANDl2patchAND64b"
628 "mrrANDsrv6ANDnic_intel-x520-da2AND78b"
630 "mrrANDvtsANDnic_intel-x520-da2AND114b"
632 "mrrANDvhostANDl2xcfwdANDbaseAND64b"
633 "mrrANDvhostANDl2xcfwdANDbaseANDimix"
635 "mrrANDvhostANDl2bdmaclrnANDbaseAND64b"
636 "mrrANDvhostANDl2bdmaclrnANDbaseANDimix"
638 "mrrANDvhostANDip4fwdANDbaseAND64b"
639 "mrrANDvhostANDip4fwdANDbaseANDimix"
643 "!mrrANDip6baseANDdot1qAND78b"
644 "!vhost_256ANDnic_intel-x520-da2"
645 "!vhostANDnic_intel-xl710"
651 test_tag_array=(# NF Density tests
652 "mrrANDnf_densityAND64b"
653 "mrrANDnf_densityANDimix"
658 if [[ -z "${TEST_TAG_STRING-}" ]]; then
659 # If nothing is specified, we will run pre-selected tests by
661 test_tag_array=("mrrANDnic_intel-x710AND1cAND64bANDip4base"
662 "mrrANDnic_intel-x710AND1cAND78bANDip6base"
663 "mrrANDnic_intel-x710AND1cAND64bANDl2bdbase"
664 "mrrANDnic_intel-x710AND1cAND64bANDl2xcbase"
667 # If trigger contains tags, split them into array.
668 test_tag_array=(${TEST_TAG_STRING//:/ })
673 # Blacklisting certain tags per topology.
674 case "${TEST_CODE}" in
676 test_tag_array+=("!drv_avf")
679 test_tag_array+=("!ipsechw")
682 test_tag_array+=("!ipsechw")
685 # Default to 3n-hsw due to compatibility.
686 test_tag_array+=("!drv_avf")
690 # We will add excluded NICs.
691 test_tag_array+=("${exclude_nics[@]/#/!NIC_}")
695 # We will prefix with perftest to prevent running other tests
698 if [[ "${TEST_CODE}" == "vpp-"* ]]; then
699 # Automatic prefixing for VPP jobs to limit the NIC used and
700 # traffic evaluation to MRR.
701 prefix="${prefix}mrrANDnic_intel-x710AND"
703 for tag in "${test_tag_array[@]}"; do
704 if [[ ${tag} == "!"* ]]; then
705 # Exclude tags are not prefixed.
708 TAGS+=("${prefix}${tag}")
714 function select_vpp_device_tags () {
719 # - TEST_CODE - String affecting test selection, usually jenkins job name.
720 # - TEST_TAG_STRING - String selecting tags, from gerrit comment.
723 # - TAGS - Array of processed tag boolean expressions.
725 case "${TEST_CODE}" in
726 # Select specific performance tests based on jenkins job type variable.
728 if [[ -z "${TEST_TAG_STRING-}" ]]; then
729 # If nothing is specified, we will run pre-selected tests by
730 # following tags. Items of array will be concatenated by OR
731 # in Robot Framework.
734 # If trigger contains tags, split them into array.
735 test_tag_array=(${TEST_TAG_STRING//:/ })
742 # We will prefix with perftest to prevent running other tests
744 prefix="devicetestAND"
745 if [[ "${TEST_CODE}" == "vpp-"* ]]; then
746 # Automatic prefixing for VPP jobs to limit testing.
749 for tag in "${test_tag_array[@]}"; do
750 if [[ ${tag} == "!"* ]]; then
751 # Exclude tags are not prefixed.
754 TAGS+=("${prefix}${tag}")
760 function select_topology () {
765 # - NODENESS - Node multiplicity of testbed, either "2n" or "3n".
766 # - FLAVOR - Node flavor string, currently either "hsw" or "skx".
767 # - CSIT_DIR - Path to existing root of local CSIT git repository.
768 # - TOPOLOGIES_DIR - Path to existing directory with available topologies.
770 # - TOPOLOGIES - Array of paths to suitable topology yaml files.
771 # - TOPOLOGIES_TAGS - Tag expression selecting tests for the topology.
773 # - die - Print to stderr and exit.
775 case_text="${NODENESS}_${FLAVOR}"
776 case "${case_text}" in
779 "${TOPOLOGIES_DIR}/vpp_device.template"
781 TOPOLOGIES_TAGS="2_node_single_link_topo"
785 "${TOPOLOGIES_DIR}/vpp_device.template"
787 TOPOLOGIES_TAGS="2_node_single_link_topo"
791 "${TOPOLOGIES_DIR}/lf_2n_skx_testbed21.yaml"
792 #"${TOPOLOGIES_DIR}/lf_2n_skx_testbed22.yaml"
793 "${TOPOLOGIES_DIR}/lf_2n_skx_testbed23.yaml"
794 "${TOPOLOGIES_DIR}/lf_2n_skx_testbed24.yaml"
796 TOPOLOGIES_TAGS="2_node_*_link_topo"
800 "${TOPOLOGIES_DIR}/lf_3n_skx_testbed31.yaml"
801 "${TOPOLOGIES_DIR}/lf_3n_skx_testbed32.yaml"
803 TOPOLOGIES_TAGS="3_node_*_link_topo"
807 "${TOPOLOGIES_DIR}/lf_3n_hsw_testbed1.yaml"
808 "${TOPOLOGIES_DIR}/lf_3n_hsw_testbed2.yaml"
809 "${TOPOLOGIES_DIR}/lf_3n_hsw_testbed3.yaml"
811 TOPOLOGIES_TAGS="3_node_single_link_topo"
814 # No falling back to 3n_hsw default, that should have been done
815 # by the function which has set NODENESS and FLAVOR.
816 die "Unknown specification: ${case_text}"
819 if [[ -z "${TOPOLOGIES-}" ]]; then
820 die "No applicable topology found!"
825 function untrap_and_unreserve_testbed () {
826 # Use this as a trap function to ensure testbed does not remain reserved.
827 # Perhaps call directly before script exit, to free testbed for other jobs.
828 # This function is smart enough to avoid multiple unreservations (so safe).
829 # Topo cleanup is executed (call it best practice), ignoring failures.
832 # - default message to die with if testbed might remain reserved.
834 # - ${1} - Message to die with if unreservation fails. Default hardcoded.
835 # Variables read (by inner function):
836 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
837 # - PYTHON_SCRIPTS_DIR - Path to directory holding Python scripts.
839 # - WORKING_TOPOLOGY - Set to empty string on successful unreservation.
841 # - EXIT - Failure to untrap is reported, but ignored otherwise.
843 # - die - Print to stderr and exit.
846 set +eu # We do not want to exit early in a "teardown" function.
847 trap - EXIT || echo "Trap deactivation failed, continuing anyway."
848 wt="${WORKING_TOPOLOGY}" # Just to avoid too long lines.
849 if [[ -z "${wt-}" ]]; then
851 warn "Testbed looks unreserved already. Trap removal failed before?"
854 python "${PYTHON_SCRIPTS_DIR}/topo_reservation.py" -c -t "${wt}" || {
855 die "${1:-FAILED TO UNRESERVE, FIX MANUALLY.}" 2
864 # Print the message to standard error.
867 # - ${@} - The text of the message.