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