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 comment="${GERRIT_EVENT_COMMENT_TEXT}"
419 # As "perftest" can be followed by something, we substitute it.
420 comment="${comment/perftest-2n/perftest}"
421 comment="${comment/perftest-3n/perftest}"
422 comment="${comment/perftest-hsw/perftest}"
423 comment="${comment/perftest-skx/perftest}"
424 tag_string="$(echo "${comment}" \
425 | grep -oE '(perftest$|perftest[[:space:]].+$)' || true)"
426 # Set test tags as string.
427 TEST_TAG_STRING="${tag_string#$"perftest"}"
430 die "Unknown specification: ${TEST_CODE}"
436 function reserve_testbed () {
440 # Reserve physical testbed, perform cleanup, register trap to unreserve.
443 # - TOPOLOGIES - Array of paths to topology yaml to attempt reservation on.
444 # - PYTHON_SCRIPTS_DIR - Path to directory holding the reservation script.
446 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
448 # - die - Print to stderr and exit.
450 # - EXIT - Calls cancel_all for ${WORKING_TOPOLOGY}.
453 for topo in "${TOPOLOGIES[@]}"; do
455 python "${PYTHON_SCRIPTS_DIR}/topo_reservation.py" -t "${topo}"
458 if [[ "${result}" == "0" ]]; then
459 WORKING_TOPOLOGY="${topo}"
460 echo "Reserved: ${WORKING_TOPOLOGY}"
461 trap "untrap_and_unreserve_testbed" EXIT || {
462 message="TRAP ATTEMPT AND UNRESERVE FAILED, FIX MANUALLY."
463 untrap_and_unreserve_testbed "${message}" || {
464 die "Teardown should have died, not failed."
466 die "Trap attempt failed, unreserve succeeded. Aborting."
469 die "Testbed cleanup failed."
475 if [[ -n "${WORKING_TOPOLOGY-}" ]]; then
476 # Exit the infinite while loop if we made a reservation.
480 # Wait ~3minutes before next try.
481 sleep_time="$[ ( $RANDOM % 20 ) + 180 ]s" || {
482 die "Sleep time calculation failed."
484 echo "Sleeping ${sleep_time}"
485 sleep "${sleep_time}" || die "Sleep failed."
490 function run_pybot () {
494 # Currently, VPP-1361 causes occasional test failures.
495 # If real result is more important than time, we can retry few times.
496 # TODO: We should be retrying on test case level instead.
499 # - ${1} - Optional number of pybot invocations to try to avoid failures.
502 # - CSIT_DIR - Path to existing root of local CSIT git repository.
503 # - ARCHIVE_DIR - Path to store robot result files in.
504 # - PYBOT_ARGS, EXPANDED_TAGS - See compose_pybot_arguments.sh
506 # - PYBOT_EXIT_STATUS - Exit status of most recent pybot invocation.
508 # - die - Print to stderr and exit.
510 # Set ${tries} as an integer variable, to fail on non-numeric input.
511 local -i "tries" || die "Setting type of variable failed."
512 tries="${1:-1}" || die "Argument evaluation failed."
513 all_options=("--outputdir" "${ARCHIVE_DIR}" "${PYBOT_ARGS[@]}")
514 all_options+=("${EXPANDED_TAGS[@]}")
517 if [[ "${tries}" -le 0 ]]; then
520 tries="$((${tries} - 1))"
522 pushd "${CSIT_DIR}" || die "Change directory operation failed."
524 # TODO: Make robot tests not require "$(pwd)" == "${CSIT_DIR}".
525 pybot "${all_options[@]}" "${CSIT_DIR}/tests/"
526 PYBOT_EXIT_STATUS="$?"
528 popd || die "Change directory operation failed."
529 if [[ "${PYBOT_EXIT_STATUS}" == "0" ]]; then
536 function select_tags () {
541 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
542 # - TEST_CODE - String affecting test selection, usually jenkins job name.
543 # - TEST_TAG_STRING - String selecting tags, from gerrit comment.
545 # - TOPOLOGIES_DIR - Path to existing directory with available tpologies.
547 # - TAGS - Array of processed tag boolean expressions.
550 # All topologies NICs
551 available=$(grep -hoPR "model: \K.*" "${TOPOLOGIES_DIR}"/* | sort -u)
552 # Selected topology NICs
553 reserved=$(grep -hoPR "model: \K.*" "${WORKING_TOPOLOGY}" | sort -u)
554 # All topologies NICs - Selected topology NICs
555 exclude_nics=($(comm -13 <(echo "${reserved}") <(echo "${available}")))
557 case "${TEST_CODE}" in
558 # Select specific performance tests based on jenkins job type variable.
560 test_tag_array=("ndrpdrAND64bAND1c"
564 test_tag_array=(# vic
565 "mrrANDnic_cisco-vic-1227AND64b"
566 "mrrANDnic_cisco-vic-1385AND64b"
568 "mrrANDmemifANDethAND64b"
569 "mrrANDmemifANDethANDimix"
573 "mrrANDip4baseAND64b"
575 "mrrANDip4fwdANDfib_2mAND64b"
577 "mrrANDip4fwdANDfib_200kANDnic_intel-*710AND64b"
579 "mrrANDip4fwdANDfib_20kANDnic_intel-*710AND64b"
581 "mrrANDip4fwdANDacl1AND10k_flowsAND64b"
582 "mrrANDip4fwdANDacl50AND10k_flowsAND64b"
584 "mrrANDip4fwdANDnat44ANDbaseAND64b"
585 "mrrANDip4fwdANDnat44ANDsrc_user_4000AND64b"
587 "mrrANDip4fwdANDfeatureANDnic_intel-*710AND64b"
588 # TODO: Remove when tags in
589 # tests/vpp/perf/ip4/*-ipolicemarkbase-*.robot
591 "mrrANDip4fwdANDpolice_markANDnic_intel-*710AND64b"
593 "mrrANDip4fwdANDencapANDip6unrlayANDip4ovrlayANDnic_intel-x520-da2AND64b"
594 "mrrANDip4fwdANDencapANDnic_intel-*710AND64b"
595 "mrrANDl2ovrlayANDencapANDnic_intel-*710AND64b"
597 "mrrANDip6baseANDethAND78b"
599 "mrrANDip6fwdANDfeatureANDnic_intel-*710AND78b"
601 "mrrANDip6fwdANDfib_2mANDnic_intel-*710AND78b"
603 "mrrANDip6fwdANDfib_200kANDnic_intel-*710AND78b"
605 "mrrANDip6fwdANDfib_20kANDnic_intel-*710AND78b"
607 "mrrANDip6fwdANDencapANDnic_intel-x520-da2AND78b"
609 "mrrANDl2xcfwdANDbaseAND64b"
611 "mrrANDl2xcANDacl1AND10k_flowsAND64b"
612 "mrrANDl2xcANDacl50AND10k_flowsAND64b"
614 "mrrANDl2xcANDfib_2mAND64b"
615 # l2xc scale FIB 200k
616 "mrrANDl2xcANDfib_200kANDnic_intel-*710AND64b"
618 "mrrANDl2xcANDfib_20kANDnic_intel-*710AND64b"
620 "mrrANDl2bdmaclrnANDbaseAND64b"
622 "mrrANDl2bdmaclrnANDacl1AND10k_flowsAND64b"
623 "mrrANDl2bdmaclrnANDacl50AND10k_flowsAND64b"
625 "mrrANDl2bdmaclrnANDfib_1mAND64b"
626 # l2bd scale FIB 200k
627 "mrrANDl2bdmaclrnANDfib_100kANDnic_intel-*710AND64b"
629 "mrrANDl2bdmaclrnANDfib_10kANDnic_intel-*710AND64b"
631 "mrrANDl2patchAND64b"
633 "mrrANDsrv6ANDnic_intel-x520-da2AND78b"
635 "mrrANDvtsANDnic_intel-x520-da2AND114b"
637 "mrrANDvhostANDl2xcfwdANDbaseAND64b"
638 "mrrANDvhostANDl2xcfwdANDbaseANDimix"
640 "mrrANDvhostANDl2bdmaclrnANDbaseAND64b"
641 "mrrANDvhostANDl2bdmaclrnANDbaseANDimix"
643 "mrrANDvhostANDip4fwdANDbaseAND64b"
644 "mrrANDvhostANDip4fwdANDbaseANDimix"
648 "!mrrANDip6baseANDdot1qAND78b"
649 "!vhost_256ANDnic_intel-x520-da2"
650 "!vhostANDnic_intel-xl710"
656 test_tag_array=(# NF Density tests
657 "mrrANDnf_densityAND64b"
658 "mrrANDnf_densityANDimix"
663 if [[ -z "${TEST_TAG_STRING-}" ]]; then
664 # If nothing is specified, we will run pre-selected tests by
666 test_tag_array=("mrrANDnic_intel-x710AND1cAND64bANDip4base"
667 "mrrANDnic_intel-x710AND1cAND78bANDip6base"
668 "mrrANDnic_intel-x710AND1cAND64bANDl2bdbase"
669 "mrrANDnic_intel-x710AND1cAND64bANDl2xcbase"
672 # If trigger contains tags, split them into array.
673 test_tag_array=(${TEST_TAG_STRING//:/ })
678 # Blacklisting certain tags per topology.
679 case "${TEST_CODE}" in
681 test_tag_array+=("!drv_avf")
684 test_tag_array+=("!ipsechw")
687 test_tag_array+=("!ipsechw")
690 # Default to 3n-hsw due to compatibility.
691 test_tag_array+=("!drv_avf")
695 # We will add excluded NICs.
696 test_tag_array+=("${exclude_nics[@]/#/!NIC_}")
700 # We will prefix with perftest to prevent running other tests
703 if [[ "${TEST_CODE}" == "vpp-"* ]]; then
704 # Automatic prefixing for VPP jobs to limit the NIC used and
705 # traffic evaluation to MRR.
706 prefix="${prefix}mrrANDnic_intel-x710AND"
708 for tag in "${test_tag_array[@]}"; do
709 if [[ ${tag} == "!"* ]]; then
710 # Exclude tags are not prefixed.
713 TAGS+=("${prefix}${tag}")
719 function select_vpp_device_tags () {
724 # - TEST_CODE - String affecting test selection, usually jenkins job name.
725 # - TEST_TAG_STRING - String selecting tags, from gerrit comment.
728 # - TAGS - Array of processed tag boolean expressions.
730 case "${TEST_CODE}" in
731 # Select specific performance tests based on jenkins job type variable.
733 if [[ -z "${TEST_TAG_STRING-}" ]]; then
734 # If nothing is specified, we will run pre-selected tests by
735 # following tags. Items of array will be concatenated by OR
736 # in Robot Framework.
739 # If trigger contains tags, split them into array.
740 test_tag_array=(${TEST_TAG_STRING//:/ })
747 # We will prefix with perftest to prevent running other tests
749 prefix="devicetestAND"
750 if [[ "${TEST_CODE}" == "vpp-"* ]]; then
751 # Automatic prefixing for VPP jobs to limit testing.
754 for tag in "${test_tag_array[@]}"; do
755 if [[ ${tag} == "!"* ]]; then
756 # Exclude tags are not prefixed.
759 TAGS+=("${prefix}${tag}")
765 function select_topology () {
770 # - NODENESS - Node multiplicity of testbed, either "2n" or "3n".
771 # - FLAVOR - Node flavor string, currently either "hsw" or "skx".
772 # - CSIT_DIR - Path to existing root of local CSIT git repository.
773 # - TOPOLOGIES_DIR - Path to existing directory with available topologies.
775 # - TOPOLOGIES - Array of paths to suitable topology yaml files.
776 # - TOPOLOGIES_TAGS - Tag expression selecting tests for the topology.
778 # - die - Print to stderr and exit.
780 case_text="${NODENESS}_${FLAVOR}"
781 case "${case_text}" in
784 "${TOPOLOGIES_DIR}/vpp_device.template"
786 TOPOLOGIES_TAGS="2_node_single_link_topo"
790 "${TOPOLOGIES_DIR}/vpp_device.template"
792 TOPOLOGIES_TAGS="2_node_single_link_topo"
796 "${TOPOLOGIES_DIR}/lf_2n_skx_testbed21.yaml"
797 #"${TOPOLOGIES_DIR}/lf_2n_skx_testbed22.yaml"
798 "${TOPOLOGIES_DIR}/lf_2n_skx_testbed23.yaml"
799 "${TOPOLOGIES_DIR}/lf_2n_skx_testbed24.yaml"
801 TOPOLOGIES_TAGS="2_node_*_link_topo"
805 "${TOPOLOGIES_DIR}/lf_3n_skx_testbed31.yaml"
806 "${TOPOLOGIES_DIR}/lf_3n_skx_testbed32.yaml"
808 TOPOLOGIES_TAGS="3_node_*_link_topo"
812 "${TOPOLOGIES_DIR}/lf_3n_hsw_testbed1.yaml"
813 "${TOPOLOGIES_DIR}/lf_3n_hsw_testbed2.yaml"
814 "${TOPOLOGIES_DIR}/lf_3n_hsw_testbed3.yaml"
816 TOPOLOGIES_TAGS="3_node_single_link_topo"
819 # No falling back to 3n_hsw default, that should have been done
820 # by the function which has set NODENESS and FLAVOR.
821 die "Unknown specification: ${case_text}"
824 if [[ -z "${TOPOLOGIES-}" ]]; then
825 die "No applicable topology found!"
830 function untrap_and_unreserve_testbed () {
831 # Use this as a trap function to ensure testbed does not remain reserved.
832 # Perhaps call directly before script exit, to free testbed for other jobs.
833 # This function is smart enough to avoid multiple unreservations (so safe).
834 # Topo cleanup is executed (call it best practice), ignoring failures.
837 # - default message to die with if testbed might remain reserved.
839 # - ${1} - Message to die with if unreservation fails. Default hardcoded.
840 # Variables read (by inner function):
841 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
842 # - PYTHON_SCRIPTS_DIR - Path to directory holding Python scripts.
844 # - WORKING_TOPOLOGY - Set to empty string on successful unreservation.
846 # - EXIT - Failure to untrap is reported, but ignored otherwise.
848 # - die - Print to stderr and exit.
851 set +eu # We do not want to exit early in a "teardown" function.
852 trap - EXIT || echo "Trap deactivation failed, continuing anyway."
853 wt="${WORKING_TOPOLOGY}" # Just to avoid too long lines.
854 if [[ -z "${wt-}" ]]; then
856 warn "Testbed looks unreserved already. Trap removal failed before?"
859 python "${PYTHON_SCRIPTS_DIR}/topo_reservation.py" -c -t "${wt}" || {
860 die "${1:-FAILED TO UNRESERVE, FIX MANUALLY.}" 2
869 # Print the message to standard error.
872 # - ${@} - The text of the message.