X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fbash%2Ffunction%2Fcommon.sh;h=2b1a7f51285825c4c6e64ea97761009aa87e739c;hb=9c0f0ca1d9a60649cc46980d447c5d567c63cf2d;hp=86659138bc7da3b3b7917225c95ee923c64e3bb4;hpb=a78df8f22fa6293718cc1053aea12662a911e785;p=csit.git diff --git a/resources/libraries/bash/function/common.sh b/resources/libraries/bash/function/common.sh index 86659138bc..2b1a7f5128 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: @@ -42,7 +42,6 @@ function activate_docker_topology () { source "${BASH_FUNCTION_DIR}/device.sh" || { die "Source failed!" } - device_image="$(< ${CSIT_DIR}/${IMAGE_VER_FILE})" case_text="${NODENESS}_${FLAVOR}" case "${case_text}" in @@ -50,13 +49,17 @@ function activate_docker_topology () { # We execute reservation over csit-shim-dcr (ssh) which runs sourced # script's functions. Env variables are read from ssh output # back to localhost for further processing. - hostname=$(grep search /etc/resolv.conf | cut -d' ' -f3) || die - ssh="ssh root@${hostname} -p 6022" + # Shim and Jenkins executor are in the same network on the same host + # Connect to docker's default gateway IP and shim's exposed port + ssh="ssh root@172.17.0.1 -p 6022" run="activate_wrapper ${NODENESS} ${FLAVOR} ${device_image}" + # The "declare -f" output is long and boring. + set +x # backtics to avoid https://midnight-commander.org/ticket/2142 env_vars=`${ssh} "$(declare -f); ${run}"` || { die "Topology reservation via shim-dcr failed!" } + set -x set -a source <(echo "$env_vars" | grep -v /usr/bin/docker) || { die "Source failed!" @@ -113,16 +116,16 @@ function activate_virtualenv () { env_dir="${root_path}/env" req_path=${2-$CSIT_DIR/requirements.txt} rm -rf "${env_dir}" || die "Failed to clean previous virtualenv." - pip3 install --upgrade virtualenv || { + pip3 install virtualenv==20.0.20 || { die "Virtualenv package install failed." } - virtualenv -p $(which python3) "${env_dir}" || { + virtualenv --no-download --python=$(which python3) "${env_dir}" || { die "Virtualenv creation for $(which python3) failed." } set +u source "${env_dir}/bin/activate" || die "Virtualenv activation failed." set -u - pip3 install --upgrade -r "${req_path}" || { + pip3 install -r "${req_path}" || { die "Requirements installation failed." } # Most CSIT Python scripts assume PYTHONPATH is set and exported. @@ -190,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". @@ -220,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." } @@ -270,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") ;; @@ -329,12 +333,14 @@ function deactivate_docker_topology () { case_text="${NODENESS}_${FLAVOR}" case "${case_text}" in "1n_skx" | "1n_tx2") - hostname=$(grep search /etc/resolv.conf | cut -d' ' -f3) || die - ssh="ssh root@${hostname} -p 6022" + ssh="ssh root@172.17.0.1 -p 6022" env_vars=$(env | grep CSIT_ | tr '\n' ' ' ) || die + # The "declare -f" output is long and boring. + set +x ${ssh} "$(declare -f); deactivate_wrapper ${env_vars}" || { die "Topology cleanup via shim-dcr failed!" } + set -x ;; "1n_vbox") enter_mutex || die @@ -405,7 +411,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 @@ -453,6 +460,10 @@ function get_test_code () { NODENESS="2n" FLAVOR="skx" ;; + *"2n-zn2"*) + NODENESS="2n" + FLAVOR="zn2" + ;; *"3n-skx"*) NODENESS="3n" FLAVOR="skx" @@ -516,6 +527,19 @@ function get_test_tag_string () { cmd=("grep" "-oP" '\S*'"${trigger}"'\S*\s\K.+$') || die "Unset trigger?" # On parsing error, TEST_TAG_STRING probably stays empty. TEST_TAG_STRING=$("${cmd[@]}" <<< "${comment}") || true + if [[ -n "${TEST_TAG_STRING-}" ]]; then + test_tag_array=(${TEST_TAG_STRING}) + if [[ "${test_tag_array[0]}" == "icl" ]]; then + export GRAPH_NODE_VARIANT="icl" + TEST_TAG_STRING="${test_tag_array[@]:1}" || true + elif [[ "${test_tag_array[0]}" == "skx" ]]; then + export GRAPH_NODE_VARIANT="skx" + TEST_TAG_STRING="${test_tag_array[@]:1}" || true + elif [[ "${test_tag_array[0]}" == "hsw" ]]; then + export GRAPH_NODE_VARIANT="hsw" + TEST_TAG_STRING="${test_tag_array[@]:1}" || true + fi + fi fi } @@ -554,7 +578,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}. @@ -581,9 +605,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 @@ -702,6 +726,7 @@ function select_tags () { # Variables read: # - WORKING_TOPOLOGY - Path to topology yaml file of the reserved testbed. # - TEST_CODE - String affecting test selection, usually jenkins job name. + # - DUT - CSIT test/ subdirectory, set while processing tags. # - TEST_TAG_STRING - String selecting tags, from gerrit comment. # Can be unset. # - TOPOLOGIES_DIR - Path to existing directory with available tpologies. @@ -735,7 +760,7 @@ function select_tags () { *"3n-tsh"*) default_nic="nic_intel-x520-da2" ;; - *"3n-skx"* | *"2n-skx"* | *"2n-clx"*) + *"3n-skx"* | *"2n-skx"* | *"2n-clx"* | *"2n-zn2"*) default_nic="nic_intel-xxv710" ;; *"3n-hsw"* | *"mrr-daily-master") @@ -747,20 +772,48 @@ 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/${DUT}-${NODENESS}-${FLAVOR}.md | + eval ${sed_nics_sub_cmd} || echo "perftest") || 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/${DUT}-${NODENESS}-${FLAVOR}.md | + eval ${sed_nics_sub_cmd} || echo "perftest") || 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/${DUT}-${NODENESS}-${FLAVOR}.md | + eval ${sed_nics_sub_cmd} || echo "perftest") || die + ;; + *"report-iterative"* ) + test_sets=(${TEST_TAG_STRING//:/ }) + # Run only one test set per run + report_file=${test_sets[0]}.md + readarray -t test_tag_array <<< $(sed 's/ //g' \ + ${tfd}/report_iterative/${NODENESS}-${FLAVOR}/${report_file} | + eval ${sed_nics_sub_cmd} || echo "perftest") || die + ;; + *"report-coverage"* ) + test_sets=(${TEST_TAG_STRING//:/ }) + # Run only one test set per run + report_file=${test_sets[0]}.md + readarray -t test_tag_array <<< $(sed 's/ //g' \ + ${tfd}/report_coverage/${NODENESS}-${FLAVOR}/${report_file} | + eval ${sed_nics_sub_cmd} || echo "perftest") || die ;; * ) if [[ -z "${TEST_TAG_STRING-}" ]]; then @@ -785,7 +838,7 @@ function select_tags () { # TODO: Add missing reasons here (if general) or where used (if specific). case "${TEST_CODE}" in *"2n-skx"*) - test_tag_array+=("!ipsechw") + test_tag_array+=("!ipsec") ;; *"3n-skx"*) test_tag_array+=("!ipsechw") @@ -793,7 +846,10 @@ function select_tags () { test_tag_array+=("!3_node_double_link_topoANDnic_intel-xxv710") ;; *"2n-clx"*) - test_tag_array+=("!ipsechw") + test_tag_array+=("!ipsec") + ;; + *"2n-zn2"*) + test_tag_array+=("!ipsec") ;; *"2n-dnv"*) test_tag_array+=("!ipsechw") @@ -816,10 +872,6 @@ function select_tags () { test_tag_array+=("!ipsechw") ;; *"3n-hsw"*) - # TODO: Introduce NOIOMMU version of AVF tests. - # TODO: Make (both) AVF tests work on Haswell, - # or document why (some of) it is not possible. - # https://github.com/FDio/vpp/blob/master/src/plugins/avf/README.md test_tag_array+=("!drv_avf") # All cards have access to QAT. But only one card (xl710) # resides in same NUMA as QAT. Other cards must go over QPI @@ -861,6 +913,13 @@ function select_tags () { 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}" == *"OR"* ]]; then + # If OR had higher precedence than AND, it would be useful here. + # Some people think it does, thus triggering way too much tests. + set -x + warn "The following tag expression hints at bad trigger: ${tag}" + warn "Operator OR has lower precedence than AND. Use space instead." + 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. @@ -902,6 +961,10 @@ function select_topology () { TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*2n_skx*.yaml ) TOPOLOGIES_TAGS="2_node_*_link_topo" ;; + "2n_zn2") + TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*2n_zn2*.yaml ) + TOPOLOGIES_TAGS="2_node_*_link_topo" + ;; "3n_skx") TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*3n_skx*.yaml ) TOPOLOGIES_TAGS="3_node_*_link_topo" @@ -1017,7 +1080,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. @@ -1027,7 +1090,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 }