]> git.proxmox.com Git - ovs.git/blame - tests/ovs-vswitchd.at
match: Do not skip formatting a zero dp_hash.
[ovs.git] / tests / ovs-vswitchd.at
CommitLineData
b7898031
BP
1AT_BANNER([ovs-vswitchd])
2
3dnl The OVS initscripts never make an empty database (one without even an
4dnl Open_vSwitch record) visible to ovs-vswitchd, but hand-rolled scripts
5dnl sometimes do. At one point, "ovs-vswitchd --detach" would never detach
6dnl and use 100% CPU if this happened, so this test checks for regression.
7AT_SETUP([ovs-vswitchd detaches correctly with empty db])
8OVS_RUNDIR=`pwd`; export OVS_RUNDIR
9OVS_LOGDIR=`pwd`; export OVS_LOGDIR
10OVS_DBDIR=`pwd`; export OVS_DBDIR
11OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
12ON_EXIT([kill `cat ovsdb-server.pid ovs-vswitchd.pid`])
13
14dnl Create database.
15touch .conf.db.~lock~
16AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
17
18dnl Start ovsdb-server. *Don't* initialize database.
19AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [ignore], [ignore])
20AT_CAPTURE_FILE([ovsdb-server.log])
21
22dnl Start ovs-vswitchd.
23AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --enable-dummy --disable-system --log-file], [0], [], [stderr])
24AT_CAPTURE_FILE([ovs-vswitchd.log])
25
26dnl ovs-vswitchd detached OK or we wouldn't have made it this far. Success.
27AT_CLEANUP
12eb035b
AW
28
29
30dnl ----------------------------------------------------------------------
31m4_define([OVS_VSCTL_CHECK_RX_PKT], [
2bf0b4a3 32AT_CHECK([ovs-vsctl list int $1 | grep statistics | sed -n 's/^.*\(rx_packets=[[0-9]][[0-9]]*\).*$/\1/p'],[0],
12eb035b
AW
33[dnl
34rx_packets=$2
35])
36])
37
38AT_SETUP([ovs-vswitchd -- stats-update-interval])
39OVS_VSWITCHD_START([add-port br0 p1 -- set int p1 type=internal])
40ovs-appctl time/stop
41
76eb754a 42dnl at the beginning, the update of rx_packets should happen every 5 seconds.
bdba1947 43ovs-appctl time/warp 11000 1000
12eb035b
AW
44OVS_VSCTL_CHECK_RX_PKT([p1], [0])
45AT_CHECK([ovs-appctl netdev-dummy/receive p1 'eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
bdba1947 46ovs-appctl time/warp 11000 1000
12eb035b
AW
47OVS_VSCTL_CHECK_RX_PKT([p1], [1])
48
49dnl set the stats update interval to 100K ms, the following 'recv' should not be updated.
50AT_CHECK([ovs-vsctl set O . other_config:stats-update-interval=100000])
bdba1947 51ovs-appctl time/warp 51000 1000
12eb035b
AW
52for i in `seq 1 5`; do
53 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
54done
55
56OVS_VSCTL_CHECK_RX_PKT([p1], [1])
57dnl advance the clock by 100K ms, the previous 'recv' should be updated.
bdba1947 58ovs-appctl time/warp 100000 1000
12eb035b
AW
59OVS_VSCTL_CHECK_RX_PKT([p1], [6])
60
61dnl now remove the configuration. 'recv' one packet. there should be an update after 5000 ms.
62AT_CHECK([ovs-vsctl clear O . other_config])
63AT_CHECK([ovs-appctl netdev-dummy/receive p1 'eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
bdba1947 64ovs-appctl time/warp 11000 1000
12eb035b
AW
65OVS_VSCTL_CHECK_RX_PKT([p1], [7])
66
67OVS_VSWITCHD_STOP
76eb754a 68AT_CLEANUP
6bef3c7c
AW
69
70dnl ----------------------------------------------------------------------
71AT_SETUP([ovs-vswitchd -- start additional ovs-vswitchd process])
72OVS_VSWITCHD_START
73
74# start another ovs-vswitchd process.
1786535e 75ovs-vswitchd --log-file=fakelog --unixctl="`pwd`"/unixctl &
6bef3c7c
AW
76
77# sleep for a while
78sleep 5
79
80# stop the process.
1786535e 81ovs-appctl -t `pwd`/unixctl exit
6bef3c7c
AW
82
83# check the fakelog, should only see one ERR for reporting
1786535e 84# the existing ovs-vswitchd process.
a07e26bf 85AT_CHECK([test `grep ERR fakelog | wc -l` -eq 1])
6bef3c7c 86
1786535e 87AT_CHECK([tail -n1 fakelog | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl
6bef3c7c
AW
88another ovs-vswitchd process is running, disabling this process () until it goes away
89])
90
91OVS_VSWITCHD_STOP
92AT_CLEANUP
e15df145
AW
93
94dnl ----------------------------------------------------------------------
95AT_SETUP([ovs-vswitchd -- switch over to another ovs-vswitchd process])
96OVS_VSWITCHD_START
97
98# start a new ovs-vswitchd process.
1786535e 99ovs-vswitchd --log-file=fakelog --enable-dummy --unixctl="`pwd`"/unixctl &
e15df145
AW
100
101# sleep for a while.
102sleep 5
103
104# kill the current active ovs-vswitchd process.
105kill `cat ovs-vswitchd.pid`
106
107sleep 5
108
109# check the creation of br0 on the new ovs-vswitchd process.
110AT_CHECK([grep "bridge br0" fakelog | sed -e 's/port [[0-9]]*$/port/;
111s/datapath ID [[a-z0-9]]*$/datapath ID/;s/^.*INFO|//'], [0], [dnl
112bridge br0: added interface br0 on port
113bridge br0: using datapath ID
114])
115
116# stop the process.
1786535e 117ovs-appctl -t `pwd`/unixctl exit
e15df145
AW
118
119# check the fakelog, should not see WARN/ERR/EMER log other than the one
120# for reporting the existing ovs-vswitchd process and the one for killing
121# the process.
122AT_CHECK([sed -n "
123/|ERR|another ovs-vswitchd process is running/d
e15df145
AW
124/|WARN|/p
125/|ERR|/p
126/|EMER|/p" fakelog
127])
128
129# cleanup.
130kill `cat ovsdb-server.pid`
131AT_CLEANUP
5aca3322
AW
132
133dnl ----------------------------------------------------------------------
134AT_SETUP([ovs-vswitchd -- invalid database path])
135
136# start an ovs-vswitchd process with invalid db path.
137ovs-vswitchd unix:invalid.db.sock --log-file=fakelog --enable-dummy --unixctl="`pwd`"/unixctl &
138
139# sleep for a while.
140sleep 10
141
142# stop the process.
143ovs-appctl -t `pwd`/unixctl exit
144
145# should not see this log (which indicates high cpu utilization).
146AT_CHECK([grep "wakeup due to" fakelog], [ignore])
147
148# check the fakelog, should not see any WARN/ERR/EMER log.
149AT_CHECK([sed -n "
150/|WARN|/p
151/|ERR|/p
152/|EMER|/p" fakelog
153])
154
155AT_CLEANUP