]> git.proxmox.com Git - ovs.git/blob - tests/run-ryu
dpif-netdev: Incremental addition/deletion of PMD threads.
[ovs.git] / tests / run-ryu
1 #! /bin/sh
2
3 run () {
4 echo "$@"
5 "$@" || exit 1
6 }
7
8 # Put built tools early in $PATH.
9 builddir=`pwd`
10 if test ! -e vswitchd/ovs-vswitchd; then
11 echo >&2 'not in build directory, please change directory or run via \"make check-ryu'
12 exit 1
13 fi
14 PATH=$builddir/ovsdb:$builddir/vswitchd:$builddir/utilities:$PATH; export PATH
15
16 # Find srcdir.
17 case $srcdir in
18 '') srcdir=$builddir ;;
19 /*) ;;
20 *) srcdir=`pwd`/$srcdir ;;
21 esac
22 if test ! -e "$srcdir"/README.rst; then
23 echo >&2 'source directory not found, please set $srcdir or run via \"make check-ryu'
24 exit 1
25 fi
26
27 # Make sure ryu is available.
28 if test X"$RYUDIR" = X; then
29 RYUDIR=$srcdir/../ryu
30 fi
31 PYTHONPATH=$RYUDIR:$PYTHONPATH; export PYTHONPATH
32 PATH=$RYUDIR/bin:$PATH; export PATH
33 if (ryu-manager --version) >/dev/null 2>&1; then
34 :
35 else
36 echo >&2 '"ryu-manager" binary not found or cannot be run, please set $RYUDIR'
37 exit 1
38 fi
39
40 # Create sandbox.
41 rm -rf sandbox
42 mkdir sandbox
43 cd sandbox
44 sandbox=`pwd`
45
46 # Set up environment for OVS programs to sandbox themselves.
47 OVS_RUNDIR=$sandbox; export OVS_RUNDIR
48 OVS_LOGDIR=$sandbox; export OVS_LOGDIR
49 OVS_DBDIR=$sandbox; export OVS_DBDIR
50 OVS_SYSCONFDIR=$sandbox; export OVS_SYSCONFDIR
51
52 for signal in 0 1 2 3 13 14 15; do
53 trap 'kill `cat $sandbox/*.pid`; trap - $signal; kill -$signal $$' $signal
54 done
55
56 # Create database and start ovsdb-server.
57 touch .conf.db.~lock~
58 rm -f conf.db
59 run ovsdb-tool create conf.db "$srcdir"/vswitchd/vswitch.ovsschema
60 run ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \
61 --remote=punix:"$sandbox"/db.sock
62
63 # Start ovs-vswitchd.
64 run ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file \
65 --enable-dummy --disable-system -vvconn -vnetdev_dummy
66
67 # Add bridges for Ryu to use, and configure them to connect to Ryu.
68 for config in \
69 'br0 0000000000000001 a b pstream=punix' \
70 'br1 0000000000000002 c d stream=unix'
71 do
72 set $config
73 bridge=$1 dpid=$2 port1=$3 port2=$4 stream_mode=$5
74 run ovs-vsctl --no-wait \
75 -- add-br $bridge \
76 -- set bridge $bridge \
77 datapath-type=dummy fail-mode=secure \
78 protocols='[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13]' \
79 other-config:datapath-id=$dpid \
80 -- set-controller $bridge tcp:127.0.0.1:6653 \
81 -- set controller $bridge connection-mode=out-of-band \
82 max-backoff=1000 \
83 -- add-port $bridge $port1 \
84 -- set interface $port1 ofport_request=1 type=dummy \
85 options:${stream_mode}:"$sandbox"/p1.sock \
86 -- add-port $bridge $port2 \
87 -- set interface $port2 ofport_request=2 type=dummy \
88 options:${stream_mode}:"$sandbox"/p2.sock
89 done
90
91 logs=
92
93 run_app() {
94 app=$1
95 cat <<EOF
96
97 --- Running $app...
98
99 EOF
100 logfile=$sandbox/`echo $app | sed 's,/,.,g'`.log
101 logs="$logs
102 $logfile"
103 ryu-manager --ofp-tcp-listen-port=6653 "$app" --log-file="$logfile" & pid=$!
104 echo $pid > "$sandbox/ryu.pid"
105 i=0
106 while sleep 1; do
107 if grep -q -E 'TEST_FINISHED|Test end|uncaught exception' "$logfile" \
108 >/dev/null
109 then
110 break
111 fi
112
113 i=`expr $i + 1`
114 if test $i -ge 600; then
115 echo "--- TIMEOUT after $i seconds"
116 break
117 fi
118 done
119 kill $pid
120 wait
121 }
122
123 # Run Ryu.
124 cd $RYUDIR
125 for app in \
126 ryu/tests/switch/tester.py
127 do
128 run_app $app
129 done
130
131 # tweak OVS setup because the following tests assume single bridge.
132 run ovs-vsctl -- del-br br1
133
134 for app in \
135 ryu/tests/integrated/test_add_flow_v10.py \
136 ryu/tests/integrated/test_request_reply_v12.py \
137 ryu/tests/integrated/test_add_flow_v12_actions.py \
138 ryu/tests/integrated/test_add_flow_v12_matches.py
139 do
140 run_app $app
141 done
142
143 cat <<EOF
144
145 ----------------------------------------------------------------------
146 Logs may be found under $sandbox, e.g.:$logs
147 $sandbox/ovs-vswitchd.log
148 $sandbox/ovsdb-server.log
149 ----------------------------------------------------------------------
150 EOF