X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fbash%2Ffunction%2Fcommon.sh;h=8f2e88843e6233ceb43775f6ab856f3c816a63e4;hb=42e546faaf042ef78bb8cbb9339c7fb06f6299dd;hp=f3e86164e1282b0b427b36e08f0b76309ad76ec6;hpb=722aaac15c0b01f0ab5a32084a58c2dd81fcac99;p=csit.git diff --git a/resources/libraries/bash/function/common.sh b/resources/libraries/bash/function/common.sh index f3e86164e1..8f2e88843e 100644 --- a/resources/libraries/bash/function/common.sh +++ b/resources/libraries/bash/function/common.sh @@ -1,5 +1,5 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. -# Copyright (c) 2019 PANTHEON.tech and/or its affiliates. +# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2020 PANTHEON.tech and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -119,7 +119,7 @@ function activate_virtualenv () { pip3 install --upgrade virtualenv || { die "Virtualenv package install failed." } - virtualenv -p $(which python3) "${env_dir}" || { + virtualenv --python=$(which python3) "${env_dir}" || { die "Virtualenv creation for $(which python3) failed." } set +u @@ -193,7 +193,8 @@ function common_dirs () { # Variables set: # - BASH_FUNCTION_DIR - Path to existing directory this file is located in. # - CSIT_DIR - Path to existing root of local CSIT git repository. - # - TOPOLOGIES_DIR - Path to existing directory with available tpologies. + # - TOPOLOGIES_DIR - Path to existing directory with available topologies. + # - JOB_SPECS_DIR - Path to existing directory with job test specifications. # - RESOURCES_DIR - Path to existing CSIT subdirectory "resources". # - TOOLS_DIR - Path to existing resources subdirectory "tools". # - PYTHON_SCRIPTS_DIR - Path to existing tools subdirectory "scripts". @@ -223,6 +224,9 @@ function common_dirs () { TOPOLOGIES_DIR=$(readlink -e "${CSIT_DIR}/topologies/available") || { die "Readlink failed." } + JOB_SPECS_DIR=$(readlink -e "${CSIT_DIR}/docs/job_specs") || { + die "Readlink failed." + } RESOURCES_DIR=$(readlink -e "${CSIT_DIR}/resources") || { die "Readlink failed." } @@ -273,9 +277,6 @@ function compose_pybot_arguments () { *"device"*) PYBOT_ARGS+=("--suite" "tests.${DUT}.device") ;; - *"func"*) - PYBOT_ARGS+=("--suite" "tests.${DUT}.func") - ;; *"perf"*) PYBOT_ARGS+=("--suite" "tests.${DUT}.perf") ;; @@ -411,7 +412,8 @@ function generate_tests () { cp -r "${CSIT_DIR}/tests" "${GENERATED_DIR}/tests" || die cmd_line=("find" "${GENERATED_DIR}/tests" "-type" "f") cmd_line+=("-executable" "-name" "*.py") - file_list=$("${cmd_line[@]}") || die + # We sort the directories, so log output can be compared between runs. + file_list=$("${cmd_line[@]}" | sort) || die for gen in ${file_list}; do directory="$(dirname "${gen}")" || die @@ -560,7 +562,7 @@ function reserve_and_cleanup_testbed () { # - 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 + # - ansible_playbook - Perform an action using ansible, see ansible.sh # Traps registered: # - EXIT - Calls cancel_all for ${WORKING_TOPOLOGY}. @@ -587,9 +589,9 @@ function reserve_and_cleanup_testbed () { } die "Trap attempt failed, unreserve succeeded. Aborting." } - # Cleanup check. + # Cleanup + calibration checks. set +e - ansible_hosts "cleanup" + ansible_playbook "cleanup, calibration" result="$?" set -e if [[ "${result}" == "0" ]]; then @@ -753,20 +755,32 @@ function select_tags () { esac sed_nic_sub_cmd="sed s/\${default_nic}/${default_nic}/" + sed_nics_sub_cmd="sed -e s/ANDxxv710/ANDnic_intel-xxv710/" + sed_nics_sub_cmd+=" | sed -e s/ANDx710/ANDnic_intel-x710/" + sed_nics_sub_cmd+=" | sed -e s/ANDxl710/ANDnic_intel-xl710/" + sed_nics_sub_cmd+=" | sed -e s/ANDx520-da2/ANDnic_intel-x520-da2/" + sed_nics_sub_cmd+=" | sed -e s/ANDx553/ANDnic_intel-x553/" + sed_nics_sub_cmd+=" | sed -e s/ANDcx556a/ANDnic_mellanox-cx556a/" + sed_nics_sub_cmd+=" | sed -e s/ANDvic1227/ANDnic_cisco-vic-1227/" + sed_nics_sub_cmd+=" | sed -e s/ANDvic1385/ANDnic_cisco-vic-1385/" # Tag file directory shorthand. - tfd="${BASH_FUNCTION_DIR}" + tfd="${JOB_SPECS_DIR}" case "${TEST_CODE}" in # Select specific performance tests based on jenkins job type variable. *"ndrpdr-weekly"* ) - readarray -t test_tag_array < "${tfd}/mlr-weekly.txt" || die + readarray -t test_tag_array <<< $(sed 's/ //g' \ + ${tfd}/mlr-weekly-${NODENESS}-${FLAVOR}.md | + eval ${sed_nics_sub_cmd}) || die ;; *"mrr-daily"* ) - readarray -t test_tag_array <<< $(${sed_nic_sub_cmd} \ - ${tfd}/mrr-daily-${FLAVOR}.txt) || die + readarray -t test_tag_array <<< $(sed 's/ //g' \ + ${tfd}/mrr-daily-${NODENESS}-${FLAVOR}.md | + eval ${sed_nics_sub_cmd}) || die ;; *"mrr-weekly"* ) - readarray -t test_tag_array <<< $(${sed_nic_sub_cmd} \ - ${tfd}/mrr-weekly.txt) || die + readarray -t test_tag_array <<< $(sed 's/ //g' \ + ${tfd}/mrr-weekly-${NODENESS}-${FLAVOR}.md | + eval ${sed_nics_sub_cmd}) || die ;; * ) if [[ -z "${TEST_TAG_STRING-}" ]]; then @@ -1023,7 +1037,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 + # - ansible_playbook - Perform an action using ansible, see ansible.sh set -xo pipefail set +eu # We do not want to exit early in a "teardown" function. @@ -1033,7 +1047,7 @@ function untrap_and_unreserve_testbed () { set -eu warn "Testbed looks unreserved already. Trap removal failed before?" else - ansible_hosts "cleanup" || true + ansible_playbook "cleanup" || true python3 "${PYTHON_SCRIPTS_DIR}/topo_reservation.py" -c -t "${wt}" || { die "${1:-FAILED TO UNRESERVE, FIX MANUALLY.}" 2 }