-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathstartMockAgents.sh
executable file
·76 lines (64 loc) · 2.06 KB
/
startMockAgents.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
#!/bin/bash
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
wait_forever=true
DATASET=default
while (( "$#" )); do
if [ "$1" == "--no-wait" ]; then
wait_forever=false
shift 1
elif [ "$1" == "--dataset" ]; then
DATASET="${2}"
shift 2
else
if [ "$1" != "-h" ]; then
echo "ERROR: invalid argument '$1'"
fi
echo "USAGE: startMockAgents.sh [--no-wait] [--dataset setName]"
echo ""
echo "where"
echo " --no-wait do not wait"
echo " --dataset setName identifies the dataset to use"
exit 1
fi
done
if [ ! -d ${DIR}/ui/features/data/${DATASET} ]; then
echo "ERROR: directory '${DIR}/ui/features/data/${DATASET}' does not exist"
exit 1
fi
HOST_IP=`hostname -i`
if [[ $HOST_IP == 127* ]]; then
echo "Overriding default HOST_IP ($HOST_IP)"
HOST_IP=$(ip addr show docker0 | grep -w inet | awk {'print $2'} | cut -d/ -f1)
fi
echo "Using HOST_IP=$HOST_IP"
set -e
if [ ! -f ${DIR}/mockAgent/mockAgent ]; then
echo "mockAgent binary doesn't exist. compiling it.."
cd ${DIR}/mockAgent
go build
fi
set -x
cd ${DIR}
${DIR}/mockAgent/mockAgent --config-file ${DIR}/ui/features/data/${DATASET}/hosts.json --host defaultHost --address ${HOST_IP} &
${DIR}/mockAgent/mockAgent --config-file ${DIR}/ui/features/data/${DATASET}/hosts.json --host host2 --address ${HOST_IP} &
${DIR}/mockAgent/mockAgent --config-file ${DIR}/ui/features/data/${DATASET}/hosts.json --host host3 --address ${HOST_IP} &
${DIR}/mockAgent/mockAgent --config-file ${DIR}/ui/features/data/${DATASET}/hosts.json --host host4 --address ${HOST_IP} &
${DIR}/mockAgent/mockAgent --config-file ${DIR}/ui/features/data/${DATASET}/hosts.json --host host5 --address ${HOST_IP} &
set +x
WAIT=0
while [ $WAIT -lt 5 ]; do
echo "."
sleep 1s
let WAIT=WAIT+1
done
if jobs -l | grep -q "Done";
then
jobs 1>&2
echo "Mock agent(s) failed, closing" 1>&2
pkill mockAgent
exit 1;
fi
echo "Mock agents up, test suite may be run"
while $wait_forever ;
do sleep 5m;
done