Merge "CSIT-PERF: New trigger design"
[ci-management.git] / jjb / vpp / include-raw-vpp-csit-verify-perf.sh
1 #!/bin/bash
2
3 set -xeu -o pipefail
4
5 if [[ ${GERRIT_EVENT_TYPE} == 'comment-added' ]]; then
6     TRIGGER=`echo ${GERRIT_EVENT_COMMENT_TEXT} \
7         | grep -oE '(perftest$|perftest[[:space:]].+$)'`
8 else
9     TRIGGER=''
10 fi
11 # Export test type.
12 export TEST_TAG="VERIFY-PERF-PATCH"
13 # Export test tags as string.
14 export TEST_TAG_STRING=${TRIGGER#$"perftest"}
15
16 # Get CSIT branch from which to test from
17 # running build-root/scripts/csit-test-branch
18 if [ -x build-root/scripts/csit-test-branch ]; then
19     CSIT_BRANCH=`build-root/scripts/csit-test-branch`;
20 fi
21
22 # check CSIT_BRANCH value
23 if [ "$CSIT_BRANCH" == "" ]; then
24     echo "CSIT_BRANCH not provided => 'latest' will be used"
25     CSIT_BRANCH="latest"
26 fi
27
28 # clone csit
29 git clone --depth 1 --no-single-branch https://gerrit.fd.io/r/csit
30
31 # if the git clone fails, complain clearly and exit
32 if [ $? != 0 ]; then
33     echo "Failed to run: git clone --depth 1 --no-single-branch https://gerrit.fd.io/r/csit"
34     exit 1
35 fi
36
37 cp build-root/*.deb csit/
38 if [ -e dpdk/vpp-dpdk-dkms*.deb ]
39 then
40     cp dpdk/vpp-dpdk-dkms*.deb csit/
41 else
42     cp /w/dpdk/vpp-dpdk-dkms*.deb csit/ 2>/dev/null || :
43     cp /var/cache/apt/archives/vpp-dpdk-dkms*.deb csit/ 2>/dev/null || :
44 fi
45
46 cd csit
47
48 if [ "$CSIT_BRANCH" == "latest" ]; then
49     # set required CSIT branch_id based on VPP master branch; by default use 'oper'
50     case "$VPP_BRANCH" in
51         master )
52             BRANCH_ID="oper"
53             ;;
54         stable/1710 )
55             BRANCH_ID="oper-rls1710"
56             ;;
57         stable/1801 )
58             BRANCH_ID="oper-rls1801"
59             ;;
60         * )
61             BRANCH_ID="oper"
62     esac
63
64     # get the latest verified version of the required branch
65     CSIT_BRANCH=$(echo $(git branch -r | grep -E "${BRANCH_ID}-[0-9]+" | tail -n 1))
66
67     if [ "${CSIT_BRANCH}" == "" ]; then
68         echo "No verified CSIT branch found - exiting"
69         exit 1
70     fi
71
72     # remove 'origin/' from the branch name
73     CSIT_BRANCH=$(echo ${CSIT_BRANCH#origin/})
74 fi
75
76 # checkout the required csit branch
77 git checkout ${CSIT_BRANCH}
78
79 if [ $? != 0 ]; then
80     echo "Failed to checkout the required CSIT branch: ${CSIT_BRANCH}"
81     exit 1
82 fi
83
84 # execute csit bootstrap script if it exists
85 if [ ! -e bootstrap-verify-perf.sh ]
86 then
87     echo 'ERROR: No bootstrap-verify-perf.sh found'
88     exit 1
89 fi
90
91 # make sure that bootstrap-verify-perf.sh is executable
92 chmod +x bootstrap-verify-perf.sh
93 # run the script
94 ./bootstrap-verify-perf.sh *.deb
95
96 # vim: ts=4 ts=4 sts=4 et :