CSIT-1135: Scripts for VPP per-patch testing
[csit.git] / resources / libraries / bash / entry / per_patch_perf.sh
1 #!/usr/bin/env bash
2
3 # Copyright (c) 2018 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 set -exuo pipefail
17
18 # Assumptions:
19 # + There is a directory holding VPP repo with patch under test checked out.
20 # + It contains csit subdirectory with CSIT code to use (this script is there).
21 # + Everything needed to build VPP is already installed locally.
22 # Consequences:
23 # + At the end, VPP repo has parent commit checked out and built.
24 # + Directories build_root, dpdk and csit are reset during the run.
25 # + The following directories (relative to VPP repo) are (re)created:
26 # ++ csit_new, csit_parent, build_new, build_parent,
27 # ++ archive, csit/archive, csit_download_dir.
28 # This entry script currently does not need any environment variable set.
29
30 # TODO: Implement some kind of VPP build caching.
31
32 # "set -eu" handles failures from the following two lines.
33 BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))"
34 BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")"
35 source "${BASH_FUNCTION_DIR}/common.sh" || {
36     echo "Source failed." >&2
37     exit 1
38 }
39 source "${BASH_FUNCTION_DIR}/per_patch.sh" || die "Source failed."
40 common_dirs || die
41 set_perpatch_vpp_dir || die
42 build_vpp_ubuntu_amd64 "NEW" || die
43 prepare_build_parent || die
44 build_vpp_ubuntu_amd64 "PARENT" || die
45 prepare_test_new || die
46 ## Replace previous 4 lines with this to speed up testing.
47 #download_builds "REPLACE_WITH_URL" || die
48 get_test_tag_string || die
49 get_test_code "${1-}" || die
50 set_perpatch_dut || die
51 select_topology || die
52 activate_virtualenv "${VPP_DIR}" || die
53 reserve_testbed || die
54 select_tags || die
55 compose_pybot_arguments || die
56 check_download_dir || die
57 run_pybot "10" || die
58 copy_archives || die
59 die_on_pybot_error || die
60 prepare_test_parent || die
61 check_download_dir || die
62 run_pybot "10" || die
63 untrap_and_unreserve_testbed || die
64 copy_archives || die
65 die_on_pybot_error || die
66 compare_test_results  # The error code becomes this script's error code.
67 # TODO: After merging, make sure archiving works as expected.