OVN has had a test framework for as long as I've been working on the
project. The test framework is designed for performing functional tests
of OVN. That is, with the entirety of OVN up and running, we can provide
configuration and test data and ensure that OVN does with that data what
we expect. This is 100% a good thing and has helped us to detect lots of
bugs before they can actually be merged in.

What's missing, though, are smaller-scale unit tests. As an example, if
I wanted to test ovn-northd's IPAM code, I would need to start up
ovn-northd, create a logical switch, configure that logical switch to
use IPAM, and then create logical switch ports to exercise the IPAM
code. This can be overkill if my only goal is to ensure that IPAM's
algorithm for selecting the next IP address is correct.

This patch series proposes a unit test framework for OVN.

If you want to run the unit tests, you can do so in a couple of ways.

1) Within the testsuite.
   ./configure --with-ovs-source=/path/to/ovs --enable-unit-tests
   make check TESTSUITEFLAGS="-k unit"

2) One-off from the command line
   ./configure --with-ovs-source=/path/to/ovs --enable-unit-tests
   make sandbox
   ovn-appctl -t ovn-northd unit-test <test_name>

Some notes on this patch series
1) Patch 1 is the most important one in the series. This is an RFC
because I'm trying to find out if the unit test framework itself is
good. The refactoring in patch 2 and the unit tests added in patch 3 are
meant to illustrate examples of the framework. They do not necessarily
need to be merged as-is. Feel free to comment on them if you'd like,
though.
2) Ideally, new unit tests could be added to the testsuite via a script.
They've been added manually in this patch series.
3) This patch series only adds unit test capabilities to ovn-northd.
However, the patch series we actually merge should add unit test
capabilities to ovn-controller as well.

Mark Michelson (3):
  Add unit test framework.
  northd: refactor init_ipam_info_for_datapath
  northd: Add init_ipam unit tests.

 acinclude.m4        |  12 ++
 configure.ac        |   1 +
 lib/automake.mk     |   4 +-
 lib/unit-test.c     | 125 +++++++++++++++
 lib/unit-test.h     |  41 +++++
 northd/ovn-northd.c | 362 ++++++++++++++++++++++++++++++++++----------
 tests/atlocal.in    |   1 +
 tests/automake.mk   |   3 +-
 tests/testsuite.at  |   1 +
 9 files changed, 472 insertions(+), 78 deletions(-)
 create mode 100644 lib/unit-test.c
 create mode 100644 lib/unit-test.h

-- 
2.25.4

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to