update monitoring scripts
[osm/vim-emu.git] / utils / ci / test_sdk_monitor.sh
1 #!/bin/bash
2 # test if a vnf can be deployed and monitored
3
4 #start test emulator topology
5 #python src/emuvim/examples/monitoring_demo_topology.py &
6
7 # start a vnf
8 son-emu-cli compute start -d datacenter1 -n vnf1 --net '(id=input,ip=10.0.10.3/24),(id=output,ip=10.0.10.4/24)'
9 # monitor a metric
10 son-emu-cli monitor setup_metric -vnf vnf1:output --metric tx_packets
11
12 sleep 5
13
14 # check if metric is monitored as expected
15 cpu_load=$(son-emu-cli monitor prometheus -d datacenter1 -vnf vnf1 -q 'sum(rate(container_cpu_usage_seconds_total{id="/docker/<uuid>"}[10s]))')
16
17 # stop the monitor
18 son-emu-cli monitor stop_metric -vnf vnf1:output --metric tx_packets
19
20 #stop the vnf
21 son-emu-cli compute stop -d datacenter1 -n vnf1
22
23 # test if prometheus query worked
24 echo $cpu_load
25 if [[ $cpu_load =~ $regex ]] ; then
26 echo " cpu monitor test OK"
27 exit 0
28 else
29 echo "cpu monitor test not OK"
30 exit 1
31 fi