Remove broken pipe warning logs from ovsdb-server.log for ovn tests
[cascardo/ovs.git] / tests / ovn-sbctl.at
1 AT_BANNER([ovn-sbctl])
2
3 # OVN_SBCTL_TEST_START
4 m4_define([OVN_SBCTL_TEST_START],
5   [dnl Create databases (ovn-nb, ovn-sb).
6    for daemon in ovn-nb ovn-sb; do
7       AT_CHECK([ovsdb-tool create $daemon.db $abs_top_srcdir/${daemon%%-*}/${daemon}.ovsschema])
8    done
9
10    dnl Start ovsdb-server.
11    AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock ovn-nb.db ovn-sb.db], [0], [], [stderr])
12    on_exit "kill `cat ovsdb-server.pid`"
13    AT_CHECK([[sed < stderr '
14 /vlog|INFO|opened log file/d
15 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
16    AT_CAPTURE_FILE([ovsdb-server.log])
17
18    dnl Start ovn-northd.
19    AT_CHECK([ovn-northd --detach --pidfile --log-file --ovnnb-db=unix:$OVS_RUNDIR/db.sock --ovnsb-db=unix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
20    on_exit "kill `cat ovn-northd.pid`"
21    AT_CHECK([[sed < stderr '
22 /vlog|INFO|opened log file/d']])
23    AT_CAPTURE_FILE([ovn-northd.log])
24 ])
25
26 # OVN_SBCTL_TEST_STOP
27 m4_define([OVN_SBCTL_TEST_STOP],
28   [# removes all 'Broken pipe' warning logs from ovsdb-server.log.  this is in
29    # that *ctl command (e.g. ovn-nbctl) exits right after committing the change
30    # to database.  however, in reaction, some daemon (e.g. ovn-controller-vtep)
31    # may immediately update the database.  this later update may cause database
32    # sending update back to *ctl command if *ctl has not proceeded to exit yet.
33    # and if *ctl command exits before database calling send, the send from
34    # database will fail with 'Broken pipe' error.
35    AT_CHECK([check_logs "$1
36 /Broken pipe/d"])
37    AT_CHECK([ovs-appctl -t ovn-northd exit])
38    AT_CHECK([ovs-appctl -t ovsdb-server exit])])
39
40 dnl ---------------------------------------------------------------------
41
42 AT_SETUP([ovn-sbctl - chassis commands])
43 OVN_SBCTL_TEST_START
44 ovn_init_db ovn-sb
45
46 AT_CHECK([ovn-sbctl chassis-add ch0 geneve 1.2.3.4])
47 AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort],
48          [0], [dnl
49 1.2.3.4,geneve
50 ])
51
52 AT_CHECK([ovn-sbctl chassis-add ch1 stt,geneve,vxlan 1.2.3.5])
53 AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort],
54          [0], [dnl
55 1.2.3.4,geneve
56 1.2.3.5,geneve
57 1.2.3.5,stt
58 1.2.3.5,vxlan
59 ])
60
61 AT_CHECK([ovn-sbctl chassis-del ch0])
62 AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort],
63          [0], [dnl
64 1.2.3.5,geneve
65 1.2.3.5,stt
66 1.2.3.5,vxlan
67 ])
68
69 OVN_SBCTL_TEST_STOP
70 AT_CLEANUP
71
72 dnl ---------------------------------------------------------------------
73
74 AT_SETUP([ovn-sbctl - test])
75 OVN_SBCTL_TEST_START
76
77 AT_CHECK([ovn-nbctl lswitch-add br-test])
78 AT_CHECK([ovn-nbctl lport-add br-test vif0])
79 AT_CHECK([ovn-nbctl lport-set-addresses vif0 f0:ab:cd:ef:01:02])
80 AT_CHECK([ovn-sbctl chassis-add ch0 stt 1.2.3.5])
81 AT_CHECK([ovn-sbctl lport-bind vif0 ch0])
82
83 AT_CHECK([ovn-sbctl show], [0], [dnl
84 Chassis "ch0"
85     Encap stt
86         ip: "1.2.3.5"
87     Port_Binding "vif0"
88 ])
89
90 # adds another 'vif1'
91 AT_CHECK([ovn-nbctl lport-add br-test vif1])
92 AT_CHECK([ovn-nbctl lport-set-addresses vif1 f0:ab:cd:ef:01:03])
93 AT_CHECK([ovn-sbctl lport-bind vif1 ch0])
94
95 AT_CHECK([ovn-sbctl show | sed 's/vif[[0-9]]/vif/'], [0], [dnl
96 Chassis "ch0"
97     Encap stt
98         ip: "1.2.3.5"
99     Port_Binding "vif"
100     Port_Binding "vif"
101 ])
102
103 # deletes 'vif1'
104 AT_CHECK([ovn-nbctl lport-del vif1])
105
106 AT_CHECK([ovn-sbctl show], [0], [dnl
107 Chassis "ch0"
108     Encap stt
109         ip: "1.2.3.5"
110     Port_Binding "vif0"
111 ])
112
113 uuid=$(ovn-sbctl --columns=_uuid list Chassis ch0 | cut -d ':' -f2 | tr -d ' ')
114 AT_CHECK_UNQUOTED([ovn-sbctl --columns=logical_port,mac,chassis list Port_Binding], [0], [dnl
115 logical_port        : "vif0"
116 mac                 : [["f0:ab:cd:ef:01:02"]]
117 chassis             : ${uuid}
118 ])
119
120 # test the passing down of logical port type and options.
121 AT_CHECK([ovn-nbctl lport-add br-test vtep0])
122 AT_CHECK([ovn-nbctl lport-set-type vtep0 vtep])
123 AT_CHECK([ovn-nbctl lport-set-options vtep0 vtep_physical_switch=p0 vtep_logical_switch=l0])
124
125 OVS_WAIT_UNTIL([test -n "`ovn-sbctl --columns=logical_port list Port_Binding | grep vtep0`" ])
126 AT_CHECK_UNQUOTED([ovn-sbctl --columns=logical_port,mac,type,options list Port_Binding vtep0], [0], [dnl
127 logical_port        : "vtep0"
128 mac                 : [[]]
129 type                : vtep
130 options             : {vtep_logical_switch="l0", vtep_physical_switch="p0"}
131 ])
132
133 OVN_SBCTL_TEST_STOP
134 AT_CLEANUP