-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_proxy.sh
executable file
·74 lines (61 loc) · 1.99 KB
/
test_proxy.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
#!/bin/bash
LOCAL_IP="127.0.0.1:8080"
IP_CLOUD="18.196.210.14"
PORT_CLOUD="8080"
CONNECTION=true
N=1
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-a|--address-cloud)
IP_CLOUD="$2"
shift # past argument
shift # past value
;;
-p|--port-cloud)
PORT_CLOUD="$2"
shift # past argument
shift # past value
;;
-n)
N="$2"
shift # past argument
shift # past value
;;
--no-connection)
CONNECTION=false
shift # past argument
;;
*) # unknown option
print >&2 "Usage: $0 [-n number of cicles for the test] [--no-connection] [-a|--address-cloud address-cloud] [-p|--port-cloud port-cloud] "
exit 1;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
echo "Local node info"
curl --silent "http://$LOCAL_IP/function/func_nodeinfo" -d "" | grep Hostname
if [ "$CONNECTION" = true ];
then
echo "Cloud node info"
curl --silent --max-time 5 "http://$IP_CLOUD:$PORT_CLOUD/function/func_nodeinfo" -d "" | grep Hostname
fi
############
echo "Testing functions"
# echo on
#set -x
set -v
for i in `seq 2 $N`
do
curl --silent "http://$LOCAL_IP/function/weight_scale" -d '{"func":"func_light","query":"ucb1"}'
curl --silent "http://$LOCAL_IP/function/proxy" -d '{"func":"func_light", "data":{"value": true}}'
curl --silent "http://$LOCAL_IP/function/weight_scale" -d '{"func":"func_heavy","query":"ucb1"}'
curl --silent "http://$LOCAL_IP/function/proxy" -d '{"func":"func_heavy", "data":{"value": false}}'
curl --silent "http://$LOCAL_IP/function/weight_scale" -d '{"func":"func_super_heavy","query":"ucb1"}'
curl --silent "http://$LOCAL_IP/function/proxy" -d '{"func":"func_super_heavy", "data":{"value": true}}'
curl --silent "http://$LOCAL_IP/function/weight_scale" -d '{"func":"func_obese_heavy","query":"ucb1"}'
curl --silent "http://$LOCAL_IP/function/proxy" -d '{"func":"func_obese_heavy", "data":{"value": false}}'
done
set +v
echo "Function's Overall stats"
curl "http://$LOCAL_IP/function/get_overall_stats" | json_pp