From 43540e83b692dddb89055afbc393b79532659ad2 Mon Sep 17 00:00:00 2001 From: James Nunez Date: Mon, 25 Nov 2019 07:25:50 -0700 Subject: [PATCH] LU-13002 tests: change clean up in sanity-lnet sanity-lnet should detect the state of the system before executing, and restore that state when it has finished. Test-Parameters: trivial Test-Parameters: testlist=sanity-lnet,runtests Signed-off-by: James Nunez Change-Id: I3e3c5465789389e840efab516b35234cd61be901 Reviewed-on: https://review.whamcloud.com/36849 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Chris Horn Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- lustre/tests/sanity-lnet.sh | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/lustre/tests/sanity-lnet.sh b/lustre/tests/sanity-lnet.sh index 052c39d..b3e5e92 100755 --- a/lustre/tests/sanity-lnet.sh +++ b/lustre/tests/sanity-lnet.sh @@ -28,6 +28,38 @@ export LNETCTL=${LNETCTL:-"$LUSTRE/../lnet/utils/lnetctl"} export LNETCTL=$(which lnetctl 2> /dev/null) [[ -z $LNETCTL ]] && skip "Need lnetctl" +restore_mounts=false + +if is_mounted $MOUNT || is_mounted $MOUNT2; then + cleanupall || error "Failed cleanup prior to test execution" + restore_mounts=true +fi + +cleanup_lnet() { + echo "Cleaning up LNet" + $LNETCTL lnet unconfigure 2>/dev/null + unload_modules +} + +restore_modules=false +if module_loaded lnet ; then + cleanup_lnet || error "Failed to unload modules before test execution" + restore_modules=true +fi + +cleanup_testsuite() { + rm -f $TMP/sanity-dlc* + cleanup_netns + cleanup_lnet + if $restore_mounts; then + setupall || error "Failed to setup Lustre after test execution" + elif $restore_modules; then + load_modules || + error "Couldn't load modules after test execution" + fi + return 0 +} + load_lnet() { load_module ../libcfs/libcfs/libcfs # Prevent local MODOPTS_LIBCFS being passed as part of environment @@ -51,11 +83,6 @@ load_lnet() { load_module ../lnet/klnds/$LNETLND } -cleanup_lnet() { - $LNETCTL lnet unconfigure 2>/dev/null - unload_modules -} - do_lnetctl() { echo "$LNETCTL $@" $LNETCTL "$@" @@ -134,6 +161,7 @@ test_5() { } run_test 5 "add a network using an interface in the non-default namespace" -cleanup_netns -cleanup_lnet +complete $SECONDS + +cleanup_testsuite exit_status -- 1.8.3.1