diff options
Diffstat (limited to 'resources/libraries/bash/entry')
34 files changed, 578 insertions, 370 deletions
diff --git a/resources/libraries/bash/entry/README.txt b/resources/libraries/bash/entry/README.txt index bf7897f8a6..8757c9b013 100644 --- a/resources/libraries/bash/entry/README.txt +++ b/resources/libraries/bash/entry/README.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco 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: diff --git a/resources/libraries/bash/entry/bisect.sh b/resources/libraries/bash/entry/bisect.sh new file mode 100644 index 0000000000..d5cb1d51ba --- /dev/null +++ b/resources/libraries/bash/entry/bisect.sh @@ -0,0 +1,188 @@ +#!/usr/bin/env bash + +# Copyright (c) 2023 Cisco 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: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -exuo pipefail + +# This entry script does not change which CSIT branch is used, +# use "with_oper_for_vpp.sh" wrapper for that. +# +# This script is to be used for locating performance regressions +# (or breakages, or progressions, or fixes). +# It uses "git bisect" commands on the VPP repository, +# between the triggered VPP patch and a commit specified in the first argument +# of the gerrit comment text. +# The other arguments are used as tag expressions for selecting tests as usual. +# Many different result types are supported. +# +# Logs are present in the archive directory, but usually the main output +# is the offending commit as identified by "git bisect", visible in console. +# +# While selecting just one testcase is the intended use, +# this script should be able to deal with multiple testcases as well, +# grouping all the values together. This usually inflates +# the standard deviation, but it is not clear how that affects the bisection. +# +# For the bisection decision, jumpavg library is used, +# deciding whether shorter description is achieved by forcefully grouping +# the middle results with the old, or with the new ones. +# If the shortest description is achieved with 3 separate groups, +# bisect interval focuses on biggest relative change +# (with respect to pairwise maximum). +# +# If a test fails, an artificial result is used to distinguish +# from normal results. Currently, the value 1.0, with the multiplicity of 4. +# +# Note that if there was a VPP API change that affects tests in the interval, +# there frequently is no good way for single CSIT commit to work there. +# You can try manually reverting the CSIT changes to make tests pass, +# possibly needing to search over multiple subintervals. +# Using and older CSIT commit (possibly cherry-picking the bisect Change +# if it was not present in CSIT compatible with old enough VPP builds) +# is the fastest solution; but beware of CSIT-induced performance effects +# (e.g. TRex settings). +# +# If a regression happens during a subinterval where the test fails +# due to a bug in VPP, you may try to create a new commit chain +# with the fix cherry-picked to the start of the interval. +# Do not do that as a chain in Gerrit, it would be long and Gerrit will refuse +# edits of already merged Changes. +# Instead, add a block of bash code to do the manipulation +# on local git history between checkout and bisect. +# +# At the start, the script executes first bisect iteration in an attempt +# to avoid work if the search interval has only one commit (or is invalid). +# Only when the work is needed, earliest and latest commits are built +# and tested. Branches "earliest", "middle" and "latest" are temporarily created +# as a way to remember which commits to check out. +# +# Test results are parsed from json files, +# symlinks are used to tell python script which results to compare. +# +# Assumptions: +# + There is a directory holding VPP repo with patch under test checked out. +# + It contains csit subdirectory with CSIT code to use (this script is there). +# + Everything needed to build VPP is already installed locally. +# Consequences: +# + Working directory is switched to the VPP repo root. +# + At the end, VPP repo has checked out and built some commit, +# as chosen by "git bisect". +# + Directories build_root, build and csit are reset during the run. +# + The following directories (relative to VPP repo) are (re)created: +# ++ csit_{earliest,middle,latest}, build_{earliest,latest}, +# ++ archive, csit/archive, csit/download_dir. +# + Symlinks csit_{early,late,mid} are also created. +# Arguments: +# - ${1} - If present, override JOB_NAME to simplify manual usage. + +# "set -eu" handles failures from the following two lines. +BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" +BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")" +source "${BASH_FUNCTION_DIR}/common.sh" || { + echo "Source failed." >&2 + exit 1 +} +source "${BASH_FUNCTION_DIR}/per_patch.sh" || die "Source failed." +# Cleanup needs ansible. +source "${BASH_FUNCTION_DIR}/ansible.sh" || die "Source failed." +common_dirs || die +check_prerequisites || die +set_perpatch_vpp_dir || die +get_test_code "${1-}" || die +get_test_tag_string || die +# Unfortunately, git bisect only works at the top of the repo. +cd "${VPP_DIR}" || die + +# Save the current commit. +git checkout -b "latest" +# Save the lower bound commit. +git checkout -b "earliest" +git reset --hard "${GIT_BISECT_FROM}" + +# This is the place for custom code manipulating local git history. + +#git checkout -b "alter" +#... +#git checkout "latest" +#git rebase "alter" || git rebase --skip +#git branch -D "alter" + +git bisect start || die +# TODO: Can we add a trap for "git bisect reset" or even "deactivate", +# without affecting the inner trap for unreserve and cleanup? +git checkout "latest" +git status || die +git describe || die +git bisect new || die +# Performing first iteration early to avoid testing or even building. +git checkout "earliest" || die "Failed to checkout earliest commit." +git status || die +git describe || die +# The first iteration. +git bisect old | tee "git.log" || die "Invalid bisect interval?" +git checkout -b "middle" || die "Failed to create branch: middle" +git status || die +git describe || die +if head -n 1 "git.log" | cut -b -11 | fgrep -q "Bisecting:"; then + echo "Building and testing initial bounds." +else + echo "Single commit, no work needed." + exit 0 +fi +# Building latest first, good for avoiding DPDK rebuilds. +git checkout "latest" || die "Failed to checkout latest commit." +build_vpp_ubuntu "LATEST" || die +set_aside_build_artifacts "latest" || die +git checkout "earliest" || die "Failed to checkout earliest commit." +git status || die +git describe || die +build_vpp_ubuntu "EARLIEST" || die +set_aside_build_artifacts "earliest" || die +git checkout "middle" || die "Failed to checkout middle commit." +git branch -D "earliest" "latest" || die "Failed to remove branches." +# Done with repo manipulation for now, testing commences. +initialize_csit_dirs "earliest" "middle" "latest" || die +set_perpatch_dut || die +select_topology || die +select_arch_os || die +activate_virtualenv "${VPP_DIR}" || die +generate_tests || die +archive_tests || die + +# TODO: Does it matter which build is tested first? + +select_build "build_earliest" || die +check_download_dir || die +reserve_and_cleanup_testbed || die +run_robot || die +move_test_results "csit_earliest" || die +ln -s -T "csit_earliest" "csit_early" || die + +# Explicit cleanup, in case the previous test left the testbed in a bad shape. +ansible_playbook "cleanup" + +select_build "build_latest" || die +check_download_dir || die +run_robot || die +move_test_results "csit_latest" || die +ln -s -T "csit_latest" "csit_late" || die +untrap_and_unreserve_testbed || die + +# See function documentation for the logic in the loop. +main_bisect_loop || die +# In worst case, the middle branch is still checked out. +# TODO: Is there a way to ensure "middle" branch is always deleted? +git branch -D "middle" || true +# Delete symlinks to prevent duplicate archiving. +rm -vrf "csit_early" "csit_late" "csit_mid" diff --git a/resources/libraries/bash/entry/bootstrap_aws_eb_version_create_release.sh b/resources/libraries/bash/entry/bootstrap_aws_eb_version_create_release.sh new file mode 100755 index 0000000000..0bbf3b83ff --- /dev/null +++ b/resources/libraries/bash/entry/bootstrap_aws_eb_version_create_release.sh @@ -0,0 +1,32 @@ +# Copyright (c) 2024 Cisco 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: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -exuo pipefail + +# Assumptions: +# + There is a directory holding CSIT code to use (this script is there). +# Consequences (and specific assumptions) are multiple, +# examine tree of functions for current description. + +# "set -eu" handles failures from the following two lines. +BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" +BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")" +source "${BASH_FUNCTION_DIR}/common.sh" || { + echo "Source failed." >&2 + exit 1 +} +source "${BASH_FUNCTION_DIR}/eb_version.sh" || die "Source failed." +source "${BASH_FUNCTION_DIR}/hugo.sh" || die "Source failed." +source "${BASH_FUNCTION_DIR}/terraform.sh" || die "Source failed." +common_dirs || die +eb_version_create_release || die diff --git a/resources/libraries/bash/entry/bootstrap_aws_eb_version_deploy.sh b/resources/libraries/bash/entry/bootstrap_aws_eb_version_deploy.sh new file mode 100755 index 0000000000..15d6dae405 --- /dev/null +++ b/resources/libraries/bash/entry/bootstrap_aws_eb_version_deploy.sh @@ -0,0 +1,32 @@ +# Copyright (c) 2023 Cisco 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: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -exuo pipefail + +# Assumptions: +# + There is a directory holding CSIT code to use (this script is there). +# Consequences (and specific assumptions) are multiple, +# examine tree of functions for current description. + +# "set -eu" handles failures from the following two lines. +BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" +BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")" +source "${BASH_FUNCTION_DIR}/common.sh" || { + echo "Source failed." >&2 + exit 1 +} +source "${BASH_FUNCTION_DIR}/eb_version.sh" || die "Source failed." +source "${BASH_FUNCTION_DIR}/hugo.sh" || die "Source failed." +source "${BASH_FUNCTION_DIR}/terraform.sh" || die "Source failed." +common_dirs || die +eb_version_deploy || die diff --git a/resources/libraries/bash/entry/bootstrap_aws_eb_version_verify.sh b/resources/libraries/bash/entry/bootstrap_aws_eb_version_verify.sh new file mode 100755 index 0000000000..362a2f78af --- /dev/null +++ b/resources/libraries/bash/entry/bootstrap_aws_eb_version_verify.sh @@ -0,0 +1,32 @@ +# Copyright (c) 2023 Cisco 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: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -exuo pipefail + +# Assumptions: +# + There is a directory holding CSIT code to use (this script is there). +# Consequences (and specific assumptions) are multiple, +# examine tree of functions for current description. + +# "set -eu" handles failures from the following two lines. +BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" +BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")" +source "${BASH_FUNCTION_DIR}/common.sh" || { + echo "Source failed." >&2 + exit 1 +} +source "${BASH_FUNCTION_DIR}/eb_version.sh" || die "Source failed." +source "${BASH_FUNCTION_DIR}/hugo.sh" || die "Source failed." +source "${BASH_FUNCTION_DIR}/terraform.sh" || die "Source failed." +common_dirs || die +eb_version_build_verify || die diff --git a/resources/libraries/bash/entry/bootstrap_report.sh b/resources/libraries/bash/entry/bootstrap_report.sh new file mode 100755 index 0000000000..47a9d2e3d4 --- /dev/null +++ b/resources/libraries/bash/entry/bootstrap_report.sh @@ -0,0 +1,32 @@ +# Copyright (c) 2023 Cisco 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: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -exuo pipefail + +# Assumptions: +# + There is a directory holding CSIT code to use (this script is there). +# Consequences (and specific assumptions) are multiple, +# examine tree of functions for current description. + +# "set -eu" handles failures from the following two lines. +BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" +BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")" +source "${BASH_FUNCTION_DIR}/common.sh" || { + echo "Source failed." >&2 + exit 1 +} +source "${BASH_FUNCTION_DIR}/eb_version.sh" || die "Source failed." +common_dirs || die +activate_virtualenv || die +generate_report || die +die_on_error || die diff --git a/resources/libraries/bash/entry/bootstrap_verify_perf.sh b/resources/libraries/bash/entry/bootstrap_verify_perf.sh index fc3344010b..18dfd08c39 100644..100755 --- a/resources/libraries/bash/entry/bootstrap_verify_perf.sh +++ b/resources/libraries/bash/entry/bootstrap_verify_perf.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco 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: @@ -32,21 +32,21 @@ source "${BASH_FUNCTION_DIR}/common.sh" || { } source "${BASH_FUNCTION_DIR}/gather.sh" || die "Source failed." source "${BASH_FUNCTION_DIR}/ansible.sh" || die "Source failed." +source "${BASH_FUNCTION_DIR}/terraform.sh" || die "Source failed." common_dirs || die check_prerequisites || die get_test_code "${1-}" || die get_test_tag_string || die -select_topology || die select_arch_os || die gather_build || die check_download_dir || die activate_virtualenv || die generate_tests || die archive_tests || die +prepare_topology || die +select_topology || die reserve_and_cleanup_testbed || die -select_tags || die -compose_pybot_arguments || die -run_pybot || die -untrap_and_unreserve_testbed || die +run_robot || die move_archives || die -die_on_pybot_error || die +untrap_and_unreserve_testbed || die +die_on_robot_error || die diff --git a/resources/libraries/bash/entry/bootstrap_vpp_device.sh b/resources/libraries/bash/entry/bootstrap_vpp_device.sh index ef7bb08dfa..fd6279f8c7 100755 --- a/resources/libraries/bash/entry/bootstrap_vpp_device.sh +++ b/resources/libraries/bash/entry/bootstrap_vpp_device.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco 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: @@ -35,16 +35,15 @@ common_dirs || die check_prerequisites || die get_test_code "${1-}" || die get_test_tag_string || die -select_topology || die select_arch_os || die gather_build || die check_download_dir || die activate_virtualenv || die generate_tests || die archive_tests || die +prepare_topology || die +select_topology || die activate_docker_topology || die -select_vpp_device_tags || die -compose_pybot_arguments || die -run_pybot || die +run_robot || die move_archives || die -die_on_pybot_error || die +die_on_robot_error || die diff --git a/resources/libraries/bash/entry/check/doc_verify.sh b/resources/libraries/bash/entry/check/doc_verify.sh deleted file mode 100644 index 50b3d2db17..0000000000 --- a/resources/libraries/bash/entry/check/doc_verify.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2019 Cisco 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: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -xeuo pipefail - -# This file should be executed from tox, as the assumend working directory -# is different from where this file is located. -# This file does not have executable flag nor shebang, -# to dissuade non-tox callers. - -# "set -eu" handles failures from the following two lines. -BASH_CHECKS_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" -BASH_FUNCTION_DIR="$(readlink -e "${BASH_CHECKS_DIR}/../../function")" -source "${BASH_FUNCTION_DIR}/common.sh" || { - echo "Source failed." >&2 - exit 1 -} - -common_dirs || die -log_file="$(pwd)/doc_verify.log" || die - -# Pre-cleanup. -rm -f "${log_file}" || die -rm -f "${DOC_GEN_DIR}/csit.docs.tar.gz" || die -rm -rf "${DOC_GEN_DIR}/_build" || die - -# Documentation generation. -# Here we do store only stderr to file while stdout (inlcuding Xtrace) is -# printed to console. This way we can track increased errors in future. -# We do not need to do trap as the env will be closed after tox finished the -# task. -exec 3>&1 || die -export BASH_XTRACEFD="3" || die - -pushd "${DOC_GEN_DIR}" || die -source ./run_doc.sh ${GERRIT_BRANCH:-local} 2> ${log_file} || true -popd || die - -if [[ ! -f "${log_file}" ]] || [[ -s "${log_file}" ]]; then - # Output file not exists or is non empty. - warn - warn "Doc verify checker: FAIL" - exit 1 -fi - -warn -warn "Doc verify checker: PASS" diff --git a/resources/libraries/bash/entry/check/tc_coverage.sh b/resources/libraries/bash/entry/check/tc_coverage.sh deleted file mode 100644 index 2fda5f7d52..0000000000 --- a/resources/libraries/bash/entry/check/tc_coverage.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2019 Cisco 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: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -xeuo pipefail - -# This file should be executed from tox, as the assumend working directory -# is different from where this file is located. -# This file does not have executable flag nor shebang, -# to dissuade non-tox callers. - -# "set -eu" handles failures from the following two lines. -BASH_CHECKS_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" -BASH_FUNCTION_DIR="$(readlink -e "${BASH_CHECKS_DIR}/../../function")" -source "${BASH_FUNCTION_DIR}/common.sh" || { - echo "Source failed." >&2 - exit 1 -} - -# Grep of interest: We want all tc01- prefixed (skip TC variations for now). -# Currently script assumes all variations inside to be part of either -# auto-generation or not checked at all (VIRL derivates). -r_grep="tc01-" -# Parse grep of interest (learn path, learn suite, learn testcase name). -r_parse='(.*)\/(.*).robot.*(tc[[:digit:]]{2}-.*)' - -rm -f "tc_coverage.log" || die - -# Disabling -x: Following lines are doing too much garbage output. -set +x - -# Grep interest. -grep_match=$(grep -RE "${r_grep}" tests/*) || die -# Extract data from the grep output. -suites_dirs=($(printf "${grep_match}" | sed -re "s/${r_parse}/\1/")) || die -suites_names=($(printf "${grep_match}" | sed -re "s/${r_parse}/\2/")) || die -testcases_names=($(printf "${grep_match}" | sed -re "s/${r_parse}/\3/")) || die - -# Extract 2N suites from the global testcase list and normalize output. -suites_2n=($(printf '%s\n' "${suites_names[@]}" | \ - grep -E "^(2n1l|2n)-" | \ - sed -re "s/(2n1l|2n)-//")) -# Extract 3N suites from the global testcase list. -suites_3n=($(printf '%s\n' "${suites_names[@]}" | \ - grep -vE "^(2n1l|2n|eth2p)-")) -# Extract vpp_device suites from the global testcase list. -# Code will try to map the naming to perf by normalizing output. -suites_dev=($(printf '%s\n' "${suites_names[@]}" | \ - grep -E "^eth2p-" | \ - sed -re "s/eth2p-/10ge2p1x710-/" | \ - sed -re "s/-dev/-ndrpdr/" | \ - sed -re "s/-ethicmpv/-ethip/")) - -# Compute intersection of arrays. -intersection_3n2n=($(comm -12 <(printf '%s\n' "${suites_3n[@]}" | sort) \ - <(printf '%s\n' "${suites_2n[@]}" | sort))) -intersection_3ndev=($(comm -12 <(printf '%s\n' "${suites_2n[@]}" | sort) \ - <(printf '%s\n' "${suites_dev[@]}" | sort))) - -# Print the results in CSV format. -echo "Suite name;Testcase name;2n version;VPP Device version" \ - > tc_coverage.log -for i in "${!suites_names[@]}"; do - if [[ ! "${suites_names[i]}" =~ ^(2n1l|2n|eth2p)-.* ]]; then - echo -n "${suites_names[i]};${testcases_names[i]}" \ - >> tc_coverage.log - if [[ "${intersection_3n2n[@]}" =~ "${suites_names[i]}" ]]; then - echo -n ";yes" >> tc_coverage.log - else - echo -n ";no" >> tc_coverage.log - fi - if [[ "${intersection_3ndev[@]}" =~ "${suites_names[i]}" ]]; then - echo ";yes" >> tc_coverage.log - else - echo ";no" >> tc_coverage.log - fi - fi -done - -set -x - -echo "Count 2n: ${#suites_2n[@]}" -echo "Count 3n: ${#suites_3n[@]}" -echo "Count dev: ${#suites_dev[@]}" -echo "Coverage 2n3n: ${#intersection_3n2n[@]}" -echo "Coverage 3ndev: ${#intersection_3ndev[@]}" - -warn -warn "Testcase coverage checker: PASS" diff --git a/resources/libraries/bash/entry/check/tc_naming.sh b/resources/libraries/bash/entry/check/tc_naming.sh deleted file mode 100644 index e9f86fc0dd..0000000000 --- a/resources/libraries/bash/entry/check/tc_naming.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2020 Cisco 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: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -xeuo pipefail - -# This file should be executed from tox, as the assumend working directory -# is different from where this file is located. -# This file does not have executable flag nor shebang, -# to dissuade non-tox callers. - -# "set -eu" handles failures from the following two lines. -BASH_CHECKS_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" -BASH_FUNCTION_DIR="$(readlink -e "${BASH_CHECKS_DIR}/../../function")" -source "${BASH_FUNCTION_DIR}/common.sh" || { - echo "Source failed." >&2 - exit 1 -} - -# Grep of interest: We want all [0-9]{2,4}B- or IMIX- prefixed. -# Currently script assumes all variations inside to be part of either -# auto-generation or not checked at all (VIRL derivates). -r_grep="([0-9]{2,4}B|IMIX)-" -# Parse grep of interest (learn path, learn suite, learn testcase name). -r_parse='(.*)\/(.*).robot.*(([0-9]{2,4}B|IMIX)-.*)' - -# CSIT Testcase naming convention rules. -# https://wiki.fd.io/view/CSIT/csit-test-naming -# Rules are defined as regular expressions in ordered array and checked in order -# in a loop, where every iteration is catenated with previous rules. This way we -# can detect where exactly the naming does not meet criteria and print error -# from rule string array. This imply that rules are defined in a way of a single -# string. First rule must start with ^ and last is terminated by $. -# Rules are written from Left to Right. -# Bash regular expression logic is used. Once the error is raised the checker is -# breaked for current Testcase marking the expected fail. -# One caveat of this solution is that we cannot proceed to check full names now -# as majority of Testcases does not meet naming criteria. -s_testc_rules=( - 'packet size' - 'core combination' - 'NIC driver mode' - 'packet encapsulation on L2 layer' - 'test type' - ) -r_testc_rules=( - '^([[:digit:]]{2,4}B|IMIX)-' - '([[:digit:]]+c-){0,1}' - '(avf-|1lbvpplacp-|2lbvpplacp-){0,1}' - '(eth|dot1q|dot1ad)' - # TODO: Packet encapsulation (here majority of TC starts failing). - #'(ip4|ip6|ip6ip6|icmpv4|icmpv6)' - #'(ipsec[[:digit:]]+tnlhw|ipsec[[:digit:]]+tnlsw|' - #'srhip6|tcp|udp|lispip6|lispip4|vxlan){0,1}' - #'(http){0,1}-' - '(.*)-(dev|ndrpdr|bps|cps|rps|reconf)$' - ) -s_suite_rules=( - 'number of SUT nodes' - 'NIC card' - 'NIC driver mode' - 'packet encapsulation on L2 layer' - 'test type' - ) -r_suite_rules=( - '^(2n1l|2n){0,1}-' - '(eth2p|10ge2p1x710)-' - '(avf-|1lbvpplacp-|2lbvpplacp-){0,1}' - '(eth|dot1q|dot1ad)' - # TODO: Packet encapsulation (here majority of TC starts failing). - #'(ip4|ip6|ip6ip6|icmpv4|icmpv6)' - #'(ipsec[[:digit:]]+tnlhw|ipsec[[:digit:]]+tnlsw|' - #'srhip6|tcp|udp|lispip6|lispip4|vxlan){0,1}' - #'(http){0,1}-' - '(.*)-(dev|ndrpdr|bps|cps|rps|reconf)$' - ) - -rm -f "tc_naming.log" || die - -# Disabling -x: Following lines are doing too much garbage output. -set +x - -# Grep interest. -grep_match=$(grep -RE "${r_grep}" tests/*) || die -# Extract data from the grep output. -suites_dirs=($(printf "${grep_match}" | sed -re "s/${r_parse}/\1/")) || die -suites_names=($(printf "${grep_match}" | sed -re "s/${r_parse}/\2/")) || die -testcases_names=($(printf "${grep_match}" | sed -re "s/${r_parse}/\3/")) || die - -# Naming check. -total_failed_tc=0 -total_failed_su=0 -for idx in "${!testcases_names[@]}"; do - for pass in "${!r_suite_rules[@]}"; do - r_rule=$(printf '%s' "${r_suite_rules[@]:1:pass}") - if [[ ! "${suites_names[idx]}" =~ ${r_rule} ]]; then - msg="" - msg+="${suites_dirs[idx]}/${suites_names[idx]} / " - msg+="${testcases_names[idx]} ${s_suite_rules[pass]} " - msg+="is not matching suite naming rule!" - echo "${msg}" | tee -a "tc_naming.log" || die - total_failed_su=$((total_failed_su + 1)) - break - fi - done - for pass in "${!r_testc_rules[@]}"; do - r_rule=$(printf '%s' "${r_testc_rules[@]:1:pass}") - if [[ ! "${testcases_names[idx]}" =~ ${r_rule} ]]; then - msg="" - msg+="${suites_dirs[idx]}/${suites_names[idx]} / " - msg+="${testcases_names[idx]} ${s_testc_rules[pass]} " - msg+="is not matching testcase naming rule!" - echo "${msg}" | tee -a "tc_naming.log" || die - total_failed_tc=$((total_failed_tc + 1)) - break - fi - done -done - -set -x - -if [ $((total_failed_tc + total_failed_su)) != "0" ]; then - warn - warn "Testcase naming checker: FAIL" - exit 1 -fi - -warn -warn "Testcase naming checker: PASS" diff --git a/resources/libraries/bash/entry/check_crc.sh b/resources/libraries/bash/entry/check_crc.sh index 798d29a7f0..5860bcbca5 100644 --- a/resources/libraries/bash/entry/check_crc.sh +++ b/resources/libraries/bash/entry/check_crc.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco 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: diff --git a/resources/libraries/bash/entry/check_l3fwd.sh b/resources/libraries/bash/entry/check_l3fwd.sh new file mode 100755 index 0000000000..3e53b636a3 --- /dev/null +++ b/resources/libraries/bash/entry/check_l3fwd.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright (c) 2022 Cisco 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: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Helper functions for starting testpmd. + +set -exuo pipefail + +# Assumptions: +# + There is a directory holding CSIT code to use (this script is there). +# + At least one of the following is true: +# ++ JOB_NAME environment variable is set, +# ++ or this entry script has access to arguments. +# Consequences (and specific assumptions) are multiple, +# examine tree of functions for current description. + +# FIXME: Define API contract (as opposed to just help) for bootstrap. + +# "set -eu" handles failures from the following two lines. +BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" +BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")" +source "${BASH_FUNCTION_DIR}/common.sh" || { + echo "Source failed." >&2 + exit 1 +} +source "${BASH_FUNCTION_DIR}/dpdk.sh" || die "Source failed." +common_dirs || die +dpdk_l3fwd_check || die diff --git a/resources/libraries/bash/entry/check_testpmd.sh b/resources/libraries/bash/entry/check_testpmd.sh new file mode 100755 index 0000000000..1622b25b70 --- /dev/null +++ b/resources/libraries/bash/entry/check_testpmd.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright (c) 2022 Cisco 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: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Helper functions for starting testpmd. + +set -exuo pipefail + +# Assumptions: +# + There is a directory holding CSIT code to use (this script is there). +# + At least one of the following is true: +# ++ JOB_NAME environment variable is set, +# ++ or this entry script has access to arguments. +# Consequences (and specific assumptions) are multiple, +# examine tree of functions for current description. + +# FIXME: Define API contract (as opposed to just help) for bootstrap. + +# "set -eu" handles failures from the following two lines. +BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" +BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")" +source "${BASH_FUNCTION_DIR}/common.sh" || { + echo "Source failed." >&2 + exit 1 +} +source "${BASH_FUNCTION_DIR}/dpdk.sh" || die "Source failed." +common_dirs || die +dpdk_testpmd_check || die diff --git a/resources/libraries/bash/entry/cleanup_dpdk.sh b/resources/libraries/bash/entry/cleanup_dpdk.sh index 726f98c1a1..517e5b98f5 100755 --- a/resources/libraries/bash/entry/cleanup_dpdk.sh +++ b/resources/libraries/bash/entry/cleanup_dpdk.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco 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: diff --git a/resources/libraries/bash/entry/init_dpdk.sh b/resources/libraries/bash/entry/init_dpdk.sh index 910ade38f9..fdbb5b2bd6 100755 --- a/resources/libraries/bash/entry/init_dpdk.sh +++ b/resources/libraries/bash/entry/init_dpdk.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco 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: diff --git a/resources/libraries/bash/entry/install_dpdk.sh b/resources/libraries/bash/entry/install_dpdk.sh index d87aa5a832..f6a6d454af 100755 --- a/resources/libraries/bash/entry/install_dpdk.sh +++ b/resources/libraries/bash/entry/install_dpdk.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco 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: diff --git a/resources/libraries/bash/entry/install_nginx.sh b/resources/libraries/bash/entry/install_nginx.sh new file mode 100755 index 0000000000..3a2c8ef7eb --- /dev/null +++ b/resources/libraries/bash/entry/install_nginx.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021 Intel 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: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Install the NGINX framework on the DUT node. Check prerequisites. + +set -exuo pipefail + +# Assumptions: +# + There is a directory holding CSIT code to use (this script is there). +# + At least one of the following is true: +# ++ JOB_NAME environment variable is set, +# ++ or this entry script has access to arguments. +# Consequences (and specific assumptions) are multiple, +# examine tree of functions for current description. + +BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" +BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")" +source "${BASH_FUNCTION_DIR}/common.sh" || { + echo "Source failed." >&2 + exit 1 +} +source "${BASH_FUNCTION_DIR}/nginx.sh" || die "Source failed." +common_dirs ${@} || die +gather_nginx || die "Download nginx failed." +nginx_extract || die "Extract nginx failed." +nginx_compile || die "Compile nginx failed." diff --git a/resources/libraries/bash/entry/patch_l3fwd.sh b/resources/libraries/bash/entry/patch_l3fwd.sh index 0ce02a0047..88597f1da0 100755 --- a/resources/libraries/bash/entry/patch_l3fwd.sh +++ b/resources/libraries/bash/entry/patch_l3fwd.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco 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: diff --git a/resources/libraries/bash/entry/patch_l3fwd_flip_routes b/resources/libraries/bash/entry/patch_l3fwd_flip_routes index 3b35e1f930..c5eff5d3ca 100755 --- a/resources/libraries/bash/entry/patch_l3fwd_flip_routes +++ b/resources/libraries/bash/entry/patch_l3fwd_flip_routes @@ -1,7 +1,7 @@ #!/bin/sh -patch --ignore-whitespace --forward l3fwd_lpm.c <<"_EOF" -44,45c44,45 +patch --ignore-whitespace --forward main.c <<"_EOF" +204,205c204,205 < {RTE_IPV4(198, 18, 0, 0), 24, 0}, < {RTE_IPV4(198, 18, 1, 0), 24, 1}, --- diff --git a/resources/libraries/bash/entry/per_patch_device.sh b/resources/libraries/bash/entry/per_patch_device.sh index ba4f4bb478..88d7f13494 100644 --- a/resources/libraries/bash/entry/per_patch_device.sh +++ b/resources/libraries/bash/entry/per_patch_device.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco 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: @@ -39,22 +39,22 @@ source "${BASH_FUNCTION_DIR}/per_patch.sh" || die "Source failed." common_dirs || die check_prerequisites || die set_perpatch_vpp_dir || die -build_vpp_ubuntu_amd64 "CURRENT" || die -set_aside_commit_build_artifacts || die -initialize_csit_dirs || die +git status || die +git describe || die +build_vpp_ubuntu "CURRENT" || die +initialize_csit_dirs "current" || die get_test_code "${1-}" || die get_test_tag_string || die set_perpatch_dut || die -select_topology || die select_arch_os || die -select_build "build_current" || die +select_build "build-root" || die check_download_dir || die activate_virtualenv "${VPP_DIR}" || die generate_tests || die archive_tests || die +prepare_topology || die +select_topology || die activate_docker_topology || die -select_vpp_device_tags || die -compose_pybot_arguments || die -run_pybot || die +run_robot || die move_archives || die -die_on_pybot_error || die +die_on_robot_error || die diff --git a/resources/libraries/bash/entry/per_patch_perf.sh b/resources/libraries/bash/entry/per_patch_perf.sh index 7b64aea67f..9a825a007e 100644 --- a/resources/libraries/bash/entry/per_patch_perf.sh +++ b/resources/libraries/bash/entry/per_patch_perf.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco 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: @@ -44,11 +44,16 @@ source "${BASH_FUNCTION_DIR}/ansible.sh" || die "Source failed." common_dirs || die check_prerequisites || die set_perpatch_vpp_dir || die -build_vpp_ubuntu_amd64 "CURRENT" || die -set_aside_commit_build_artifacts || die -build_vpp_ubuntu_amd64 "PARENT" || die -set_aside_parent_build_artifacts || die -initialize_csit_dirs || die +git status || die +git describe || die +build_vpp_ubuntu "CURRENT" || die +set_aside_build_artifacts "current" || die +git checkout "HEAD~" || die "Failed to checkout parent commit." +git status || die +git describe || die +build_vpp_ubuntu "PARENT" || die +set_aside_build_artifacts "parent" || die +initialize_csit_dirs "parent" "current" || die get_test_code "${1-}" || die get_test_tag_string || die set_perpatch_dut || die @@ -58,8 +63,6 @@ activate_virtualenv "${VPP_DIR}" || die generate_tests || die archive_tests || die reserve_and_cleanup_testbed || die -select_tags || die -compose_pybot_arguments || die # Support for interleaved measurements is kept for future. iterations=1 # 8 for ((iter=0; iter<iterations; iter++)); do @@ -71,16 +74,14 @@ for ((iter=0; iter<iterations; iter++)); do # Testing current first. Good for early failures or for API changes. select_build "build_current" || die check_download_dir || die - run_pybot || die - archive_parse_test_results "csit_current/${iter}" || die - die_on_pybot_error || die + run_robot || die + move_test_results "csit_current/${iter}" || die # TODO: Use less heavy way to avoid apt remove failures. ansible_playbook "cleanup" || die select_build "build_parent" || die check_download_dir || die - run_pybot || die - archive_parse_test_results "csit_parent/${iter}" || die - die_on_pybot_error || die + run_robot || die + move_test_results "csit_parent/${iter}" || die done untrap_and_unreserve_testbed || die compare_test_results # The error code becomes this script's error code. diff --git a/resources/libraries/bash/entry/run_l3fwd.sh b/resources/libraries/bash/entry/run_l3fwd.sh index 5716dec59a..d204e89c6f 100755 --- a/resources/libraries/bash/entry/run_l3fwd.sh +++ b/resources/libraries/bash/entry/run_l3fwd.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco 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: diff --git a/resources/libraries/bash/entry/run_testpmd.sh b/resources/libraries/bash/entry/run_testpmd.sh index 6208487774..1d6b9ee3c6 100755 --- a/resources/libraries/bash/entry/run_testpmd.sh +++ b/resources/libraries/bash/entry/run_testpmd.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco 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: diff --git a/resources/libraries/bash/entry/tox.sh b/resources/libraries/bash/entry/tox.sh index 82b7ef5307..22dfdfe05f 100755 --- a/resources/libraries/bash/entry/tox.sh +++ b/resources/libraries/bash/entry/tox.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco 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: @@ -29,4 +29,12 @@ source "${BASH_FUNCTION_DIR}/common.sh" || { common_dirs || die cd "${CSIT_DIR}" || die activate_virtualenv "${CSIT_DIR}" "${CSIT_DIR}/tox-requirements.txt" || die -tox # Return code is turned into Jenkins job vote. +set +e +# Verbosity is increased so console output shows any unwanted downloads. +tox -vv +TOX_EXIT_STATUS="$?" +set -e +mkdir -p "${CSIT_DIR}/archives" || die +mv *.log "${CSIT_DIR}/archives" || die + +exit "${TOX_EXIT_STATUS}" diff --git a/resources/libraries/bash/entry/check/README.txt b/resources/libraries/bash/entry/tox/README.txt index a72274464c..9ce21e93d0 100644 --- a/resources/libraries/bash/entry/check/README.txt +++ b/resources/libraries/bash/entry/tox/README.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2024 Cisco 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: @@ -11,10 +11,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -This directory contains checker scripts and other files they need. -Each checker script is assumed to be run from tox, +This directory contains tox scripts and other files they need. +Generally, a tox script is either a checker (suitable for automated verify) +or a fixer (manually started, risky as uncommitted edits can be lost). + +In the tox verify job we want to avoid running fixers, +as they can affect what other checkers see +(e.g. autogen fixer could add more too long lines). +That is why we keep fixers separate from checkers in principle, +even for fairly safe tasks (e.g. bumping copyright years). + +Each tox script is assumed to be run from tox, when working directory is set to ${CSIT_DIR}. -Each script should: + +Each checker script should: + Return nonzero exit code when it fails. ++ The tox might ignore the code when the check is not blocking. + Write less verbose output to stderr. @@ -23,5 +33,9 @@ Each script should: + Only the output suitable for automated processing by an external caller should be written to stdout. ++ The level of "less verbose" depends on check and state of codebase. -+ TODO: Should we carefully document which files are - whitelisted/blacklisted for a particulat check? + +Each fixer script should: ++ Perform edits on current filesystem ++ Not assume git is clean (there may be uncommitted edits). ++ Use "git diff HEAD~" to get both comitted and uncomitted edits to analyze. ++ Output whatever it wants (possibly nothing). diff --git a/resources/libraries/bash/entry/check/autogen.sh b/resources/libraries/bash/entry/tox/autogen.sh index 822c50c0ea..40cc2c2066 100644 --- a/resources/libraries/bash/entry/check/autogen.sh +++ b/resources/libraries/bash/entry/tox/autogen.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco 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: @@ -50,8 +50,8 @@ cp -rf "${CSIT_DIR}/tests"/* "${GENERATED_DIR}/tests_tmp"/ # I think archiving the diff is enough. diff_cmd=("diff" "-dur" "${GENERATED_DIR}/tests_tmp" "${GENERATED_DIR}/tests") -# Diff returns RC=1 if output is nonzero, so we do not die on the next line. -lines="$("${diff_cmd[@]}" | tee "autogen.log" | wc -l)" +# Diff returns RC=1 if output is nonzero. +lines="$("${diff_cmd[@]}" | tee "autogen.log" | wc -l || true)" if [ "${lines}" != "0" ]; then # TODO: Decide which text goes to stdout and which to stderr. warn "Autogen conflict, diff sees nonzero lines: ${lines}" diff --git a/resources/libraries/bash/entry/check/copyright_year.sh b/resources/libraries/bash/entry/tox/copyright_year.sh index 2f9bc1fbeb..272763100e 100644 --- a/resources/libraries/bash/entry/check/copyright_year.sh +++ b/resources/libraries/bash/entry/tox/copyright_year.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2024 Cisco 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: @@ -24,10 +24,7 @@ set -exuo pipefail # but not the current year (in the same line). # The offending lines are stored to copyright_year.log (overwriting). # -# 3 lines were chosen, because first two lines could be shebang and empty line, -# and more than 3 lines would start failing on files with multiple copyright -# holders. There, only the last updating entity needs to bump its year, -# and put other copyright lines below. +# 3 lines were chosen, because first two lines could be shebang and empty line. # "set -eu" handles failures from the following two lines. BASH_CHECKS_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" @@ -42,7 +39,7 @@ IFS=$'\n' files=($(git diff --name-only HEAD~ || true)) unset IFS truncate -s 0 "copyright_year.log" || die -# A change can have thousands of files, supress console output in the cycle. +# A change can have thousands of files, supress console output for the cycle. set +x for fil in "${files[@]}"; do # Greps do "fail" on 0 line output, we need to ignore that diff --git a/resources/libraries/bash/entry/tox/fix_copyright_year.sh b/resources/libraries/bash/entry/tox/fix_copyright_year.sh new file mode 100644 index 0000000000..d822f272af --- /dev/null +++ b/resources/libraries/bash/entry/tox/fix_copyright_year.sh @@ -0,0 +1,55 @@ +# Copyright (c) 2024 Cisco 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: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -exuo pipefail + +# This file should be executed from tox, as the assumed working directory +# is different from where this file is located. +# This file does not have executable flag nor shebang, +# to dissuade non-tox callers. + +# This is a fixer script, so be careful before starting it. +# It is recommended to always commit your recent edits before running this, +# and use "git diff" after running this to confirm the edits are correct. +# Otherwise you can lose your edits and introduce bad edits. + +# This script runs a variant of "git diff" command +# to get the list of edited files, and few sed commands to edit the year +# if "20.." pattern matches in first 3 lines. +# No detection of "copyright", so edits can apply at surprising places. + +# 3 lines were chosen, because first two lines could be shebang and empty line. + +# "set -eu" handles failures from the following two lines. +BASH_CHECKS_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" +BASH_FUNCTION_DIR="$(readlink -e "${BASH_CHECKS_DIR}/../../function")" +source "${BASH_FUNCTION_DIR}/common.sh" || { + echo "Source failed." >&2 + exit 1 +} + +year=$(date +'%Y') +IFS=$'\n' +files=($(git diff --name-only HEAD~ || true)) +unset IFS +# A change can have thousands of files, supress console output for the cycle. +set +x +for fil in "${files[@]}"; do + if [[ -f "${fil}" ]]; then + sed -i "1 s/20../${year}/g" "${fil}" + sed -i "2 s/20../${year}/g" "${fil}" + sed -i "3 s/20../${year}/g" "${fil}" + # Else the file was actually deleted and sed would fail. + fi +done +set -x diff --git a/resources/libraries/bash/entry/check/gpl_license.sh b/resources/libraries/bash/entry/tox/gpl_license.sh index a1c46a0e90..7112075883 100644 --- a/resources/libraries/bash/entry/check/gpl_license.sh +++ b/resources/libraries/bash/entry/tox/gpl_license.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco 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: diff --git a/resources/libraries/bash/entry/check/line.sh b/resources/libraries/bash/entry/tox/line.sh index 932f3cdbe9..a90fc22cae 100644 --- a/resources/libraries/bash/entry/check/line.sh +++ b/resources/libraries/bash/entry/tox/line.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco 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: diff --git a/resources/libraries/bash/entry/check/new_line.sh b/resources/libraries/bash/entry/tox/new_line.sh index 2e24c0256b..a8fb38f73e 100644 --- a/resources/libraries/bash/entry/check/new_line.sh +++ b/resources/libraries/bash/entry/tox/new_line.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco 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: diff --git a/resources/libraries/bash/entry/check/pylint.sh b/resources/libraries/bash/entry/tox/pylint.sh index 919e140f28..a3e0f8ee14 100644 --- a/resources/libraries/bash/entry/check/pylint.sh +++ b/resources/libraries/bash/entry/tox/pylint.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco 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: @@ -19,7 +19,8 @@ set -exuo pipefail # to dissuade non-tox callers. # This script runs pylint and propagates its exit code. -# Config is taken from pylint.cfg, and proper virtualenv is assumed to be active. +# Config is taken from pylint.cfg, +# and proper virtualenv is assumed to be active. # The pylint output stored to pylint.log (overwriting). # "set -eu" handles failures from the following two lines. @@ -29,7 +30,7 @@ source "${BASH_FUNCTION_DIR}/common.sh" || { echo "Source failed." >&2 exit 1 } -pylint_args=("--rcfile=pylint.cfg" "resources/") +pylint_args=("--rcfile=pylint.cfg" "resources/" "GPL/traffic_scripts") if pylint "${pylint_args[@]}" > "pylint.log"; then warn warn "Pylint checker: PASS" diff --git a/resources/libraries/bash/entry/with_oper_for_vpp.sh b/resources/libraries/bash/entry/with_oper_for_vpp.sh index 23c0d8a9d1..f9d7829bd2 100644 --- a/resources/libraries/bash/entry/with_oper_for_vpp.sh +++ b/resources/libraries/bash/entry/with_oper_for_vpp.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2018 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco 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: |