da5f142299f030de9ba95df2cdd0d59981cb1503
[ci-management.git] / jjb / vpp / include-raw-vpp-csit-functional.sh
1 #!/bin/bash
2 set -xeu -o pipefail
3
4 # Get CSIT branch from which to test from
5 # running build-root/scripts/csit-test-branch
6 if [ -x build-root/scripts/csit-test-branch ]; then
7     CSIT_BRANCH=`build-root/scripts/csit-test-branch`;
8 fi
9
10 # check CSIT_BRANCH value
11 if [ "$CSIT_BRANCH" == "" ]; then
12     echo "CSIT_BRANCH not provided => 'latest' will be used"
13     CSIT_BRANCH="latest"
14 fi
15
16 # clone csit
17 git clone --depth 1 --no-single-branch https://gerrit.fd.io/r/csit
18
19 # if the git clone fails, complain clearly and exit
20 if [ $? != 0 ]; then
21     echo "Failed to run: git clone --depth 1 --no-single-branch https://gerrit.fd.io/r/csit"
22     exit 1
23 fi
24
25 cp build-root/*.deb csit/
26 if [ -e dpdk/vpp-dpdk-dkms*.deb ]
27 then
28     cp dpdk/vpp-dpdk-dkms*.deb csit/
29 else
30     cp /w/dpdk/vpp-dpdk-dkms*.deb csit/
31 fi
32
33 # Check for CSIT_REF test file
34 if [ -e CSIT_REF ]; then
35     source CSIT_REF
36 fi
37
38 # If also testing a specific csit refpoint look for CSIT_REF
39 if [[ -v CSIT_REF ]]; then
40     (cd csit ; git fetch ssh://rotterdam-jobbuilder@gerrit.fd.io:29418/csit $CSIT_REF && git checkout FETCH_HEAD)
41 else
42     cd csit
43     if [ "$CSIT_BRANCH" == "latest" ]; then
44         # set required CSIT branch_id based on VPP master branch; by default use 'oper'
45         case "$VPP_BRANCH" in
46             master )
47                 BRANCH_ID="oper"
48                 ;;
49             stable/1710 )
50                 BRANCH_ID="oper-rls1710"
51                 ;;
52             stable/1801 )
53                 BRANCH_ID="oper-rls1801"
54                 ;;
55             * )
56                 BRANCH_ID="oper"
57         esac
58
59         # get the latest verified version of the required branch
60         CSIT_BRANCH=$(echo $(git branch -r | grep -E "${BRANCH_ID}-[0-9]+" | tail -n 1))
61
62         if [ "${CSIT_BRANCH}" == "" ]; then
63             echo "No verified CSIT branch found - exiting"
64             exit 1
65         fi
66
67         # remove 'origin/' from the branch name
68         CSIT_BRANCH=$(echo ${CSIT_BRANCH#origin/})
69     fi
70     # checkout the required csit branch
71     git checkout ${CSIT_BRANCH}
72
73     if [ $? != 0 ]; then
74         echo "Failed to checkout the required CSIT branch: ${CSIT_BRANCH}"
75         exit 1
76     fi
77 fi
78
79 # execute csit bootstrap script if it exists
80 if [ -e bootstrap.sh ]
81 then
82     # make sure that bootstrap.sh is executable
83     chmod +x bootstrap.sh
84     # run the script
85     ./bootstrap.sh *.deb
86 else
87     echo 'ERROR: No bootstrap.sh found'
88     exit 1
89 fi
90
91 # vim: ts=4 ts=4 sts=4 et :