Whamcloud - gitweb
LU-13002 tests: change clean up in sanity-lnet 49/36849/5
authorJames Nunez <jnunez@whamcloud.com>
Mon, 25 Nov 2019 14:25:50 +0000 (07:25 -0700)
committerOleg Drokin <green@whamcloud.com>
Fri, 20 Dec 2019 03:25:17 +0000 (03:25 +0000)
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 <jnunez@whamcloud.com>
Change-Id: I3e3c5465789389e840efab516b35234cd61be901
Reviewed-on: https://review.whamcloud.com/36849
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <hornc@cray.com>
Reviewed-by: Shaun Tancheff <stancheff@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-lnet.sh

index 052c39d..b3e5e92 100755 (executable)
@@ -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