ovn: Make it possible for CMS to detect when the OVN system is up-to-date.
[cascardo/ovs.git] / tests / ovn-nbctl.at
index 7f01b4d..5357ced 100644 (file)
@@ -9,6 +9,7 @@ m4_define([OVN_NBCTL_TEST_START],
    dnl Start ovsdb-server.
    AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/ovnnb_db.sock ovn-nb.db], [0], [], [stderr])
    on_exit "kill `cat ovsdb-server.pid`"
+   AT_CHECK([ovn-nbctl init])
    AT_CHECK([[sed < stderr '
 /vlog|INFO|opened log file/d
 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
@@ -23,62 +24,66 @@ m4_define([OVN_NBCTL_TEST_STOP],
    # may immediately update the database.  this later update may cause database
    # sending update back to *ctl command if *ctl has not proceeded to exit yet.
    # and if *ctl command exits before database calling send, the send from
-   # database will fail with 'Broken pipe' error.
+   # database will fail with 'Broken pipe' error. Also removes all "connection
+   # reset" warning logs by a similar rationale (either EPIPE or ECONNRESET can
+   # be returned on a send depending on whether the peer had unconsumed data when
+   # it closed the socket).
    AT_CHECK([check_logs "$1
+/reset by peer/d
 /Broken pipe/d"])
    OVS_APP_EXIT_AND_WAIT([ovsdb-server])])
 
 
-AT_SETUP([ovn-nbctl - basic lswitch commands])
+AT_SETUP([ovn-nbctl - basic switch commands])
 OVN_NBCTL_TEST_START
 
-AT_CHECK([ovn-nbctl lswitch-add ls0])
-AT_CHECK([ovn-nbctl lswitch-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+AT_CHECK([ovn-nbctl ls-add ls0])
+AT_CHECK([ovn-nbctl ls-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (ls0)
 ])
 
-AT_CHECK([ovn-nbctl lswitch-add ls1])
-AT_CHECK([ovn-nbctl lswitch-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+AT_CHECK([ovn-nbctl ls-add ls1])
+AT_CHECK([ovn-nbctl ls-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (ls0)
 <1> (ls1)
 ])
 
-AT_CHECK([ovn-nbctl lswitch-del ls0])
-AT_CHECK([ovn-nbctl lswitch-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+AT_CHECK([ovn-nbctl ls-del ls0])
+AT_CHECK([ovn-nbctl ls-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (ls1)
 ])
 
 AT_CHECK([ovn-nbctl show ls0])
-AT_CHECK([ovn-nbctl lswitch-add ls0])
+AT_CHECK([ovn-nbctl ls-add ls0])
 AT_CHECK([ovn-nbctl show ls0 | ${PERL} $srcdir/uuidfilt.pl], [0],
-  [    lswitch <0> (ls0)
+  [    switch <0> (ls0)
 ])
-AT_CHECK([ovn-nbctl lswitch-add ls0], [1], [],
-  [ovn-nbctl: ls0: an lswitch with this name already exists
+AT_CHECK([ovn-nbctl ls-add ls0], [1], [],
+  [ovn-nbctl: ls0: a switch with this name already exists
 ])
-AT_CHECK([ovn-nbctl --may-exist lswitch-add ls0])
+AT_CHECK([ovn-nbctl --may-exist ls-add ls0])
 AT_CHECK([ovn-nbctl show ls0 | ${PERL} $srcdir/uuidfilt.pl], [0],
-  [    lswitch <0> (ls0)
+  [    switch <0> (ls0)
 ])
-AT_CHECK([ovn-nbctl --add-duplicate lswitch-add ls0])
-AT_CHECK([ovn-nbctl --may-exist --add-duplicate lswitch-add ls0], [1], [],
+AT_CHECK([ovn-nbctl --add-duplicate ls-add ls0])
+AT_CHECK([ovn-nbctl --may-exist --add-duplicate ls-add ls0], [1], [],
   [ovn-nbctl: --may-exist and --add-duplicate may not be used together
 ])
-AT_CHECK([ovn-nbctl lswitch-del ls0], [1], [],
+AT_CHECK([ovn-nbctl ls-del ls0], [1], [],
   [ovn-nbctl: Multiple logical switches named 'ls0'.  Use a UUID.
 ])
 
-AT_CHECK([ovn-nbctl lswitch-del ls2], [1], [],
-  [ovn-nbctl: ls2: lswitch name not found
+AT_CHECK([ovn-nbctl ls-del ls2], [1], [],
+  [ovn-nbctl: ls2: switch name not found
 ])
-AT_CHECK([ovn-nbctl --if-exists lswitch-del ls2])
+AT_CHECK([ovn-nbctl --if-exists ls-del ls2])
 
-AT_CHECK([ovn-nbctl lswitch-add])
-AT_CHECK([ovn-nbctl lswitch-add])
-AT_CHECK([ovn-nbctl --add-duplicate lswitch-add], [1], [],
+AT_CHECK([ovn-nbctl ls-add])
+AT_CHECK([ovn-nbctl ls-add])
+AT_CHECK([ovn-nbctl --add-duplicate ls-add], [1], [],
   [ovn-nbctl: --add-duplicate requires specifying a name
 ])
-AT_CHECK([ovn-nbctl --may-exist lswitch-add], [1], [],
+AT_CHECK([ovn-nbctl --may-exist ls-add], [1], [],
   [ovn-nbctl: --may-exist requires specifying a name
 ])
 
@@ -87,51 +92,51 @@ AT_CLEANUP
 
 dnl ---------------------------------------------------------------------
 
-AT_SETUP([ovn-nbctl - basic lport commands])
+AT_SETUP([ovn-nbctl - basic logical switch port commands])
 OVN_NBCTL_TEST_START
 
-AT_CHECK([ovn-nbctl lswitch-add ls0])
-AT_CHECK([ovn-nbctl lport-add ls0 lp0])
-AT_CHECK([ovn-nbctl lport-add ls0 lp0], [1], [],
-  [ovn-nbctl: lp0: an lport with this name already exists
+AT_CHECK([ovn-nbctl ls-add ls0])
+AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
+AT_CHECK([ovn-nbctl lsp-add ls0 lp0], [1], [],
+  [ovn-nbctl: lp0: a port with this name already exists
 ])
-AT_CHECK([ovn-nbctl --may-exist lport-add ls0 lp0])
-AT_CHECK([ovn-nbctl lport-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp0])
+AT_CHECK([ovn-nbctl lsp-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (lp0)
 ])
 
-AT_CHECK([ovn-nbctl lport-add ls0 lp1])
-AT_CHECK([ovn-nbctl lport-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+AT_CHECK([ovn-nbctl lsp-add ls0 lp1])
+AT_CHECK([ovn-nbctl lsp-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (lp0)
 <1> (lp1)
 ])
 
-AT_CHECK([ovn-nbctl lswitch-add ls1])
-AT_CHECK([ovn-nbctl lport-add ls0 lp1], [1], [],
-  [ovn-nbctl: lp1: an lport with this name already exists
+AT_CHECK([ovn-nbctl ls-add ls1])
+AT_CHECK([ovn-nbctl lsp-add ls0 lp1], [1], [],
+  [ovn-nbctl: lp1: a port with this name already exists
 ])
-AT_CHECK([ovn-nbctl --may-exist lport-add ls1 lp1], [1], [],
-  [ovn-nbctl: lp1: lport already exists but in lswitch ls0
+AT_CHECK([ovn-nbctl --may-exist lsp-add ls1 lp1], [1], [],
+  [ovn-nbctl: lp1: port already exists but in switch ls0
 ])
-AT_CHECK([ovn-nbctl --may-exist lport-add ls0 lp1 lp0 5], [1], [],
-  [ovn-nbctl: lp1: lport already exists but has no parent
+AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp1 lp0 5], [1], [],
+  [ovn-nbctl: lp1: port already exists but has no parent
 ])
 
-AT_CHECK([ovn-nbctl lport-del lp1])
-AT_CHECK([ovn-nbctl lport-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+AT_CHECK([ovn-nbctl lsp-del lp1])
+AT_CHECK([ovn-nbctl lsp-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (lp0)
 ])
 
-AT_CHECK([ovn-nbctl lport-add ls0 lp2 lp3 5])
-AT_CHECK([ovn-nbctl --may-exist lport-add ls0 lp2 lp4 5], [1], [],
-  [ovn-nbctl: lp2: lport already exists with different parent lp3
+AT_CHECK([ovn-nbctl lsp-add ls0 lp2 lp3 5])
+AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp4 5], [1], [],
+  [ovn-nbctl: lp2: port already exists with different parent lp3
 ])
-AT_CHECK([ovn-nbctl --may-exist lport-add ls0 lp2 lp3 10], [1], [],
-  [ovn-nbctl: lp2: lport already exists with different tag 5
+AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp3 10], [1], [],
+  [ovn-nbctl: lp2: port already exists with different tag 5
 ])
 AT_CHECK([ovn-nbctl clear Logical_Switch_Port lp2 tag])
-AT_CHECK([ovn-nbctl --may-exist lport-add ls0 lp2 lp3 5], [1], [],
-  [ovn-nbctl: lp2: lport already exists but has no tag
+AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp3 5], [1], [],
+  [ovn-nbctl: lp2: port already exists but has no tag
 ])
 
 OVN_NBCTL_TEST_STOP
@@ -142,19 +147,19 @@ dnl ---------------------------------------------------------------------
 AT_SETUP([ovn-nbctl - lport addresses])
 OVN_NBCTL_TEST_START
 
-AT_CHECK([ovn-nbctl lswitch-add ls0])
-AT_CHECK([ovn-nbctl lport-add ls0 lp0])
-AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
+AT_CHECK([ovn-nbctl ls-add ls0])
+AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
+AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
 ])
 
-AT_CHECK([ovn-nbctl lport-set-addresses lp0 00:11:22:33:44:55 unknown])
-AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
+AT_CHECK([ovn-nbctl lsp-set-addresses lp0 00:11:22:33:44:55 unknown])
+AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
 00:11:22:33:44:55
 unknown
 ])
 
-AT_CHECK([ovn-nbctl lport-set-addresses lp0])
-AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
+AT_CHECK([ovn-nbctl lsp-set-addresses lp0])
+AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
 ])
 
 OVN_NBCTL_TEST_STOP
@@ -165,19 +170,19 @@ dnl ---------------------------------------------------------------------
 AT_SETUP([ovn-nbctl - port security])
 OVN_NBCTL_TEST_START
 
-AT_CHECK([ovn-nbctl lswitch-add ls0])
-AT_CHECK([ovn-nbctl lport-add ls0 lp0])
-AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
+AT_CHECK([ovn-nbctl ls-add ls0])
+AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
+AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
 ])
 
-AT_CHECK([ovn-nbctl lport-set-port-security lp0 aa:bb:cc:dd:ee:ff 00:11:22:33:44:55])
-AT_CHECK([ovn-nbctl lport-get-port-security lp0], [0], [dnl
+AT_CHECK([ovn-nbctl lsp-set-port-security lp0 aa:bb:cc:dd:ee:ff 00:11:22:33:44:55])
+AT_CHECK([ovn-nbctl lsp-get-port-security lp0], [0], [dnl
 00:11:22:33:44:55
 aa:bb:cc:dd:ee:ff
 ])
 
-AT_CHECK([ovn-nbctl lport-set-port-security lp0])
-AT_CHECK([ovn-nbctl lport-get-port-security lp0], [0], [dnl
+AT_CHECK([ovn-nbctl lsp-set-port-security lp0])
+AT_CHECK([ovn-nbctl lsp-get-port-security lp0], [0], [dnl
 ])
 
 OVN_NBCTL_TEST_STOP
@@ -188,7 +193,7 @@ dnl ---------------------------------------------------------------------
 AT_SETUP([ovn-nbctl - ACLs])
 OVN_NBCTL_TEST_START
 
-AT_CHECK([ovn-nbctl lswitch-add ls0])
+AT_CHECK([ovn-nbctl ls-add ls0])
 AT_CHECK([ovn-nbctl --log acl-add ls0 from-lport 600 udp drop])
 AT_CHECK([ovn-nbctl --log acl-add ls0 to-lport 500 udp drop])
 AT_CHECK([ovn-nbctl acl-add ls0 from-lport 400 tcp drop])
@@ -297,6 +302,14 @@ OVN_NBCTL_TEST_START
 
 AT_CHECK([ovn-nbctl lr-add lr0])
 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
+
+AT_CHECK([ovn-nbctl show lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+    router <0> (lr0)
+        port lrp0
+            mac: "00:00:00:01:02:03"
+            networks: [["192.168.1.1/24"]]
+])
+
 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24], [1], [],
   [ovn-nbctl: lrp0: a port with this name already exists
 ])
@@ -305,7 +318,7 @@ AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (lrp0)
 ])
 
-AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 lrp1-peer])
+AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 peer=lrp1-peer])
 AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (lrp0)
 <1> (lrp1)
@@ -328,13 +341,25 @@ AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/2
   [ovn-nbctl: lrp1: port already exists with mismatching peer
 ])
 
-AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 lrp1-peer])
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 10.0.0.1/24 peer=lrp1-peer], [1], [],
+  [ovn-nbctl: lrp1: port already exists with different network
+])
+
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 peer=lrp1-peer])
 
 AT_CHECK([ovn-nbctl lrp-del lrp1])
 AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (lrp0)
 ])
 
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 10.0.0.1/24 peer=lrp1-peer])
+
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 172.16.0.1/24 peer=lrp1-peer], [1], [],
+  [ovn-nbctl: lrp1: port already exists with different network
+])
+
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 10.0.0.1/24 192.168.1.1/24 peer=lrp1-peer])
+
 OVN_NBCTL_TEST_STOP
 AT_CLEANUP
 
@@ -388,6 +413,14 @@ IPv4 Routes
                 0.0.0.0/0               192.168.0.1
 ])
 
+AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1 lp1])
+AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
+IPv4 Routes
+              10.0.0.0/24                  11.0.0.1 lp1
+              10.0.1.0/24                  11.0.1.1 lp0
+                0.0.0.0/0               192.168.0.1
+])
+
 dnl Delete non-existent prefix
 AT_CHECK([ovn-nbctl lr-route-del lr0 10.0.2.1/24], [1], [],
   [ovn-nbctl: no matching prefix: 10.0.2.0/24
@@ -398,7 +431,7 @@ AT_CHECK([ovn-nbctl lr-route-del lr0 10.0.1.1/24])
 
 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
 IPv4 Routes
-              10.0.0.0/24                  11.0.0.1
+              10.0.0.0/24                  11.0.0.1 lp1
                 0.0.0.0/0               192.168.0.1
 ])
 
@@ -407,7 +440,7 @@ AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
 ])
 
 dnl Check IPv6 routes
-AT_CHECK([ovn-nbctl lr-route-add lr0 ::/0 2001:0db8:0:f101::1])
+AT_CHECK([ovn-nbctl lr-route-add lr0 0:0:0:0:0:0:0:0/0 2001:0db8:0:f101::1])
 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:0::/64 2001:0db8:0:f102::1 lp0])
 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1])
 
@@ -434,7 +467,7 @@ dnl Check IPv4 and IPv6 routes
 AT_CHECK([ovn-nbctl lr-route-add lr0 0.0.0.0/0 192.168.0.1])
 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.1.1/24 11.0.1.1 lp0])
 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.1/24 11.0.0.1])
-AT_CHECK([ovn-nbctl lr-route-add lr0 ::/0 2001:0db8:0:f101::1])
+AT_CHECK([ovn-nbctl lr-route-add lr0 0:0:0:0:0:0:0:0/0 2001:0db8:0:f101::1])
 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:0::/64 2001:0db8:0:f102::1 lp0])
 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1])