[ovs-dev,4/4] tests: Add unit tests for ovn-nbctl.
diff mbox

Message ID 1441316822-60290-4-git-send-email-jpettit@nicira.com
State Accepted
Headers show

Commit Message

Justin Pettit Sept. 3, 2015, 9:47 p.m. UTC
Signed-off-by: Justin Pettit <jpettit@nicira.com>
---
 tests/automake.mk  |    1 +
 tests/ovn-nbctl.at |  119 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/testsuite.at |    1 +
 3 files changed, 121 insertions(+), 0 deletions(-)
 create mode 100644 tests/ovn-nbctl.at

Comments

Ben Pfaff Sept. 4, 2015, 5:55 p.m. UTC | #1
On Thu, Sep 03, 2015 at 02:47:02PM -0700, Justin Pettit wrote:
> Signed-off-by: Justin Pettit <jpettit@nicira.com>

Thanks for writing tests!

Acked-by: Ben Pfaff <blp@nicira.com>

Patch
diff mbox

diff --git a/tests/automake.mk b/tests/automake.mk
index 32f757b..4198039 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -87,6 +87,7 @@  TESTSUITE_AT = \
 	tests/vtep-ctl.at \
 	tests/auto-attach.at \
 	tests/ovn.at \
+	tests/ovn-nbctl.at \
 	tests/ovn-sbctl.at \
 	tests/ovn-controller-vtep.at
 
diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at
new file mode 100644
index 0000000..dd81626
--- /dev/null
+++ b/tests/ovn-nbctl.at
@@ -0,0 +1,119 @@ 
+AT_BANNER([ovn-nbctl])
+
+# OVN_NBCTL_TEST_START
+m4_define([OVN_NBCTL_TEST_START],
+  [OVS_RUNDIR=`pwd`; export OVS_RUNDIR
+   OVS_LOGDIR=`pwd`; export OVS_LOGDIR
+   OVS_DBDIR=`pwd`; export OVS_DBDIR
+   OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
+
+   dnl Create ovn-nb database.
+   AT_CHECK([ovsdb-tool create ovn-nb.db $abs_top_srcdir/ovn/ovn-nb.ovsschema])
+
+   dnl Start ovsdb-server.
+   AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock ovn-nb.db], [0], [], [stderr])
+    ON_EXIT_UNQUOTED([kill `cat ovsdb-server.pid`])
+   AT_CHECK([[sed < stderr '
+/vlog|INFO|opened log file/d
+/ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
+   AT_CAPTURE_FILE([ovsdb-server.log])
+])
+
+# OVN_NBCTL_TEST_STOP
+m4_define([OVN_NBCTL_TEST_STOP],
+  [AT_CHECK([check_logs $1])
+   AT_CHECK([ovs-appctl -t ovsdb-server exit])])
+
+
+AT_SETUP([ovn-nbctl - lswitch])
+OVN_NBCTL_TEST_START
+
+AT_CHECK([ovn-nbctl lswitch-add ls0])
+AT_CHECK([ovn-nbctl lswitch-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
+<0> (ls0)
+<1> (ls1)
+])
+
+AT_CHECK([ovn-nbctl lswitch-del ls0])
+AT_CHECK([ovn-nbctl lswitch-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+<0> (ls1)
+])
+
+OVN_NBCTL_TEST_STOP
+AT_CLEANUP
+
+dnl ---------------------------------------------------------------------
+
+AT_SETUP([ovn-nbctl - lport])
+OVN_NBCTL_TEST_START
+
+AT_CHECK([ovn-nbctl lswitch-add ls0])
+AT_CHECK([ovn-nbctl lport-add ls0 lp0])
+AT_CHECK([ovn-nbctl lport-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
+<0> (lp0)
+<1> (lp1)
+])
+
+AT_CHECK([ovn-nbctl lport-del lp1])
+AT_CHECK([ovn-nbctl lport-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+<0> (lp0)
+])
+
+OVN_NBCTL_TEST_STOP
+AT_CLEANUP
+
+dnl ---------------------------------------------------------------------
+
+AT_SETUP([ovn-nbctl - lport macs])
+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-macs lp0], [0], [dnl
+])
+
+AT_CHECK([ovn-nbctl lport-set-macs lp0 00:11:22:33:44:55 unknown])
+AT_CHECK([ovn-nbctl lport-get-macs lp0], [0], [dnl
+00:11:22:33:44:55
+unknown
+])
+
+AT_CHECK([ovn-nbctl lport-set-macs lp0])
+AT_CHECK([ovn-nbctl lport-get-macs lp0], [0], [dnl
+])
+
+OVN_NBCTL_TEST_STOP
+AT_CLEANUP
+
+dnl ---------------------------------------------------------------------
+
+AT_SETUP([ovn-nbctl - lport 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-macs 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
+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
+])
+
+OVN_NBCTL_TEST_STOP
+AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index f3bc126..cb2e098 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -68,5 +68,6 @@  m4_include([tests/vlog.at])
 m4_include([tests/vtep-ctl.at])
 m4_include([tests/auto-attach.at])
 m4_include([tests/ovn.at])
+m4_include([tests/ovn-nbctl.at])
 m4_include([tests/ovn-sbctl.at])
 m4_include([tests/ovn-controller-vtep.at])