d02e00f555b02663e338446cea2fa27ba08d3ee6
[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   [AT_CHECK([check_logs $1])
29    AT_CHECK([ovs-appctl -t ovn-northd exit])
30    AT_CHECK([ovs-appctl -t ovsdb-server exit])])
31
32 dnl ---------------------------------------------------------------------
33
34 AT_SETUP([ovn-sbctl - chassis commands])
35 OVN_SBCTL_TEST_START
36 ovn_init_db ovn-sb
37
38 AT_CHECK([ovn-sbctl chassis-add ch0 geneve 1.2.3.4])
39 AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort],
40          [0], [dnl
41 1.2.3.4,geneve
42 ])
43
44 AT_CHECK([ovn-sbctl chassis-add ch1 stt,geneve,vxlan 1.2.3.5])
45 AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort],
46          [0], [dnl
47 1.2.3.4,geneve
48 1.2.3.5,geneve
49 1.2.3.5,stt
50 1.2.3.5,vxlan
51 ])
52
53 AT_CHECK([ovn-sbctl chassis-del ch0])
54 AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort],
55          [0], [dnl
56 1.2.3.5,geneve
57 1.2.3.5,stt
58 1.2.3.5,vxlan
59 ])
60
61 OVN_SBCTL_TEST_STOP
62 AT_CLEANUP
63
64 dnl ---------------------------------------------------------------------
65
66 AT_SETUP([ovn-sbctl - test])
67 OVN_SBCTL_TEST_START
68
69 AT_CHECK([ovn-nbctl lswitch-add br-test])
70 AT_CHECK([ovn-nbctl lport-add br-test vif0])
71 AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:02])
72 AT_CHECK([ovn-sbctl chassis-add ch0 stt 1.2.3.5])
73 AT_CHECK([ovn-sbctl lport-bind vif0 ch0])
74
75 AT_CHECK([ovn-sbctl show], [0], [dnl
76 Chassis "ch0"
77     Encap stt
78         ip: "1.2.3.5"
79     Port_Binding "vif0"
80 ])
81
82 # adds another 'vif1'
83 AT_CHECK([ovn-nbctl lport-add br-test vif1])
84 AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:03])
85 AT_CHECK([ovn-sbctl lport-bind vif1 ch0])
86
87 AT_CHECK([ovn-sbctl show | sed 's/vif[[0-9]]/vif/'], [0], [dnl
88 Chassis "ch0"
89     Encap stt
90         ip: "1.2.3.5"
91     Port_Binding "vif"
92     Port_Binding "vif"
93 ])
94
95 # deletes 'vif1'
96 AT_CHECK([ovn-nbctl lport-del vif1])
97
98 AT_CHECK([ovn-sbctl show], [0], [dnl
99 Chassis "ch0"
100     Encap stt
101         ip: "1.2.3.5"
102     Port_Binding "vif0"
103 ])
104
105 uuid=$(ovn-sbctl --columns=_uuid list Chassis ch0 | cut -d ':' -f2 | tr -d ' ')
106 AT_CHECK_UNQUOTED([ovn-sbctl --columns=logical_port,mac,chassis list Port_Binding], [0], [dnl
107 logical_port        : "vif0"
108 mac                 : [["f0:ab:cd:ef:01:02"]]
109 chassis             : ${uuid}
110 ])
111
112 # test the passing down of logical port type and options.
113 AT_CHECK([ovn-nbctl lport-add br-test vtep0])
114 AT_CHECK([ovn-nbctl lport-set-type vtep0 vtep])
115 AT_CHECK([ovn-nbctl lport-set-options vtep0 vtep_physical_switch=p0 vtep_logical_switch=l0])
116
117 OVS_WAIT_UNTIL([test -n "`ovn-sbctl --columns=logical_port list Port_Binding | grep vtep0`" ])
118 AT_CHECK_UNQUOTED([ovn-sbctl --columns=logical_port,mac,type,options list Port_Binding vtep0], [0], [dnl
119 logical_port        : "vtep0"
120 mac                 : [[]]
121 type                : vtep
122 options             : {vtep_logical_switch="l0", vtep_physical_switch="p0"}
123 ])
124
125 OVN_SBCTL_TEST_STOP
126 AT_CLEANUP