ovn-nbctl: Update logical switch port commands.
[cascardo/ovs.git] / tests / ovn-nbctl.at
index a8ed41e..8b4195e 100644 (file)
@@ -53,7 +53,17 @@ AT_CHECK([ovn-nbctl lswitch-add ls0])
 AT_CHECK([ovn-nbctl show ls0 | ${PERL} $srcdir/uuidfilt.pl], [0],
   [    lswitch <0> (ls0)
 ])
-AT_CHECK([ovn-nbctl lswitch-add ls0])
+AT_CHECK([ovn-nbctl lswitch-add ls0], [1], [],
+  [ovn-nbctl: ls0: an lswitch with this name already exists
+])
+AT_CHECK([ovn-nbctl --may-exist lswitch-add ls0])
+AT_CHECK([ovn-nbctl show ls0 | ${PERL} $srcdir/uuidfilt.pl], [0],
+  [    lswitch <0> (ls0)
+])
+AT_CHECK([ovn-nbctl --add-duplicate lswitch-add ls0])
+AT_CHECK([ovn-nbctl --may-exist --add-duplicate lswitch-add ls0], [1], [],
+  [ovn-nbctl: --may-exist and --add-duplicate may not be used together
+])
 AT_CHECK([ovn-nbctl lswitch-del ls0], [1], [],
   [ovn-nbctl: Multiple logical switches named 'ls0'.  Use a UUID.
 ])
@@ -63,56 +73,65 @@ AT_CHECK([ovn-nbctl lswitch-del ls2], [1], [],
 ])
 AT_CHECK([ovn-nbctl --if-exists lswitch-del ls2])
 
+AT_CHECK([ovn-nbctl lswitch-add])
+AT_CHECK([ovn-nbctl lswitch-add])
+AT_CHECK([ovn-nbctl --add-duplicate lswitch-add], [1], [],
+  [ovn-nbctl: --add-duplicate requires specifying a name
+])
+AT_CHECK([ovn-nbctl --may-exist lswitch-add], [1], [],
+  [ovn-nbctl: --may-exist requires specifying a name
+])
+
 OVN_NBCTL_TEST_STOP
 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 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 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 lswitch 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_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 clear Logical_Switch_Port lp2 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
@@ -120,22 +139,22 @@ AT_CLEANUP
 
 dnl ---------------------------------------------------------------------
 
-AT_SETUP([ovn-nbctl - addresses])
+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 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
@@ -147,18 +166,18 @@ 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 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
@@ -212,3 +231,224 @@ from-lport   200 (ip) drop
 
 OVN_NBCTL_TEST_STOP
 AT_CLEANUP
+
+dnl ---------------------------------------------------------------------
+
+AT_SETUP([ovn-nbctl - basic logical router commands])
+OVN_NBCTL_TEST_START
+
+AT_CHECK([ovn-nbctl lr-add lr0])
+AT_CHECK([ovn-nbctl lr-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+<0> (lr0)
+])
+
+AT_CHECK([ovn-nbctl lr-add lr1])
+AT_CHECK([ovn-nbctl lr-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+<0> (lr0)
+<1> (lr1)
+])
+
+AT_CHECK([ovn-nbctl lr-del lr0])
+AT_CHECK([ovn-nbctl lr-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+<0> (lr1)
+])
+
+AT_CHECK([ovn-nbctl show lr0])
+AT_CHECK([ovn-nbctl lr-add lr0])
+AT_CHECK([ovn-nbctl show lr0 | ${PERL} $srcdir/uuidfilt.pl], [0],
+  [    router <0> (lr0)
+])
+AT_CHECK([ovn-nbctl lr-add lr0], [1], [],
+  [ovn-nbctl: lr0: a router with this name already exists
+])
+AT_CHECK([ovn-nbctl --may-exist lr-add lr0])
+AT_CHECK([ovn-nbctl show lr0 | ${PERL} $srcdir/uuidfilt.pl], [0],
+  [    router <0> (lr0)
+])
+AT_CHECK([ovn-nbctl --add-duplicate lr-add lr0])
+AT_CHECK([ovn-nbctl --may-exist --add-duplicate lr-add lr0], [1], [],
+  [ovn-nbctl: --may-exist and --add-duplicate may not be used together
+])
+AT_CHECK([ovn-nbctl lr-del lr0], [1], [],
+  [ovn-nbctl: Multiple logical routers named 'lr0'.  Use a UUID.
+])
+
+AT_CHECK([ovn-nbctl lr-del lr2], [1], [],
+  [ovn-nbctl: lr2: router name not found
+])
+AT_CHECK([ovn-nbctl --if-exists lr-del lr2])
+
+AT_CHECK([ovn-nbctl lr-add])
+AT_CHECK([ovn-nbctl lr-add])
+AT_CHECK([ovn-nbctl --add-duplicate lr-add], [1], [],
+  [ovn-nbctl: --add-duplicate requires specifying a name
+])
+AT_CHECK([ovn-nbctl --may-exist lr-add], [1], [],
+  [ovn-nbctl: --may-exist requires specifying a name
+])
+
+OVN_NBCTL_TEST_STOP
+AT_CLEANUP
+
+dnl ---------------------------------------------------------------------
+
+AT_SETUP([ovn-nbctl - basic logical router port commands])
+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 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
+])
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
+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-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+<0> (lrp0)
+<1> (lrp1)
+])
+
+AT_CHECK([ovn-nbctl lr-add lr1])
+AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
+  [ovn-nbctl: lrp1: a port with this name already exists
+])
+
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr1 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
+  [ovn-nbctl: lrp1: port already exists but in router lr0
+])
+
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:04:05:06 192.168.1.1/24], [1], [],
+  [ovn-nbctl: lrp1: port already exists with mac 00:00:00:01:02:03
+])
+
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
+  [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 lrp-del lrp1])
+AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+<0> (lrp0)
+])
+
+OVN_NBCTL_TEST_STOP
+AT_CLEANUP
+
+dnl ---------------------------------------------------------------------
+
+AT_SETUP([ovn-nbctl - logical router port enable and disable])
+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 lrp-get-enabled lrp0], [0], [enabled
+])
+
+AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 disabled])
+AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [disabled
+])
+
+AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 enabled])
+AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [enabled
+])
+
+AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 xyzzy], [1], [],
+  [ovn-nbctl: xyzzy: state must be "enabled" or "disabled"
+])
+
+OVN_NBCTL_TEST_STOP
+AT_CLEANUP
+
+dnl ---------------------------------------------------------------------
+
+AT_SETUP([ovn-nbctl - routes])
+OVN_NBCTL_TEST_START
+
+AT_CHECK([ovn-nbctl lr-add lr0])
+
+dnl Check IPv4 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.0/24 11.0.1.1 lp0])
+AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.1/24 11.0.0.2])
+
+dnl Add overlapping route with 10.0.0.1/24
+AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1], [1], [],
+  [ovn-nbctl: duplicate prefix: 10.0.0.0/24
+])
+AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1])
+
+AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
+IPv4 Routes
+              10.0.0.0/24                  11.0.0.1
+              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
+])
+AT_CHECK([ovn-nbctl --if-exists lr-route-del lr0 10.0.2.1/24])
+
+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
+                0.0.0.0/0               192.168.0.1
+])
+
+AT_CHECK([ovn-nbctl lr-route-del lr0])
+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 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])
+
+AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
+IPv6 Routes
+            2001:db8::/64        2001:db8:0:f102::1 lp0
+          2001:db8:1::/64        2001:db8:0:f103::1
+                     ::/0        2001:db8:0:f101::1
+])
+
+AT_CHECK([ovn-nbctl lr-route-del lr0 2001:0db8:0::/64])
+
+AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
+IPv6 Routes
+          2001:db8:1::/64        2001:db8:0:f103::1
+                     ::/0        2001:db8:0:f101::1
+])
+
+AT_CHECK([ovn-nbctl lr-route-del lr0])
+AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
+])
+
+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 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])
+
+AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
+IPv4 Routes
+              10.0.0.0/24                  11.0.0.1
+              10.0.1.0/24                  11.0.1.1 lp0
+                0.0.0.0/0               192.168.0.1
+
+IPv6 Routes
+            2001:db8::/64        2001:db8:0:f102::1 lp0
+          2001:db8:1::/64        2001:db8:0:f103::1
+                     ::/0        2001:db8:0:f101::1
+])
+
+OVN_NBCTL_TEST_STOP
+AT_CLEANUP