1 # Copyright (c) 2019 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 () {
93 # Update virtualenv pip package, delete and create virtualenv directory,
94 # activate the virtualenv, install requirements, set PYTHONPATH.
97 # - ${1} - Path to existing directory for creating virtualenv in.
98 # If missing or empty, ${CSIT_DIR} is used.
99 # - ${2} - Path to requirements file, ${CSIT_DIR}/requirements.txt if empty.
101 # - CSIT_DIR - Path to existing root of local CSIT git repository.
102 # Variables exported:
103 # - PYTHONPATH - CSIT_DIR, as CSIT Python scripts usually need this.
105 # - die - Print to stderr and exit.
107 # TODO: Do we want the callers to be able to set the env dir name?
108 # TODO: + In that case, do we want to support env switching?
109 # TODO: + In that case we want to make env_dir global.
110 # TODO: Do we want the callers to override PYTHONPATH loaction?
112 root_path="${1-$CSIT_DIR}"
113 env_dir="${root_path}/env"
114 req_path=${2-$CSIT_DIR/requirements.txt}
115 rm -rf "${env_dir}" || die "Failed to clean previous virtualenv."
116 pip install --upgrade virtualenv || {
117 die "Virtualenv package install failed."
119 virtualenv "${env_dir}" || {
120 die "Virtualenv creation failed."
123 source "${env_dir}/bin/activate" || die "Virtualenv activation failed."
125 pip install --upgrade -r "${req_path}" || {
126 die "Requirements installation failed."
128 # Most CSIT Python scripts assume PYTHONPATH is set and exported.
129 export PYTHONPATH="${root_path}" || die "Export failed."
133 function check_download_dir () {
137 # Fail if there are no files visible in ${DOWNLOAD_DIR}.
138 # TODO: Do we need this as a function, if it is (almost) a one-liner?
141 # - DOWNLOAD_DIR - Path to directory pybot takes the build to test from.
143 # - ${DOWNLOAD_DIR} - Has to be non-empty to proceed.
145 # - die - Print to stderr and exit.
147 if [[ ! "$(ls -A "${DOWNLOAD_DIR}")" ]]; then
148 die "No artifacts downloaded!"
153 function cleanup_topo () {
158 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
159 # - PYTHON_SCRIPTS_DIR - Path to directory holding the reservation script.
161 python "${PYTHON_SCRIPTS_DIR}/topo_cleanup.py" -t "${WORKING_TOPOLOGY}"
162 # Not using "|| die" as some callers might want to ignore errors,
163 # e.g. in teardowns, such as unreserve.
167 function common_dirs () {
172 # - BASH_FUNCTION_DIR - Path to existing directory this file is located in.
173 # - CSIT_DIR - Path to existing root of local CSIT git repository.
174 # - TOPOLOGIES_DIR - Path to existing directory with available tpologies.
175 # - RESOURCES_DIR - Path to existing CSIT subdirectory "resources".
176 # - TOOLS_DIR - Path to existing resources subdirectory "tools".
177 # - PYTHON_SCRIPTS_DIR - Path to existing tools subdirectory "scripts".
178 # - ARCHIVE_DIR - Path to created CSIT subdirectory "archive".
179 # - DOWNLOAD_DIR - Path to created CSIT subdirectory "download_dir".
181 # - die - Print to stderr and exit.
183 BASH_FUNCTION_DIR="$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")" || {
184 die "Some error during localizing this source directory."
186 # Current working directory could be in a different repo, e.g. VPP.
187 pushd "${BASH_FUNCTION_DIR}" || die "Pushd failed"
188 CSIT_DIR="$(readlink -e "$(git rev-parse --show-toplevel)")" || {
189 die "Readlink or git rev-parse failed."
191 popd || die "Popd failed."
192 TOPOLOGIES_DIR="$(readlink -e "${CSIT_DIR}/topologies/available")" || {
193 die "Readlink failed."
195 RESOURCES_DIR="$(readlink -e "${CSIT_DIR}/resources")" || {
196 die "Readlink failed."
198 TOOLS_DIR="$(readlink -e "${RESOURCES_DIR}/tools")" || {
199 die "Readlink failed."
201 PYTHON_SCRIPTS_DIR="$(readlink -e "${TOOLS_DIR}/scripts")" || {
202 die "Readlink failed."
205 ARCHIVE_DIR="$(readlink -f "${CSIT_DIR}/archive")" || {
206 die "Readlink failed."
208 mkdir -p "${ARCHIVE_DIR}" || die "Mkdir failed."
209 DOWNLOAD_DIR="$(readlink -f "${CSIT_DIR}/download_dir")" || {
210 die "Readlink failed."
212 mkdir -p "${DOWNLOAD_DIR}" || die "Mkdir failed."
216 function compose_pybot_arguments () {
221 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
222 # - DUT - CSIT test/ subdirectory, set while processing tags.
223 # - TAGS - Array variable holding selected tag boolean expressions.
224 # - TOPOLOGIES_TAGS - Tag boolean expression filtering tests for topology.
225 # - TEST_CODE - The test selection string from environment or argument.
227 # - PYBOT_ARGS - String holding part of all arguments for pybot.
228 # - EXPANDED_TAGS - Array of strings pybot arguments compiled from tags.
230 # No explicit check needed with "set -u".
231 PYBOT_ARGS=("--loglevel" "TRACE")
232 PYBOT_ARGS+=("--variable" "TOPOLOGY_PATH:${WORKING_TOPOLOGY}")
234 case "${TEST_CODE}" in
236 PYBOT_ARGS+=("--suite" "tests.${DUT}.device")
239 PYBOT_ARGS+=("--suite" "tests.${DUT}.func")
242 PYBOT_ARGS+=("--suite" "tests.${DUT}.perf")
245 die "Unknown specification: ${TEST_CODE}"
249 for tag in "${TAGS[@]}"; do
250 if [[ ${tag} == "!"* ]]; then
251 EXPANDED_TAGS+=("--exclude" "${tag#$"!"}")
253 EXPANDED_TAGS+=("--include" "${TOPOLOGIES_TAGS}AND${tag}")
259 function copy_archives () {
264 # - WORKSPACE - Jenkins workspace, copy only if the value is not empty.
265 # Can be unset, then it speeds up manual testing.
266 # - ARCHIVE_DIR - Path to directory with content to be copied.
267 # Directories updated:
268 # - ${WORKSPACE}/archives/ - Created if does not exist.
269 # Content of ${ARCHIVE_DIR}/ is copied here.
271 # - die - Print to stderr and exit.
273 # We will create additional archive if workspace variable is set.
274 # This way if script is running in jenkins all will be
275 # automatically archived to logs.fd.io.
276 if [[ -n "${WORKSPACE-}" ]]; then
277 mkdir -p "${WORKSPACE}/archives/" || die "Archives dir create failed."
278 cp -rf "${ARCHIVE_DIR}"/* "${WORKSPACE}/archives" || die "Copy failed."
283 function deactivate_docker_topology () {
284 # Deactivate virtual vpp-device topology by removing containers.
287 # - NODENESS - Node multiplicity of desired testbed.
288 # - FLAVOR - Node flavor string, usually describing the processor.
292 case_text="${NODENESS}_${FLAVOR}"
293 case "${case_text}" in
295 hostname=$(grep search /etc/resolv.conf | cut -d' ' -f3)
296 ssh="ssh root@${hostname} -p 6022"
297 env_vars="$(env | grep CSIT_ | tr '\n' ' ' )"
298 ${ssh} "$(declare -f); deactivate_wrapper ${env_vars}" || {
299 die "Topology cleanup via shim-dcr failed!"
304 clean_environment || {
305 die "Topology cleanup locally failed!"
310 die "Unknown specification: ${case_text}!"
316 # Print the message to standard error end exit with error code specified
317 # by the second argument.
320 # - The default error message.
322 # - ${1} - The whole error message, be sure to quote. Optional
323 # - ${2} - the code to exit with, default: 1.
327 warn "${1:-Unspecified run-time error occurred!}"
332 function die_on_pybot_error () {
336 # Source this fragment if you want to abort on any failed test case.
339 # - PYBOT_EXIT_STATUS - Set by a pybot running fragment.
341 # - die - Print to stderr and exit.
343 if [[ "${PYBOT_EXIT_STATUS}" != "0" ]]; then
344 die "${PYBOT_EXIT_STATUS}" "Test failures are present!"
349 function get_test_code () {
354 # - ${1} - Optional, argument of entry script (or empty as unset).
355 # Test code value to override job name from environment.
357 # - JOB_NAME - String affecting test selection, default if not argument.
359 # - TEST_CODE - The test selection string from environment or argument.
360 # - NODENESS - Node multiplicity of desired testbed.
361 # - FLAVOR - Node flavor string, usually describing the processor.
363 TEST_CODE="${1-}" || die "Reading optional argument failed, somehow."
364 if [[ -z "${TEST_CODE}" ]]; then
365 TEST_CODE="${JOB_NAME-}" || die "Reading job name failed, somehow."
368 case "${TEST_CODE}" in
386 # Fallback to 3-node Haswell by default (backward compatibility)
394 function get_test_tag_string () {
399 # - GERRIT_EVENT_TYPE - Event type set by gerrit, can be unset.
400 # - GERRIT_EVENT_COMMENT_TEXT - Comment text, read for "comment-added" type.
401 # - TEST_CODE - The test selection string from environment or argument.
403 # - TEST_TAG_STRING - The string following "perftest" in gerrit comment,
406 # TODO: ci-management scripts no longer need to perform this.
409 if [[ "${GERRIT_EVENT_TYPE-}" == "comment-added" ]]; then
410 case "${TEST_CODE}" in
412 # On parsing error, ${trigger} stays empty.
413 trigger="$(echo "${GERRIT_EVENT_COMMENT_TEXT}" \
414 | grep -oE '(devicetest$|devicetest[[:space:]].+$)')" \
416 # Set test tags as string.
417 TEST_TAG_STRING="${trigger#$"devicetest"}"
420 # On parsing error, ${trigger} stays empty.
421 comment="${GERRIT_EVENT_COMMENT_TEXT}"
422 # As "perftest" can be followed by something, we substitute it.
423 comment="${comment/perftest-2n/perftest}"
424 comment="${comment/perftest-3n/perftest}"
425 comment="${comment/perftest-hsw/perftest}"
426 comment="${comment/perftest-skx/perftest}"
427 tag_string="$(echo "${comment}" \
428 | grep -oE '(perftest$|perftest[[:space:]].+$)' || true)"
429 # Set test tags as string.
430 TEST_TAG_STRING="${tag_string#$"perftest"}"
433 die "Unknown specification: ${TEST_CODE}"
439 function reserve_testbed () {
443 # Reserve physical testbed, perform cleanup, register trap to unreserve.
446 # - TOPOLOGIES - Array of paths to topology yaml to attempt reservation on.
447 # - PYTHON_SCRIPTS_DIR - Path to directory holding the reservation script.
449 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
451 # - die - Print to stderr and exit.
453 # - EXIT - Calls cancel_all for ${WORKING_TOPOLOGY}.
456 for topo in "${TOPOLOGIES[@]}"; do
458 python "${PYTHON_SCRIPTS_DIR}/topo_reservation.py" -t "${topo}"
461 if [[ "${result}" == "0" ]]; then
462 WORKING_TOPOLOGY="${topo}"
463 echo "Reserved: ${WORKING_TOPOLOGY}"
464 trap "untrap_and_unreserve_testbed" EXIT || {
465 message="TRAP ATTEMPT AND UNRESERVE FAILED, FIX MANUALLY."
466 untrap_and_unreserve_testbed "${message}" || {
467 die "Teardown should have died, not failed."
469 die "Trap attempt failed, unreserve succeeded. Aborting."
472 die "Testbed cleanup failed."
478 if [[ -n "${WORKING_TOPOLOGY-}" ]]; then
479 # Exit the infinite while loop if we made a reservation.
483 # Wait ~3minutes before next try.
484 sleep_time="$[ ( $RANDOM % 20 ) + 180 ]s" || {
485 die "Sleep time calculation failed."
487 echo "Sleeping ${sleep_time}"
488 sleep "${sleep_time}" || die "Sleep failed."
493 function run_pybot () {
497 # Currently, VPP-1361 causes occasional test failures.
498 # If real result is more important than time, we can retry few times.
499 # TODO: We should be retrying on test case level instead.
502 # - ${1} - Optional number of pybot invocations to try to avoid failures.
505 # - CSIT_DIR - Path to existing root of local CSIT git repository.
506 # - ARCHIVE_DIR - Path to store robot result files in.
507 # - PYBOT_ARGS, EXPANDED_TAGS - See compose_pybot_arguments.sh
509 # - PYBOT_EXIT_STATUS - Exit status of most recent pybot invocation.
511 # - die - Print to stderr and exit.
513 # Set ${tries} as an integer variable, to fail on non-numeric input.
514 local -i "tries" || die "Setting type of variable failed."
515 tries="${1:-1}" || die "Argument evaluation failed."
516 all_options=("--outputdir" "${ARCHIVE_DIR}" "${PYBOT_ARGS[@]}")
517 all_options+=("${EXPANDED_TAGS[@]}")
520 if [[ "${tries}" -le 0 ]]; then
523 tries="$((${tries} - 1))"
525 pushd "${CSIT_DIR}" || die "Change directory operation failed."
527 # TODO: Make robot tests not require "$(pwd)" == "${CSIT_DIR}".
528 pybot "${all_options[@]}" "${CSIT_DIR}/tests/"
529 PYBOT_EXIT_STATUS="$?"
531 popd || die "Change directory operation failed."
532 if [[ "${PYBOT_EXIT_STATUS}" == "0" ]]; then
539 function select_tags () {
544 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
545 # - TEST_CODE - String affecting test selection, usually jenkins job name.
546 # - TEST_TAG_STRING - String selecting tags, from gerrit comment.
548 # - TOPOLOGIES_DIR - Path to existing directory with available tpologies.
550 # - TAGS - Array of processed tag boolean expressions.
553 # All topologies NICs
554 available=$(grep -hoPR "model: \K.*" "${TOPOLOGIES_DIR}"/* | sort -u)
555 # Selected topology NICs
556 reserved=$(grep -hoPR "model: \K.*" "${WORKING_TOPOLOGY}" | sort -u)
557 # All topologies NICs - Selected topology NICs
558 exclude_nics=($(comm -13 <(echo "${reserved}") <(echo "${available}")))
560 case "${TEST_CODE}" in
561 # Select specific performance tests based on jenkins job type variable.
563 test_tag_array=("ndrpdrAND64bAND1c"
567 test_tag_array=(# vic
568 "mrrANDnic_cisco-vic-1227AND64b"
569 "mrrANDnic_cisco-vic-1385AND64b"
571 "mrrANDmemifANDethAND64b"
572 "mrrANDmemifANDethANDimix"
576 "mrrANDip4baseAND64b"
578 "mrrANDip4fwdANDfib_2mAND64b"
580 "mrrANDip4fwdANDfib_200kANDnic_intel-*710AND64b"
582 "mrrANDip4fwdANDfib_20kANDnic_intel-*710AND64b"
584 "mrrANDip4fwdANDacl1AND10k_flowsAND64b"
585 "mrrANDip4fwdANDacl50AND10k_flowsAND64b"
587 "mrrANDip4fwdANDnat44ANDbaseAND64b"
588 "mrrANDip4fwdANDnat44ANDsrc_user_4000AND64b"
590 "mrrANDip4fwdANDfeatureANDnic_intel-*710AND64b"
591 # TODO: Remove when tags in
592 # tests/vpp/perf/ip4/*-ipolicemarkbase-*.robot
594 "mrrANDip4fwdANDpolice_markANDnic_intel-*710AND64b"
596 "mrrANDip4fwdANDencapANDip6unrlayANDip4ovrlayANDnic_intel-x520-da2AND64b"
597 "mrrANDip4fwdANDencapANDnic_intel-*710AND64b"
598 "mrrANDl2ovrlayANDencapANDnic_intel-*710AND64b"
600 "mrrANDip6baseANDethAND78b"
602 "mrrANDip6fwdANDfeatureANDnic_intel-*710AND78b"
604 "mrrANDip6fwdANDfib_2mANDnic_intel-*710AND78b"
606 "mrrANDip6fwdANDfib_200kANDnic_intel-*710AND78b"
608 "mrrANDip6fwdANDfib_20kANDnic_intel-*710AND78b"
610 "mrrANDip6fwdANDencapANDnic_intel-x520-da2AND78b"
612 "mrrANDl2xcfwdANDbaseAND64b"
614 "mrrANDl2xcANDacl1AND10k_flowsAND64b"
615 "mrrANDl2xcANDacl50AND10k_flowsAND64b"
617 "mrrANDl2xcANDfib_2mAND64b"
618 # l2xc scale FIB 200k
619 "mrrANDl2xcANDfib_200kANDnic_intel-*710AND64b"
621 "mrrANDl2xcANDfib_20kANDnic_intel-*710AND64b"
623 "mrrANDl2bdmaclrnANDbaseAND64b"
625 "mrrANDl2bdmaclrnANDacl1AND10k_flowsAND64b"
626 "mrrANDl2bdmaclrnANDacl50AND10k_flowsAND64b"
628 "mrrANDl2bdmaclrnANDfib_1mAND64b"
629 # l2bd scale FIB 200k
630 "mrrANDl2bdmaclrnANDfib_100kANDnic_intel-*710AND64b"
632 "mrrANDl2bdmaclrnANDfib_10kANDnic_intel-*710AND64b"
634 "mrrANDl2patchAND64b"
636 "mrrANDsrv6ANDnic_intel-x520-da2AND78b"
638 "mrrANDvtsANDnic_intel-x520-da2AND114b"
640 "mrrANDvhostANDl2xcfwdANDbaseAND64b"
641 "mrrANDvhostANDl2xcfwdANDbaseANDimix"
643 "mrrANDvhostANDl2bdmaclrnANDbaseAND64b"
644 "mrrANDvhostANDl2bdmaclrnANDbaseANDimix"
646 "mrrANDvhostANDip4fwdANDbaseAND64b"
647 "mrrANDvhostANDip4fwdANDbaseANDimix"
651 "!mrrANDip6baseANDdot1qAND78b"
652 "!vhost_256ANDnic_intel-x520-da2"
653 "!vhostANDnic_intel-xl710"
659 test_tag_array=(# NF Density tests
660 "mrrANDnf_densityAND64b"
661 "mrrANDnf_densityANDimix"
666 if [[ -z "${TEST_TAG_STRING-}" ]]; then
667 # If nothing is specified, we will run pre-selected tests by
669 test_tag_array=("mrrANDnic_intel-x710AND1cAND64bANDip4base"
670 "mrrANDnic_intel-x710AND1cAND78bANDip6base"
671 "mrrANDnic_intel-x710AND1cAND64bANDl2bdbase"
672 "mrrANDnic_intel-x710AND1cAND64bANDl2xcbase"
675 # If trigger contains tags, split them into array.
676 test_tag_array=(${TEST_TAG_STRING//:/ })
681 # Blacklisting certain tags per topology.
682 case "${TEST_CODE}" in
684 test_tag_array+=("!drv_avf")
687 test_tag_array+=("!ipsechw")
690 test_tag_array+=("!ipsechw")
693 # Default to 3n-hsw due to compatibility.
694 test_tag_array+=("!drv_avf")
698 # We will add excluded NICs.
699 test_tag_array+=("${exclude_nics[@]/#/!NIC_}")
703 # We will prefix with perftest to prevent running other tests
706 if [[ "${TEST_CODE}" == "vpp-"* ]]; then
707 # Automatic prefixing for VPP jobs to limit the NIC used and
708 # traffic evaluation to MRR.
709 prefix="${prefix}mrrANDnic_intel-x710AND"
711 for tag in "${test_tag_array[@]}"; do
712 if [[ ${tag} == "!"* ]]; then
713 # Exclude tags are not prefixed.
716 TAGS+=("${prefix}${tag}")
722 function select_vpp_device_tags () {
727 # - TEST_CODE - String affecting test selection, usually jenkins job name.
728 # - TEST_TAG_STRING - String selecting tags, from gerrit comment.
731 # - TAGS - Array of processed tag boolean expressions.
733 case "${TEST_CODE}" in
734 # Select specific performance tests based on jenkins job type variable.
736 if [[ -z "${TEST_TAG_STRING-}" ]]; then
737 # If nothing is specified, we will run pre-selected tests by
738 # following tags. Items of array will be concatenated by OR
739 # in Robot Framework.
742 # If trigger contains tags, split them into array.
743 test_tag_array=(${TEST_TAG_STRING//:/ })
750 # We will prefix with perftest to prevent running other tests
752 prefix="devicetestAND"
753 if [[ "${TEST_CODE}" == "vpp-"* ]]; then
754 # Automatic prefixing for VPP jobs to limit testing.
757 for tag in "${test_tag_array[@]}"; do
758 if [[ ${tag} == "!"* ]]; then
759 # Exclude tags are not prefixed.
762 TAGS+=("${prefix}${tag}")
768 function select_topology () {
773 # - NODENESS - Node multiplicity of testbed, either "2n" or "3n".
774 # - FLAVOR - Node flavor string, currently either "hsw" or "skx".
775 # - CSIT_DIR - Path to existing root of local CSIT git repository.
776 # - TOPOLOGIES_DIR - Path to existing directory with available topologies.
778 # - TOPOLOGIES - Array of paths to suitable topology yaml files.
779 # - TOPOLOGIES_TAGS - Tag expression selecting tests for the topology.
781 # - die - Print to stderr and exit.
783 case_text="${NODENESS}_${FLAVOR}"
784 case "${case_text}" in
787 "${TOPOLOGIES_DIR}/vpp_device.template"
789 TOPOLOGIES_TAGS="2_node_single_link_topo"
793 "${TOPOLOGIES_DIR}/vpp_device.template"
795 TOPOLOGIES_TAGS="2_node_single_link_topo"
799 "${TOPOLOGIES_DIR}/lf_2n_skx_testbed21.yaml"
800 #"${TOPOLOGIES_DIR}/lf_2n_skx_testbed22.yaml"
801 "${TOPOLOGIES_DIR}/lf_2n_skx_testbed23.yaml"
802 "${TOPOLOGIES_DIR}/lf_2n_skx_testbed24.yaml"
804 TOPOLOGIES_TAGS="2_node_*_link_topo"
808 "${TOPOLOGIES_DIR}/lf_3n_skx_testbed31.yaml"
809 "${TOPOLOGIES_DIR}/lf_3n_skx_testbed32.yaml"
811 TOPOLOGIES_TAGS="3_node_*_link_topo"
815 "${TOPOLOGIES_DIR}/lf_3n_hsw_testbed1.yaml"
816 "${TOPOLOGIES_DIR}/lf_3n_hsw_testbed2.yaml"
817 "${TOPOLOGIES_DIR}/lf_3n_hsw_testbed3.yaml"
819 TOPOLOGIES_TAGS="3_node_single_link_topo"
822 # No falling back to 3n_hsw default, that should have been done
823 # by the function which has set NODENESS and FLAVOR.
824 die "Unknown specification: ${case_text}"
827 if [[ -z "${TOPOLOGIES-}" ]]; then
828 die "No applicable topology found!"
833 function untrap_and_unreserve_testbed () {
834 # Use this as a trap function to ensure testbed does not remain reserved.
835 # Perhaps call directly before script exit, to free testbed for other jobs.
836 # This function is smart enough to avoid multiple unreservations (so safe).
837 # Topo cleanup is executed (call it best practice), ignoring failures.
840 # - default message to die with if testbed might remain reserved.
842 # - ${1} - Message to die with if unreservation fails. Default hardcoded.
843 # Variables read (by inner function):
844 # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed.
845 # - PYTHON_SCRIPTS_DIR - Path to directory holding Python scripts.
847 # - WORKING_TOPOLOGY - Set to empty string on successful unreservation.
849 # - EXIT - Failure to untrap is reported, but ignored otherwise.
851 # - die - Print to stderr and exit.
854 set +eu # We do not want to exit early in a "teardown" function.
855 trap - EXIT || echo "Trap deactivation failed, continuing anyway."
856 wt="${WORKING_TOPOLOGY}" # Just to avoid too long lines.
857 if [[ -z "${wt-}" ]]; then
859 warn "Testbed looks unreserved already. Trap removal failed before?"
862 python "${PYTHON_SCRIPTS_DIR}/topo_reservation.py" -c -t "${wt}" || {
863 die "${1:-FAILED TO UNRESERVE, FIX MANUALLY.}" 2
872 # Print the message to standard error.
875 # - ${@} - The text of the message.