diff --git a/src/libpmempool/libpmempool.c b/src/libpmempool/libpmempool.c index cd28bc57683e45a18de1998b3aed3d5fbee12a9f..4cacb4c5919e77329e2f99b8829dc8bc8851178d 100644 --- a/src/libpmempool/libpmempool.c +++ b/src/libpmempool/libpmempool.c @@ -69,6 +69,7 @@ libpmempool_init(void) LOG(3, NULL); #ifdef USE_RPMEM util_remote_init(); + util_remote_load(); rpmem_util_cmds_init(); #endif } @@ -84,6 +85,7 @@ libpmempool_fini(void) { LOG(3, NULL); #ifdef USE_RPMEM + util_remote_unload(); util_remote_fini(); rpmem_util_cmds_fini(); #endif diff --git a/src/libpmempool/rm.c b/src/libpmempool/rm.c index 79f6880c7d573efb336a302e6ec9d57f79f8d392..f1e82cf0e2f650f570a2f48a593c4b0e0f18361f 100644 --- a/src/libpmempool/rm.c +++ b/src/libpmempool/rm.c @@ -101,6 +101,12 @@ rm_local(const char *path, int flags, int is_part_file) static int rm_remote(const char *node, const char *path, int flags) { + if (!Rpmem_remove) { + ERR_F(flags, "cannot remove remote replica" + " -- missing librpmem"); + return -1; + } + int rpmem_flags = 0; if (CHECK_FLAG(flags, FORCE)) rpmem_flags |= RPMEM_REMOVE_FORCE; diff --git a/src/test/Makefile b/src/test/Makefile index ac006dfeab0ec1132bafa906872bea6520ec2cb4..7f6fd7bd77edce1f625c7b3f992097aeb7e23fc5 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -306,7 +306,8 @@ REMOTE_TESTS = \ $(OBJ_REMOTE_TESTS)\ $(RPMEM_TESTS)\ pmempool_sync_remote\ - pmempool_transform_remote + pmempool_transform_remote\ + libpmempool_rm_remote ifeq ($(filter n,$(call check_cxx_flags, -std=c++11) $(call check_clang_template_bug)),) LOCAL_TESTS += $(OBJ_CPP_TESTS) diff --git a/src/test/libpmempool_rm/Makefile.inc b/src/test/libpmempool_rm/Makefile.inc new file mode 100644 index 0000000000000000000000000000000000000000..a296b721e3d6f37eb539d95966533230c7410de3 --- /dev/null +++ b/src/test/libpmempool_rm/Makefile.inc @@ -0,0 +1,42 @@ +# +# Copyright 2017, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# +# src/test/libpmempool_rm/Makefile.inc -- build libpmempool_rm test +# + +include ../Makefile.inc + +../libpmempool_rm/libpmempool_rm: + $(MAKE) -C ../libpmempool_rm all + +all: ../libpmempool_rm/libpmempool_rm diff --git a/src/test/libpmempool_rm_remote/Makefile b/src/test/libpmempool_rm_remote/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..88a09b45045351cc3ca87cc7ede39faa628f0724 --- /dev/null +++ b/src/test/libpmempool_rm_remote/Makefile @@ -0,0 +1,41 @@ +# +# Copyright 2017, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# +# src/test/libpmempool_rm_remote/Makefile -- unit test for pmempool_rm +# with remote replica +# +SCP_TO_REMOTE_NODES = y +SCP_TARGET = libpmempool_rm +SCP_SRC_DIR = ../libpmempool_rm + +include ../libpmempool_rm/Makefile.inc diff --git a/src/test/libpmempool_rm_remote/TEST0 b/src/test/libpmempool_rm_remote/TEST0 new file mode 100755 index 0000000000000000000000000000000000000000..ac42fdfb9516003362aca0c2255e9b9b3e22680f --- /dev/null +++ b/src/test/libpmempool_rm_remote/TEST0 @@ -0,0 +1,75 @@ +#!/bin/bash -e +# +# Copyright 2017, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# +# libpmempool_rm_remote/TEST0 -- test for pmempool_rm with remote replica +# +# Remove pool, do not remove local and remote pool sets. +# +export UNITTEST_NAME=libpmempool_rm_remote/TEST0 +export UNITTEST_NUM=0 + +# standard unit test setup +. ../unittest/unittest.sh + +require_test_type medium + +setup + +require_nodes 2 + +require_node_libfabric 0 $RPMEM_PROVIDER +require_node_libfabric 1 $RPMEM_PROVIDER + +init_rpmem_on_node 1 0 + +create_poolset $DIR/pool.set 8M:$(get_node_dir 1)/pool.1:x \ + m ${NODE_ADDR[0]}:remote.set +create_poolset $DIR/remote.set 8M:$(get_node_dir 0)/remote.1:x + +copy_files_to_node 0 . $DIR/remote.set +copy_files_to_node 1 . $DIR/pool.set + +rm_files_from_node 0 remote.1 +rm_files_from_node 1 pool.1 + +expect_normal_exit run_on_node 1 ../pmempool create obj pool.set +check_files_on_node 1 pool.set pool.1 +check_files_on_node 0 remote.set remote.1 + +expect_normal_exit run_on_node 1 ./libpmempool_rm$EXESUFFIX pool.set +check_files_on_node 1 pool.set +check_files_on_node 0 remote.set +check_no_files_on_node 1 pool.1 +check_no_files_on_node 0 remote.1 + +pass diff --git a/src/test/libpmempool_rm_remote/TEST1 b/src/test/libpmempool_rm_remote/TEST1 new file mode 100755 index 0000000000000000000000000000000000000000..6f6e981be15c1e25d75aa5ca66c91626437d93e8 --- /dev/null +++ b/src/test/libpmempool_rm_remote/TEST1 @@ -0,0 +1,74 @@ +#!/bin/bash -e +# +# Copyright 2017, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# +# libpmempool_rm_remote/TEST1 -- test for pmempool_rm with remote replica +# +# Remove pool and local pool set, do not remove remote pool set. +# +export UNITTEST_NAME=libpmempool_rm_remote/TEST1 +export UNITTEST_NUM=1 + +# standard unit test setup +. ../unittest/unittest.sh + +require_test_type medium + +setup + +require_nodes 2 + +require_node_libfabric 0 $RPMEM_PROVIDER +require_node_libfabric 1 $RPMEM_PROVIDER + +init_rpmem_on_node 1 0 + +create_poolset $DIR/pool.set 8M:$(get_node_dir 1)/pool.1:x \ + m ${NODE_ADDR[0]}:remote.set +create_poolset $DIR/remote.set 8M:$(get_node_dir 0)/remote.1:x + +copy_files_to_node 0 . $DIR/remote.set +copy_files_to_node 1 . $DIR/pool.set + +rm_files_from_node 0 remote.1 +rm_files_from_node 1 pool.1 + +expect_normal_exit run_on_node 1 ../pmempool create obj pool.set +check_files_on_node 1 pool.set pool.1 +check_files_on_node 0 remote.set remote.1 + +expect_normal_exit run_on_node 1 ./libpmempool_rm$EXESUFFIX -l pool.set +check_files_on_node 0 remote.set +check_no_files_on_node 1 pool.set pool.1 +check_no_files_on_node 0 remote.1 + +pass diff --git a/src/test/libpmempool_rm_remote/TEST2 b/src/test/libpmempool_rm_remote/TEST2 new file mode 100755 index 0000000000000000000000000000000000000000..4c63d22f34a3216c04352b60dff952c69212b5e9 --- /dev/null +++ b/src/test/libpmempool_rm_remote/TEST2 @@ -0,0 +1,73 @@ +#!/bin/bash -e +# +# Copyright 2017, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# +# libpmempool_rm_remote/TEST2 -- test for pmempool_rm with remote replica +# +# Remove pool, local and remote pool sets. +# +export UNITTEST_NAME=libpmempool_rm_remote/TEST2 +export UNITTEST_NUM=2 + +# standard unit test setup +. ../unittest/unittest.sh + +require_test_type medium + +setup + +require_nodes 2 + +require_node_libfabric 0 $RPMEM_PROVIDER +require_node_libfabric 1 $RPMEM_PROVIDER + +init_rpmem_on_node 1 0 + +create_poolset $DIR/pool.set 8M:$(get_node_dir 1)/pool.1:x \ + m ${NODE_ADDR[0]}:remote.set +create_poolset $DIR/remote.set 8M:$(get_node_dir 0)/remote.1:x + +copy_files_to_node 0 . $DIR/remote.set +copy_files_to_node 1 . $DIR/pool.set + +rm_files_from_node 0 remote.1 +rm_files_from_node 1 pool.1 + +expect_normal_exit run_on_node 1 ../pmempool create obj pool.set +check_files_on_node 1 pool.set pool.1 +check_files_on_node 0 remote.set remote.1 + +expect_normal_exit run_on_node 1 ./libpmempool_rm$EXESUFFIX -l -r pool.set +check_no_files_on_node 1 pool.set pool.1 +check_no_files_on_node 0 remote.set remote.1 + +pass diff --git a/src/test/libpmempool_rm_remote/TEST3 b/src/test/libpmempool_rm_remote/TEST3 new file mode 100755 index 0000000000000000000000000000000000000000..ffbc7dbc90454c1ac37517e475e0977fbd28d5d9 --- /dev/null +++ b/src/test/libpmempool_rm_remote/TEST3 @@ -0,0 +1,77 @@ +#!/bin/bash -e +# +# Copyright 2017, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# +# libpmempool_rm_remote/TEST3 -- test for pmempool_rm with remote replica +# +# Remove pool, do not remove local and remote pool sets. +# +export UNITTEST_NAME=libpmempool_rm_remote/TEST3 +export UNITTEST_NUM=3 + +# standard unit test setup +. ../unittest/unittest.sh + +require_test_type medium + +setup + +require_nodes 2 + +require_node_libfabric 0 $RPMEM_PROVIDER +require_node_libfabric 1 $RPMEM_PROVIDER +require_node_dax_device 0 + +init_rpmem_on_node 1 0 + +create_poolset $DIR/pool.set 8M:$(get_node_dir 1)/pool.1:x \ + m ${NODE_ADDR[0]}:remote.set +create_poolset $DIR/remote.set AUTO:${NODE_DEVICE_DAX_PATH[0]} + +copy_files_to_node 0 . $DIR/remote.set +copy_files_to_node 1 . $DIR/pool.set + +expect_normal_exit run_on_node 1 ./libpmempool_rm$EXESUFFIX -f pool.set + +expect_normal_exit run_on_node 1 ../pmempool create obj pool.set +check_files_on_node 1 pool.set pool.1 +check_files_on_node 0 remote.set + +expect_normal_exit run_on_node 1 ./libpmempool_rm$EXESUFFIX pool.set +check_files_on_node 1 pool.set +check_files_on_node 0 remote.set +check_no_files_on_node 1 pool.1 + +# Verify that we can create pool on device dax after removing it. +expect_normal_exit run_on_node 1 ../pmempool create obj pool.set + +pass diff --git a/src/test/libpmempool_rm_remote/config.sh b/src/test/libpmempool_rm_remote/config.sh new file mode 100644 index 0000000000000000000000000000000000000000..40effdec5fdccfb092332b9c3ed100171549baa8 --- /dev/null +++ b/src/test/libpmempool_rm_remote/config.sh @@ -0,0 +1,41 @@ +#!/bin/bash -e +# +# Copyright 2017, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# +# libpmempool_rm_remote/config.sh -- test configuration +# + +CONF_GLOBAL_FS_TYPE=any +CONF_GLOBAL_BUILD_TYPE="debug nondebug" + +CONF_GLOBAL_RPMEM_PROVIDER=all +CONF_GLOBAL_RPMEM_PMETHOD=all diff --git a/src/test/unittest/unittest.sh b/src/test/unittest/unittest.sh index 3c6018d412f6842405dedbcc5df42d4a20bbcfd4..9a58f344eaf22a441ad8c0aa94b23711485b1200 100644 --- a/src/test/unittest/unittest.sh +++ b/src/test/unittest/unittest.sh @@ -1275,6 +1275,7 @@ function run_command() fi } + # # validate_node_number -- validate a node number # @@ -1479,6 +1480,28 @@ function require_nodes() { return 0 } +# +# check_files_on_node -- check if specified files exist on given node +# +function check_files_on_node() { + validate_node_number $1 + local N=$1 + shift + local REMOTE_DIR=${NODE_WORKING_DIR[$N]}/$curtestdir + run_command ssh $SSH_OPTS ${NODE[$N]} "for f in $*; do if [ ! -f $REMOTE_DIR/\$f ]; then echo \"Missing file \$f on node #$N\" 1>&2; exit 1; fi; done" +} + +# +# check_no_files_on_node -- check if specified files does not exist on given node +# +function check_no_files_on_node() { + validate_node_number $1 + local N=$1 + shift + local REMOTE_DIR=${NODE_WORKING_DIR[$N]}/$curtestdir + run_command ssh $SSH_OPTS ${NODE[$N]} "for f in $*; do if [ -f $REMOTE_DIR/\$f ]; then echo \"Not deleted file \$f on node #$N\" 1>&2; exit 1; fi; done" +} + # # copy_files_to_node -- copy all required files to the given remote node # usage: copy_files_to_node <node> <destination dir> <file_1> [<file_2>] ...