modify ci test
[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-zapi 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
23 # test if prometheus query worked
24 echo $cpu_load
25
26 regex='\[[0-9.]*, .*\]'
27
28 if [[ $cpu_load =~ $regex ]] ; then
29 echo " cpu monitor test OK"
30 exit 0
31 else
32 echo "cpu monitor test not OK"
33 exit 1
34 fi
35
36