Merge pull request #106 from stevenvanrossem/master
update son-monitor test scripts
diff --git a/README.md b/README.md
index 9b0038a..b05908a 100755
--- a/README.md
+++ b/README.md
@@ -84,8 +84,7 @@
* `son-emu-cli compute list`
* First terminal:
* `containernet> vnf1 ping -c 2 vnf2`
-* Second terminal:
- * `son-emu-cli monitor get_rate -vnf vnf1`
+
### Run Unit Tests
* `cd ~/son-emu`
diff --git a/setup_cli_only.py b/setup_cli_only.py
deleted file mode 100755
index 119cf8c..0000000
--- a/setup_cli_only.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from setuptools import setup, find_packages
-
-setup(name='emuvim',
- version='0.0.1',
- license='Apache 2.0',
- description='emuvim is a VIM for the SONATA platform',
- url='http://github.com/sonata-emu',
- author_email='sonata-dev@sonata-nfv.eu',
- package_dir={'': 'src'},
- # packages=find_packages('emuvim', exclude=['*.test', '*.test.*', 'test.*', 'test']),
- packages=find_packages('src'),
- install_requires=[
- 'zerorpc',
- 'tabulate',
- 'argparse',
- ],
- zip_safe=False,
- entry_points={
- 'console_scripts': [
- 'son-emu-cli=emuvim.cli.son_emu_cli:main',
- ],
- },
- setup_requires=['pytest-runner'],
- tests_require=['pytest'],
-)
\ No newline at end of file
diff --git a/src/emuvim/examples/monitoring_demo_topology.py b/src/emuvim/examples/monitoring_demo_topology.py
index 0650be4..9a86534 100755
--- a/src/emuvim/examples/monitoring_demo_topology.py
+++ b/src/emuvim/examples/monitoring_demo_topology.py
@@ -116,9 +116,9 @@
can be executed again and again.
"""
net.start()
- net.CLI()
+ #net.CLI()
# when the user types exit in the CLI, we stop the emulator
- net.stop()
+ #net.stop()
def main():
diff --git a/utils/ci/test_sdk_monitor.sh b/utils/ci/test_sdk_monitor.sh
index 26f939f..12cc44d 100755
--- a/utils/ci/test_sdk_monitor.sh
+++ b/utils/ci/test_sdk_monitor.sh
@@ -1,15 +1,31 @@
#!/bin/bash
-# test if a vnf can be monitored and deployed
+# test if a vnf can be deployed and monitored
+#start test emulator topology
+python src/emuvim/examples/monitoring_demo_topology.py &
+
+# start a vnf
+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)'
+# monitor a metric
+son-emu-cli monitor setup_metric -vnf vnf1:output --metric tx_packets
+
+sleep 5
+
+# check if metric is monitored as expected
cpu_load=$(son-emu-cli monitor prometheus -d datacenter1 -vnf vnf1 -q 'sum(rate(container_cpu_usage_seconds_total{id="/docker/<uuid>"}[10s]))')
+# stop the monitor
+son-emu-cli monitor stop_metric -vnf vnf1:output --metric tx_packets
+
+#stop the vnf
+son-emu-cli compute stop -d datacenter1 -n vnf1
+
# test if prometheus query worked
-regex="[0-9.]+, [0-9.']+"
if [[ $cpu_load =~ $regex ]] ; then
- echo "OK"
+ echo " cpu monitor test OK"
exit 0
else
echo $cpu_load
- echo "not OK"
+ echo "cpu monitor test not OK"
exit 1
fi
diff --git a/utils/docker/entrypoint.sh b/utils/docker/entrypoint.sh
index 7e72914..1820515 100755
--- a/utils/docker/entrypoint.sh
+++ b/utils/docker/entrypoint.sh
@@ -4,4 +4,9 @@
#cp /containernet/util/docker/entrypoint.sh /tmp/x.sh
#cat /tmp/x.sh | awk 'NR==1{print; print "set -x"} NR!=1' > /conteinernet/util/docker/entrypoint.sh
+# this cannot be done from the Dockerfile since we have the socket not mounted during build
+# this image is needed for the monitoring in son-emu
+echo 'Pulling the "google/cadvisor" image ... please wait'
+docker pull 'google/cadvisor'
+
exec /containernet/util/docker/entrypoint.sh $*