Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: TEST_crush_reject_empty must not run a mon #5208

Merged
merged 4 commits into from Jul 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions run-make-check.sh
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile-env.am
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/crush/CrushTester.cc
Expand Up @@ -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 {
Expand Down
51 changes: 51 additions & 0 deletions src/test/ceph-helpers.sh
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions src/test/mon/osd-crush.sh
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down