From 6b5e9a1df7dfb3a971e40aec35119ec019515b69 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Wed, 10 Jun 2015 23:16:01 +0200 Subject: [PATCH 1/4] tests: display the output of failed make check runs After a make check fails, it shows a summary but not the output of the failed tests although they contain information to diagnose the problem. Set the VERBOSE=true automake variable which is documented to collect and display the failed script output at the end of a run (the content of the test-suite.log file (valid from automake-1.11 up). http://www.gnu.org/software/automake/manual/automake.html#index-VERBOSE Also remove the run-make-check.sh that did the same in a way that is not compatible with automake-1.11. Signed-off-by: Loic Dachary (cherry picked from commit 3a55cb029bb7db9542d2b14f2deda90feb0ae0f6) --- run-make-check.sh | 5 ----- src/Makefile-env.am | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/run-make-check.sh b/run-make-check.sh index 4ff0783194e37..e609816782d31 100755 --- a/run-make-check.sh +++ b/run-make-check.sh @@ -61,11 +61,6 @@ function main() { echo "make check: successful run on $(git rev-parse HEAD)" return 0 else - find . -name '*.trs' | xargs grep -l FAIL | while read file ; do - log=$(dirname $file)/$(basename $file .trs).log - echo FAIL: $log - cat $log - done return 1 fi } diff --git a/src/Makefile-env.am b/src/Makefile-env.am index 93d5a9a0b55d4..e5fda78d5ff78 100644 --- a/src/Makefile-env.am +++ b/src/Makefile-env.am @@ -35,6 +35,9 @@ check_PROGRAMS = # tests scripts will be appended to this check_SCRIPTS = +# display the output of failed check_SCRIPTS after a failed make check +export VERBOSE = true + # python unit tests need to know where the scripts are located export PYTHONPATH=$(top_srcdir)/src/pybind From 80afb81124a0d2ef25a23a12c86617ab1da3a4bd Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Tue, 21 Apr 2015 16:11:33 +0200 Subject: [PATCH 2/4] ceph-helpers: implement test_expect_failure To display the output in case the command did not fail with the expected output. Signed-off-by: Loic Dachary (cherry picked from commit 5871781b10ff0b26c731b70d1898c474006cbee3) --- src/test/ceph-helpers.sh | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/test/ceph-helpers.sh b/src/test/ceph-helpers.sh index d02b368f3adb0..5e02d9b4a1a1c 100755 --- a/src/test/ceph-helpers.sh +++ b/src/test/ceph-helpers.sh @@ -972,6 +972,57 @@ function test_repair() { ####################################################################### +## +# Run the *command* and expect it to fail (i.e. return a non zero status). +# The output (stderr and stdout) is stored in a temporary file in *dir* +# and is expected to contain the string *expected*. +# +# Return 0 if the command failed and the string was found. Otherwise +# return 1 and cat the full output of the command on stderr for debug. +# +# @param dir temporary directory to store the output +# @param expected string to look for in the output +# @param command ... the command and its arguments +# @return 0 on success, 1 on error +# + +function expect_failure() { + local dir=$1 + shift + local expected="$1" + shift + local success + + if "$@" > $dir/out 2>&1 ; then + success=true + else + success=false + fi + + if $success || ! grep --quiet "$expected" $dir/out ; then + cat $dir/out >&2 + return 1 + else + return 0 + fi +} + +function test_expect_failure() { + local dir=$1 + + setup $dir || return 1 + expect_failure $dir FAIL bash -c 'echo FAIL ; exit 1' || return 1 + # the command did not fail + ! expect_failure $dir FAIL bash -c 'echo FAIL ; exit 0' > $dir/out || return 1 + grep --quiet FAIL $dir/out || return 1 + # the command failed but the output does not contain the expected string + ! expect_failure $dir FAIL bash -c 'echo UNEXPECTED ; exit 1' > $dir/out || return 1 + ! grep --quiet FAIL $dir/out || return 1 + teardown $dir || return 1 +} + +####################################################################### + ## # Call the **run** function (which must be defined by the caller) with # the **dir** argument followed by the caller argument list. The From 2aaeea145b24b972a0b98549c3527ccf98f4c96f Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Fri, 10 Jul 2015 16:23:47 +0200 Subject: [PATCH 3/4] tests: TEST_crush_reject_empty must not run a mon * Back in Hammer, the osd-crush.sh individual tests did not run the monitor, it was taken care of by the run() function. An attempt to run another mon fails with: error: IO lock testdir/osd-crush/a/store.db/LOCK: Resource temporarily unavailable This problem was introduced by cc1cc033930e8690a57674e842a003f6bbc7a242 from https://github.com/ceph/ceph/pull/4936 * replace test/mon/mon-test-helpers.sh with test/ceph-helpers.sh as we need run_osd() in this newly added test * update the run-dir of commands: ceph-helpers.sh use the different convention for the run-dir of daemons. http://tracker.ceph.com/issues/11975 Refs: #11975 Signed-off-by: Loic Dachary --- src/test/mon/osd-crush.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/mon/osd-crush.sh b/src/test/mon/osd-crush.sh index c0857c4e99f47..1c6347f48e4aa 100755 --- a/src/test/mon/osd-crush.sh +++ b/src/test/mon/osd-crush.sh @@ -15,7 +15,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library Public License for more details. # -source test/mon/mon-test-helpers.sh +source test/ceph-helpers.sh function run() { local dir=$1 @@ -30,7 +30,7 @@ function run() { setup $dir || return 1 run_mon $dir a --public-addr $CEPH_MON if ! $TEST_function $dir ; then - cat $dir/a/log + cat $dir/mon.a.log return 1 fi teardown $dir || return 1 @@ -103,8 +103,8 @@ function TEST_crush_rule_create_erasure() { ./ceph osd erasure-code-profile rm default || return 1 ! ./ceph osd erasure-code-profile ls | grep default || return 1 ./ceph osd crush rule create-erasure $ruleset || return 1 - CEPH_ARGS='' ./ceph --admin-daemon $dir/a/ceph-mon.a.asok log flush || return 1 - grep 'profile default set' $dir/a/log || return 1 + CEPH_ARGS='' ./ceph --admin-daemon $dir/ceph-mon.a.asok log flush || return 1 + grep 'profile default set' $dir/mon.a.log || return 1 ./ceph osd erasure-code-profile ls | grep default || return 1 ./ceph osd crush rule rm $ruleset || return 1 ! ./ceph osd crush rule ls | grep $ruleset || return 1 @@ -190,7 +190,6 @@ function TEST_crush_rename_bucket() { function TEST_crush_reject_empty() { local dir=$1 - run_mon $dir a || return 1 # should have at least one OSD run_osd $dir 0 || return 1 From 7f1c0cc9cd3deab925440b56d82c3e61a8ba5ab1 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 11 Jul 2015 23:04:33 +0800 Subject: [PATCH 4/4] crush/CrushTester: return EINVAL if crushtool returns non-zero this backports a tiny part of ec02441, otherwise CrushTester will return 1, and "ceph" cli will take it as EPERM, which is miss leading, and fails osd-crush.sh:TEST_crush_reject_empty. Signed-off-by: Kefu Chai --- src/crush/CrushTester.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crush/CrushTester.cc b/src/crush/CrushTester.cc index 04c5be1de1617..9aada7b1eb938 100644 --- a/src/crush/CrushTester.cc +++ b/src/crush/CrushTester.cc @@ -435,7 +435,7 @@ int CrushTester::test_with_crushtool(const string& crushtool, // something else entirely happened // log it and consider an invalid crush map err << "error running crushmap through crushtool: " << cpp_strerror(r); - return -r; + return -EINVAL; } namespace {