blob: 5bf4e847880b936a87e78df56dcdef5a7146a502 [file] [log] [blame]
cgeoffroy549e20f2017-03-03 16:10:40 +01001#!/bin/bash
2export DOCKER_HOST="unix:///var/run/docker.sock"
3
4set -e
5set -x
6
7W() {
8 # Wait until a line appears in the screen session
9 local T=${2:-10s}
10 timeout -k 3s ${T} grep -q "^${1}" <(tail -f screenlog.0)
11}
12
13Cmd() {
14 # Send a command to the screen session, aka into the containernet prompt
15 screen -S sonemu -X stuff "${1}^M"
16}
17
18
19if ! screen --version | grep 'Screen version'; then
20 # Install screen and do an initial cleanup
21 sudo apt-get update -qq -y
22 sudo apt-get install -y screen
23 screen --version | grep 'Screen version'
24fi
25# Initial cleanup
26pkill 'screen' || true
27screen -wipe || true
28rm -f screenlog.0
29
30
31# Start containernet with a topology
32screen -L -S sonemu -d -m python src/emuvim/examples/simple_topology.py
33# Setup screen for immediate flusing
34screen -S sonemu -X logfile flush 0
35# Wait for the cli to start
36W '*** Starting CLI:'
37# Print nodes
38Cmd 'nodes'
39# Start vnf1
40son-emu-cli compute start -d datacenter1 -n vnf1 && sleep 1s
41# Start vnf2
42son-emu-cli compute start -d datacenter1 -n vnf2 && sleep 1s
43# List compute nodes
44son-emu-cli compute list && sleep 1s
45# Gather some infos
46Cmd 'sh echo "... starting various checks"'
47Cmd 'vnf1 ifconfig && echo "... checked vnf1"'
48W "... checked vnf1"
49Cmd 'vnf2 ifconfig && echo "... checked vnf2"'
50W "... checked vnf2"
51# Try to ping vnfs
52Cmd 'vnf1 ping -c 2 vnf2 || echo "... checked ping"'
53W "... checked ping" 20s
54Cmd 'quit'
55# Wait for sonemu to end
56W '*** Done'
57
58echo -e '\n\n************i****** Result ******************\n\n'
59strings screenlog.0
60echo -e '\n\n*********************************************\n\n'
61
62
63# Check the ping result
64if grep ', 2 received' screenlog.0; then
65 echo 'No problems detected'
66 exit 0
67else
68 echo 'Ping is broken !'
69 exit 1
70fi
71
72
73# Cleanup
74rm -f screenlog.0