]> git.proxmox.com Git - mirror_ovs.git/blob - tests/ovn-sbctl.at
tests: Fix race in MPLS translate.
[mirror_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 AT_KEYWORDS([ovn])
7 for daemon in ovn-nb ovn-sb; do
8 AT_CHECK([ovsdb-tool create $daemon.db $abs_top_srcdir/${daemon%%-*}/${daemon}.ovsschema])
9 done
10
11 dnl Start ovsdb-servers.
12 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile=ovnnb_db.pid --unixctl=$OVS_RUNDIR/ovnnb_db.ctl --log-file=ovsdb_nb.log --remote=punix:$OVS_RUNDIR/ovnnb_db.sock ovn-nb.db ], [0], [], [stderr])
13 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile=ovnsb_db.pid --unixctl=$OVS_RUNDIR/ovnsb_db.ctl --log-file=ovsdb_sb.log --remote=punix:$OVS_RUNDIR/ovnsb_db.sock ovn-sb.db], [0], [], [stderr])
14 on_exit "kill `cat ovnnb_db.pid` `cat ovnsb_db.pid`"
15 AT_CHECK([[sed < stderr '
16 /vlog|INFO|opened log file/d
17 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
18 AT_CAPTURE_FILE([ovsdb-server.log])
19
20 dnl Start ovn-northd.
21 AT_CHECK([ovn-northd --detach --pidfile --log-file --ovnnb-db=unix:$OVS_RUNDIR/ovnnb_db.sock --ovnsb-db=unix:$OVS_RUNDIR/ovnsb_db.sock], [0], [], [stderr])
22 on_exit "kill `cat ovn-northd.pid`"
23 AT_CHECK([[sed < stderr '
24 /vlog|INFO|opened log file/d']])
25 AT_CAPTURE_FILE([ovn-northd.log])
26 ])
27
28 # OVN_SBCTL_TEST_STOP
29 m4_define([OVN_SBCTL_TEST_STOP],
30 [# removes all 'Broken pipe' warning logs from ovsdb-server.log. this is in
31 # that *ctl command (e.g. ovn-nbctl) exits right after committing the change
32 # to database. however, in reaction, some daemon (e.g. ovn-controller-vtep)
33 # may immediately update the database. this later update may cause database
34 # sending update back to *ctl command if *ctl has not proceeded to exit yet.
35 # and if *ctl command exits before database calling send, the send from
36 # database will fail with 'Broken pipe' error. Also removes all "connection
37 # reset" warning logs by a similar rationale (either EPIPE or ECONNRESET can
38 # be returned on a send depending on whether the peer had unconsumed data when
39 # it closed the socket).
40 AT_CHECK([check_logs "$1
41 /reset by peer/d
42 /Broken pipe/d"])
43 OVS_APP_EXIT_AND_WAIT([ovn-northd])
44 OVS_APP_EXIT_AND_WAIT_BY_TARGET([$OVS_RUNDIR/ovnnb_db.ctl], [$OVS_RUNDIR/ovnnb_db.pid])
45 OVS_APP_EXIT_AND_WAIT_BY_TARGET([$OVS_RUNDIR/ovnsb_db.ctl], [$OVS_RUNDIR/ovnsb_db.pid])])
46
47 dnl ---------------------------------------------------------------------
48
49 AT_SETUP([ovn-sbctl - chassis commands])
50 OVN_SBCTL_TEST_START
51 ovn_init_db ovn-sb
52
53 AT_CHECK([ovn-sbctl chassis-add ch0 geneve 1.2.3.4])
54 AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort],
55 [0], [dnl
56 1.2.3.4,geneve
57 ])
58
59 AT_CHECK([ovn-sbctl chassis-add ch1 stt,geneve,vxlan 1.2.3.5])
60 AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort],
61 [0], [dnl
62 1.2.3.4,geneve
63 1.2.3.5,geneve
64 1.2.3.5,stt
65 1.2.3.5,vxlan
66 ])
67
68 AT_CHECK([ovn-sbctl chassis-del ch0])
69 AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort],
70 [0], [dnl
71 1.2.3.5,geneve
72 1.2.3.5,stt
73 1.2.3.5,vxlan
74 ])
75
76 OVN_SBCTL_TEST_STOP
77 as ovn-sb
78 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
79 AT_CLEANUP
80
81 dnl ---------------------------------------------------------------------
82
83 AT_SETUP([ovn-sbctl])
84 OVN_SBCTL_TEST_START
85
86 AT_CHECK([ovn-nbctl ls-add br-test])
87 AT_CHECK([ovn-nbctl lsp-add br-test vif0])
88 AT_CHECK([ovn-nbctl lsp-set-addresses vif0 f0:ab:cd:ef:01:02])
89 AT_CHECK([ovn-sbctl chassis-add ch0 stt 1.2.3.5])
90 AT_CHECK([ovn-nbctl --wait=sb sync])
91 AT_CHECK([ovn-sbctl lsp-bind vif0 ch0])
92
93 AT_CHECK([ovn-sbctl show], [0], [dnl
94 Chassis "ch0"
95 Encap stt
96 ip: "1.2.3.5"
97 options: {csum="true"}
98 Port_Binding "vif0"
99 ])
100
101 # adds another 'vif1'
102 AT_CHECK([ovn-nbctl --wait=sb lsp-add br-test vif1])
103 AT_CHECK([ovn-nbctl lsp-set-addresses vif1 f0:ab:cd:ef:01:03])
104 AT_CHECK([ovn-sbctl lsp-bind vif1 ch0])
105
106 AT_CHECK([ovn-sbctl show | sed 's/vif[[0-9]]/vif/'], [0], [dnl
107 Chassis "ch0"
108 Encap stt
109 ip: "1.2.3.5"
110 options: {csum="true"}
111 Port_Binding "vif"
112 Port_Binding "vif"
113 ])
114
115 # deletes 'vif1'
116 AT_CHECK([ovn-nbctl lsp-del vif1])
117 AT_CHECK([ovn-nbctl --wait=sb sync])
118
119 AT_CHECK([ovn-sbctl show], [0], [dnl
120 Chassis "ch0"
121 Encap stt
122 ip: "1.2.3.5"
123 options: {csum="true"}
124 Port_Binding "vif0"
125 ])
126
127 uuid=$(ovn-sbctl --columns=_uuid list Chassis ch0 | cut -d ':' -f2 | tr -d ' ')
128 AT_CHECK_UNQUOTED([ovn-sbctl --columns=logical_port,mac,chassis list Port_Binding], [0], [dnl
129 logical_port : "vif0"
130 mac : [["f0:ab:cd:ef:01:02"]]
131 chassis : ${uuid}
132 ])
133
134 # test the passing down of logical port type and options.
135 AT_CHECK([ovn-nbctl --wait=sb lsp-add br-test vtep0])
136 AT_CHECK([ovn-nbctl lsp-set-type vtep0 vtep])
137 AT_CHECK([ovn-nbctl lsp-set-options vtep0 vtep_physical_switch=p0 vtep_logical_switch=l0])
138
139 AT_CHECK([ovn-sbctl --timeout=10 wait-until Port_Binding vtep0 options!={}])
140 AT_CHECK([ovn-sbctl --columns=logical_port,mac,type,options list Port_Binding vtep0], [0], [dnl
141 logical_port : "vtep0"
142 mac : [[]]
143 type : vtep
144 options : {vtep_logical_switch="l0", vtep_physical_switch="p0"}
145 ])
146
147 OVN_SBCTL_TEST_STOP
148 AT_CLEANUP