CSIT-1260 Create initial version of bootstrap including VF reservation
[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 # This entry script does not change CSIT branch,
19 # use "with_oper_for_vpp.sh" wrapper for that.
20 #
21 # Assumptions:
22 # + There is a directory holding VPP repo with patch under test checked out.
23 # + It contains csit subdirectory with CSIT code to use (this script is there).
24 # + Everything needed to build VPP is already installed locally.
25 # Consequences:
26 # + At the end, VPP repo has parent commit checked out and built.
27 # + Directories build_root, build and csit are reset during the run.
28 # + The following directories (relative to VPP repo) are (re)created:
29 # ++ csit_new, csit_parent, build_new, build_parent,
30 # ++ archive, csit/archive, csit_download_dir.
31
32 # TODO: Implement some kind of VPP build caching.
33
34 # "set -eu" handles failures from the following two lines.
35 BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))"
36 BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")"
37 source "${BASH_FUNCTION_DIR}/common.sh" || {
38     echo "Source failed." >&2
39     exit 1
40 }
41 source "${BASH_FUNCTION_DIR}/per_patch.sh" || die "Source failed."
42 common_dirs || die
43 set_perpatch_vpp_dir || die
44 build_vpp_ubuntu_amd64 "NEW" || die
45 prepare_build_parent || die
46 build_vpp_ubuntu_amd64 "PARENT" || die
47 prepare_test || die
48 ## Replace previous 4 lines with this to speed up testing.
49 #download_builds "REPLACE_WITH_URL" || die
50 initialize_csit_dirs || die
51 get_test_code "${1-}" || die
52 get_test_tag_string || die
53 set_perpatch_dut || die
54 select_topology || die
55 activate_virtualenv "${VPP_DIR}" || die
56 reserve_testbed || die
57 select_tags || die
58 compose_pybot_arguments || die
59 iterations=8
60 for ((iter=0; iter<iterations; iter++)); do
61     # TODO: Use less heavy way to avoid apt remove falilures.
62     cleanup_topo
63     select_build "build_parent" || die
64     check_download_dir || die
65     run_pybot || die
66     copy_archives || die
67     archive_parse_test_results "csit_parent/${iter}" || die
68     die_on_pybot_error || die
69     cleanup_topo
70     select_build "build_new" || die
71     check_download_dir || die
72     run_pybot || die
73     copy_archives || die
74     archive_parse_test_results "csit_new/${iter}" || die
75     die_on_pybot_error || die
76 done
77 untrap_and_unreserve_testbed || die
78 compare_test_results  # The error code becomes this script's error code.
79 # TODO: After merging, make sure archiving works as expected.