2 export DOCKER_HOST
="unix:///var/run/docker.sock"
8 # Wait until a line appears in the screen session.
9 # It starts from the beginning of the log and exits after the first match.
11 #timeout -k 3s ${T} stdbuf -o0 grep -q -m 1 "^${1}" <(tail -F -n+0 screenlog.0)
12 # (HACK) As Jenkins blocks subshell, we must use an intermediate script
18 if strings screenlog.0 | grep -m 1 "\${1}"; then
25 timeout
-k 3s
${T} ${SUBF} "${1}" || RES=$?
27 if [ ! "$RES" = "0" ]; then
29 echo -e "\n\n\n(Debug
) Error
while waiting
for a pattern to appear
in screenlog
.0\n\n\n"
36 # Send a command to the screen session, aka into the containernet prompt
37 screen -S sonemu -X stuff "${1}^M
"
41 # Send a command inside the vnf1 container
42 docker exec -t "mn.
${1}" /bin/bash -c "${2}" && sync
46 if ! screen --version | grep 'Screen version'; then
47 # Install screen and do an initial cleanup
48 sudo apt-get update -qq -y
49 sudo apt-get install -y screen
50 screen --version | grep 'Screen version'
52 if ! timeout --version; then
53 # Install coreutils for the timeout command
54 sudo apt-get update -qq -y
55 sudo apt-get install -y coreutils
59 pkill --signal KILL -f 'SCREEN -L -S sonemu' || true
65 # Start containernet with a topology
66 screen -L -S sonemu -d -m sudo python src/emuvim/examples/simple_topology.py
67 # Setup screen for immediate flusing
68 screen -S sonemu -X logfile flush 0
69 # Wait for the cli to start
70 W '^*** Starting CLI:' 60s
74 son-emu-cli compute start -d datacenter1 -n vnf1 && sleep 1s
76 son-emu-cli compute start -d datacenter1 -n vnf2 && sleep 1s
78 son-emu-cli compute list && sleep 1s
79 sync # avoid text overlapping
82 Cmd 'sh echo "... starting various checks
"'
83 sync # avoid text overlappin
88 IP_2=$(Vnf vnf2 'ip -f inet -o addr show vnf2-eth0' | cut -d\ -f 7 | cut -d/ -f 1)
89 # IP_1=$(Vnf vnf1 'ip -f inet -o addr show vnf1-eth0' | cut -d\ -f 7 | cut -d/ -f 1)
90 OUTPUT_A=$(Vnf vnf1 "ping -v -c 2 ${IP_2}")
92 # Wait for sonemu to end
95 echo -e '\n\n******************* Result ******************\n\n'
97 echo -e '\n\n*********************************************\n\n'
100 # Check the ping result
101 if echo ${OUTPUT_A} | grep ', 2 received'; then
102 echo 'No problems detected'
105 echo 'Ping is broken !'