db-ctl-base: Allow print rows that weak reference to table in
[cascardo/ovs.git] / tests / ovn-sbctl.at
1 AT_BANNER([ovn_controller_gw])
2
3 # OVN_SBCTL_TEST_START
4 m4_define([OVN_SBCTL_TEST_START],
5   [OVS_RUNDIR=`pwd`; export OVS_RUNDIR
6    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
7    OVS_DBDIR=`pwd`; export OVS_DBDIR
8    OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
9
10    dnl Create databases (ovn-nb, ovn-sb).
11    for daemon in ovn-nb ovn-sb; do
12       AT_CHECK([ovsdb-tool create $daemon.db $abs_top_srcdir/${daemon%%-*}/${daemon}.ovsschema])
13    done
14
15    dnl Start ovsdb-server.
16    AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock ovn-nb.db ovn-sb.db], [0], [], [stderr])
17     ON_EXIT_UNQUOTED([kill `cat ovsdb-server.pid`])
18    AT_CHECK([[sed < stderr '
19 /vlog|INFO|opened log file/d
20 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
21    AT_CAPTURE_FILE([ovsdb-server.log])
22
23    dnl Start ovn-northd.
24    AT_CHECK([ovn-northd --detach --pidfile --log-file --ovnnb-db=unix:$OVS_RUNDIR/db.sock --ovnsb-db=unix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
25    ON_EXIT_UNQUOTED([kill `cat ovn-northd.pid`])
26    AT_CHECK([[sed < stderr '
27 /vlog|INFO|opened log file/d']])
28    AT_CAPTURE_FILE([ovn-northd.log])
29 ])
30
31 # OVN_SBCTL_TEST_STOP
32 m4_define([OVN_SBCTL_TEST_STOP],
33   [AT_CHECK([check_logs $1])
34    AT_CHECK([ovs-appctl -t ovn-northd exit])
35    AT_CHECK([ovs-appctl -t ovsdb-server exit])])
36
37 # ovn-sbctl test.
38 AT_SETUP([ovn-sbctl - test])
39 OVN_SBCTL_TEST_START
40
41 AT_CHECK([ovn-nbctl lswitch-add br-test])
42 AT_CHECK([ovn-nbctl lport-add br-test vif0])
43 AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:02])
44 AT_CHECK([ovn-sbctl chassis-add ch0 stt 1.2.3.5])
45 AT_CHECK([ovn-sbctl lport-bind vif0 ch0])
46
47 AT_CHECK([ovn-sbctl show], [0], [dnl
48 Chassis "ch0"
49     Encap stt
50         ip: "1.2.3.5"
51     Port_Binding "vif0"
52 ])
53
54 # adds another 'vif1'
55 AT_CHECK([ovn-nbctl lport-add br-test vif1])
56 AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:03])
57 AT_CHECK([ovn-sbctl lport-bind vif1 ch0])
58
59 AT_CHECK([ovn-sbctl show | sed 's/vif[[0-9]]/vif/'], [0], [dnl
60 Chassis "ch0"
61     Encap stt
62         ip: "1.2.3.5"
63     Port_Binding "vif"
64     Port_Binding "vif"
65 ])
66
67 # deletes 'vif1'
68 AT_CHECK([ovn-nbctl lport-del vif1])
69
70 AT_CHECK([ovn-sbctl show], [0], [dnl
71 Chassis "ch0"
72     Encap stt
73         ip: "1.2.3.5"
74     Port_Binding "vif0"
75 ])
76
77 uuid=$(ovn-sbctl --columns=_uuid list Chassis ch0 | cut -d ':' -f2 | tr -d ' ')
78 AT_CHECK_UNQUOTED([ovn-sbctl --columns=logical_port,mac,chassis list Port_Binding], [0], [dnl
79 logical_port        : "vif0"
80 mac                 : [["f0:ab:cd:ef:01:02"]]
81 chassis             : ${uuid}
82 ])
83
84 # test the passing down of logical port type and options.
85 AT_CHECK([ovn-nbctl lport-add br-test vtep0])
86 AT_CHECK([ovn-nbctl lport-set-type vtep0 vtep])
87 AT_CHECK([ovn-nbctl lport-set-options vtep0 vtep_physical_switch=p0 vtep_logical_switch=l0])
88
89 OVS_WAIT_UNTIL([test -n "`ovn-sbctl --columns=logical_port list Port_Binding | grep vtep0`" ])
90 AT_CHECK_UNQUOTED([ovn-sbctl --columns=logical_port,mac,type,options list Port_Binding vtep0], [0], [dnl
91 logical_port        : "vtep0"
92 mac                 : [[]]
93 type                : vtep
94 options             : {vtep_logical_switch="l0", vtep_physical_switch="p0"}
95 ])
96
97 OVN_SBCTL_TEST_STOP
98 AT_CLEANUP