Merge remote-tracking branch 'upstream/master'
[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
10 sleep 1
11
12 # monitor a metric
13 son-emu-cli monitor setup_metric -vnf vnf1:output --metric tx_packets
14
15 sleep 5
16
17 # check if metric is monitored as expected
18 cpu_load=$(son-emu-cli monitor prometheus -d datacenter1 -vnf vnf1 -q 'sum(rate(container_cpu_usage_seconds_total{id="/docker/<uuid>"}[10s]))')
19
20 sleep 1
21
22 # stop the monitor
23 son-emu-cli monitor stop_metric -vnf vnf1:output --metric tx_packets
24
25 sleep 1
26
27 #stop the vnf
28 son-emu-cli compute stop -d datacenter1 -n vnf1
29
30 # test if prometheus query worked
31 echo $cpu_load
32
33 regex='\[[0-9.]*, .*\]'
34
35 if [[ $cpu_load =~ $regex ]] ; then
36 echo " cpu monitor test OK"
37 exit 0
38 else
39 echo "cpu monitor test not OK"
40 exit 1
41 fi
42
43