Skip to content

Commit

Permalink
tests: introduced tests for adding/deleting logical routers in VTEP d…
Browse files Browse the repository at this point in the history
…atabase

New tests were introduced based on lcov report, which reveals apparent code
is not covered by ovs test suites.

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
damijans authored and blp committed Jan 7, 2020
1 parent a13a020 commit c3428f4
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions tests/vtep-ctl.at
Expand Up @@ -129,6 +129,39 @@ m4_define([CHECK_LSWITCHES],
AT_CHECK([RUN_VTEP_CTL([ls-exists nonexistent])], [2], [], [],
[VTEP_CTL_CLEANUP])])


dnl CHECK_LROUTERS([LROUTER], ...)
dnl
dnl Verifies that "vtep-ctl list-lr" prints the specified list of
dnl logical routers, which must be in alphabetical order.
m4_define([CHECK_LROUTERS],
[dnl Check that the lrouters appear on list-lr, without --oneline.
AT_CHECK(
[RUN_VTEP_CTL([list-lr])],
[0],
[m4_foreach([lrinfo], [$@], [m4_car(lrinfo)
])],
[],
[VTEP_CTL_CLEANUP])

dnl Check that the lswitches appear on list-lr, with --oneline.
AT_CHECK(
[RUN_VTEP_CTL_ONELINE([list-lr])],
[0],
[m4_join([\n], m4_foreach([lrinfo], [$@], [m4_car(lrinfo),]))
],
[],
[VTEP_CTL_CLEANUP])

dnl Check that each lrouter exists according to lr-exists and that
dnl a prouter that should not exist does not.
m4_foreach([lrinfo], [$@],
[AT_CHECK([RUN_VTEP_CTL([lr-exists m4_car(lrinfo)])], [0], [],
[], [VTEP_CTL_CLEANUP])])
AT_CHECK([RUN_VTEP_CTL([lr-exists nonexistent])], [2], [], [],
[VTEP_CTL_CLEANUP])])


dnl ----------------------------------------------------------------------
AT_BANNER([vtep-ctl unit tests -- physical switch tests])

Expand Down Expand Up @@ -351,6 +384,60 @@ AT_CHECK([RUN_VTEP_CTL(
VTEP_CTL_CLEANUP
AT_CLEANUP


dnl ----------------------------------------------------------------------
AT_BANNER([vtep-ctl unit tests -- logical router tests])

AT_SETUP([add-lr a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-lr a])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LROUTERS([a])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-lr a, add-lr a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-lr a])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([add-lr a])], [1], [],
[vtep-ctl: cannot create logical router a because it already exists
], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-lr a, add-lr b])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-lr a], [add-lr b])], [0], [], [],
[VTEP_CTL_CLEANUP])
CHECK_LROUTERS([a], [b])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-lr a, add-lr b, del-lr a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-lr a], [add-lr b], [del-lr a])], [0], [], [],
[VTEP_CTL_CLEANUP])
CHECK_LROUTERS([b])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-lr a, del-lr a, add-lr a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL_TOGETHER(
[add-lr a],
[del-lr a],
[add-lr a])], [0], [


], [], [VTEP_CTL_CLEANUP])
CHECK_LROUTERS([a])
VTEP_CTL_CLEANUP
AT_CLEANUP

dnl ----------------------------------------------------------------------
AT_BANNER([vtep-ctl unit tests -- logical binding tests])

Expand Down

0 comments on commit c3428f4

Please sign in to comment.