-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunchTest.sh
executable file
·82 lines (74 loc) · 1.96 KB
/
launchTest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
###Get CampaignName and Cerberus Host
while getopts a:h:c:k:C:E:R:T: flag
do
case "${flag}" in
a) AUTHOR=${OPTARG};;
h) HOST=${OPTARG};;
c) CAMPAIGN=${OPTARG};;
k) APIKEY=${OPTARG};;
C) set -f
IFS=,
COUNTRY=($OPTARG);;
E) set -f
IFS=,
ENVIRONMENT=($OPTARG);;
R) set -f
IFS=,
ROBOT=($OPTARG);;
T) TAG=${OPTARG};;
esac
done
EXTRA_ARGS=()
echo "Author: $AUTHOR";
echo "Cerberus Host: $HOST";
echo "Campaign Name: $CAMPAIGN";
if [[ "$COUNTRY" != "" ]]; then
echo "Override Country: ${COUNTRY[@]}";
for i in "${COUNTRY[@]}"; do
EXTRA_ARGS+=(-d "country=${i}")
done
fi
if [[ "$ENVIRONMENT" != "" ]]; then
echo "Override Environment: ${ENVIRONMENT[@]}";
for i in "${ENVIRONMENT[@]}"; do
EXTRA_ARGS+=(-d "environment=${i}")
done
fi
if [[ "$ROBOT" != "" ]]; then
echo "Override Robot: ${ROBOT[@]}";
for i in "${ROBOT[@]}"; do
EXTRA_ARGS+=(-d "robot=${i}")
done
fi
###If tag not provided, generate using Campaign Name, Commiter and UnixTimestamp
if [[ "$TAG" != "" ]];
then
echo "Override Tag: $TAG";
tag=$TAG
else
tag=$CAMPAIGN.$AUTHOR.$(date +%y%m%d-%H%M%S)
fi
EXTRA_ARGS+=(-d "tag=$tag")
###Run Campaign
curl -s --request POST --url "$HOST/AddToExecutionQueueV003" -d campaign=$CAMPAIGN "${EXTRA_ARGS[@]}" -H "apikey:$APIKEY"
echo
sleep 3
###Loop on resultCI Until end of campaign
num=1
while [ $num -lt 300 ]
do
result=$(curl -s --request POST --url "$HOST/ResultCIV004" -d tag=$tag -H "apikey:$APIKEY"| jq -r '.result')
echo "Check on Campaign ($num/300) with result : " $result
if [[ "$result" != "PE" ]]; then
break
fi
sleep 3
((num=num+1))
# echo "Campaign still running... Let's try again."
done
if [[ "$result" != "OK" ]]; then
echo "Campaign Failed. CIScore Higher than threshold !!!"
exit 1
fi
echo "Campaign Successful. Congratulation !!!"