]>
Commit | Line | Data |
---|---|---|
1 | AT_BANNER([ovs-vswitchd]) | |
2 | ||
3 | dnl The OVS initscripts never make an empty database (one without even an | |
4 | dnl Open_vSwitch record) visible to ovs-vswitchd, but hand-rolled scripts | |
5 | dnl sometimes do. At one point, "ovs-vswitchd --detach" would never detach | |
6 | dnl and use 100% CPU if this happened, so this test checks for regression. | |
7 | AT_SETUP([ovs-vswitchd detaches correctly with empty db]) | |
8 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR | |
9 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
10 | OVS_DBDIR=`pwd`; export OVS_DBDIR | |
11 | OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR | |
12 | ON_EXIT([kill `cat ovsdb-server.pid ovs-vswitchd.pid`]) | |
13 | ||
14 | dnl Create database. | |
15 | touch .conf.db.~lock~ | |
16 | AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema]) | |
17 | ||
18 | dnl Start ovsdb-server. *Don't* initialize database. | |
19 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [ignore], [ignore]) | |
20 | AT_CAPTURE_FILE([ovsdb-server.log]) | |
21 | ||
22 | dnl Start ovs-vswitchd. | |
23 | AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --enable-dummy --disable-system --log-file], [0], [], [stderr]) | |
24 | AT_CAPTURE_FILE([ovs-vswitchd.log]) | |
25 | ||
26 | dnl ovs-vswitchd detached OK or we wouldn't have made it this far. Success. | |
27 | AT_CLEANUP | |
28 | ||
29 | ||
30 | dnl ---------------------------------------------------------------------- | |
31 | m4_define([OVS_VSCTL_CHECK_RX_PKT], [ | |
32 | AT_CHECK([ovs-vsctl list int $1 | grep statistics | sed -n 's/^.*\(rx_packets=[[0-9]][[0-9]]*\).*$/\1/p'],[0], | |
33 | [dnl | |
34 | rx_packets=$2 | |
35 | ]) | |
36 | ]) | |
37 | ||
38 | AT_SETUP([ovs-vswitchd -- stats-update-interval]) | |
39 | OVS_VSWITCHD_START([add-port br0 p1 -- set int p1 type=internal]) | |
40 | ovs-appctl time/stop | |
41 | ||
42 | dnl at the beginning, the update of rx_packets should happen every 5 seconds. | |
43 | ovs-appctl time/warp 11000 1000 | |
44 | OVS_VSCTL_CHECK_RX_PKT([p1], [0]) | |
45 | 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)']) | |
46 | ovs-appctl time/warp 11000 1000 | |
47 | OVS_VSCTL_CHECK_RX_PKT([p1], [1]) | |
48 | ||
49 | dnl set the stats update interval to 100K ms, the following 'recv' should not be updated. | |
50 | AT_CHECK([ovs-vsctl set O . other_config:stats-update-interval=100000]) | |
51 | ovs-appctl time/warp 51000 1000 | |
52 | for 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)']) | |
54 | done | |
55 | ||
56 | OVS_VSCTL_CHECK_RX_PKT([p1], [1]) | |
57 | dnl advance the clock by 100K ms, the previous 'recv' should be updated. | |
58 | ovs-appctl time/warp 100000 1000 | |
59 | OVS_VSCTL_CHECK_RX_PKT([p1], [6]) | |
60 | ||
61 | dnl now remove the configuration. 'recv' one packet. there should be an update after 5000 ms. | |
62 | AT_CHECK([ovs-vsctl clear O . other_config]) | |
63 | 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)']) | |
64 | ovs-appctl time/warp 11000 1000 | |
65 | OVS_VSCTL_CHECK_RX_PKT([p1], [7]) | |
66 | ||
67 | OVS_VSWITCHD_STOP | |
68 | AT_CLEANUP | |
69 | ||
70 | dnl ---------------------------------------------------------------------- | |
71 | AT_SETUP([ovs-vswitchd -- start additional ovs-vswitchd process]) | |
72 | OVS_VSWITCHD_START | |
73 | ||
74 | # start another ovs-vswitchd process. | |
75 | ovs-vswitchd --log-file=fakelog & | |
76 | pid=`echo $!` | |
77 | ||
78 | # sleep for a while | |
79 | sleep 5 | |
80 | ||
81 | # stop the process. | |
82 | kill $pid | |
83 | ||
84 | # check the fakelog, should only see one ERR for reporting | |
85 | # the existing ovs-vswitchd process and one WARN for killing | |
86 | # the process. | |
87 | AT_CHECK([test `grep ERR fakelog | wc -l` -eq 1]) | |
88 | AT_CHECK([test `grep WARN fakelog | wc -l` -eq 1]) | |
89 | ||
90 | AT_CHECK([grep ERR fakelog | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl | |
91 | another ovs-vswitchd process is running, disabling this process () until it goes away | |
92 | ]) | |
93 | ||
94 | # check the fakelog, the ERR log should be the last line. | |
95 | AT_CHECK([tail -n 2 fakelog | head -n 1 | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl | |
96 | another ovs-vswitchd process is running, disabling this process () until it goes away | |
97 | ]) | |
98 | ||
99 | OVS_VSWITCHD_STOP | |
100 | AT_CLEANUP |