ceph_watch_wait 'mon.1 \[DBG\] from.*cmd=\[{"prefix": "version"}\]: dispatch'
}
+function test_mon_crushmap_validation()
+{
+ local map=$TMPDIR/map
+ ceph osd getcrushmap -o $map
+ # crushtool validation timesout and is ignored
+ cat > $TMPDIR/crushtool <<EOF
+#!/bin/sh
+sleep 1000
+exit 0 # success
+EOF
+ chmod +x $TMPDIR/crushtool
+ ceph tell mon.* injectargs --crushtool $TMPDIR/crushtool
+ ceph osd setcrushmap -i $map 2>&1 | grep 'took too long'
+ ceph tell mon.* injectargs --crushtool crushtool
+ # crushtool validation succeeds
+ ceph osd setcrushmap -i $map
+}
+
#
# New tests should be added to the TESTS array below
#
MON_TESTS+=" mon_osd_misc"
MON_TESTS+=" mon_heap_profiler"
MON_TESTS+=" mon_tell"
+MON_TESTS+=" mon_crushmap_validation"
OSD_TESTS+=" osd_bench"
+#include "include/stringify.h"
#include "CrushTester.h"
#include <algorithm>
dst.push_back( data_buffer.str() );
}
-int CrushTester::test_with_crushtool(const string& crushtool)
+int CrushTester::test_with_crushtool(const string& crushtool,
+ int timeout)
{
+ string timeout_string = stringify(timeout);
vector<const char *> cmd_args;
+ cmd_args.push_back("timeout");
+ cmd_args.push_back(timeout_string.c_str());
cmd_args.push_back(crushtool.c_str());
cmd_args.push_back("-i");
cmd_args.push_back("-");
// major success!
return 0;
}
+ if (r == 124) {
+ // the test takes longer than timeout and was interrupted
+ return -EINTR;
+ }
if (r == ENOENT) {
err << "unable to find " << cmd_args << " to test the map";
}
int test();
- int test_with_crushtool(const string& crushtool);
+ int test_with_crushtool(const string& crushtool,
+ int timeout);
};
#endif
dout(10) << " testing map" << dendl;
stringstream ess;
CrushTester tester(crush, ess);
- int r = tester.test_with_crushtool(g_conf->crushtool);
+ int r = tester.test_with_crushtool(g_conf->crushtool,
+ g_conf->mon_lease);
if (r < 0) {
- derr << "error on crush map: " << ess.str() << dendl;
- ss << "Failed to parse crushmap: " << ess.str();
- err = r;
- goto reply;
+ if (r == -EINTR) {
+ ss << "(note: crushtool tests not run because they took too long) ";
+ } else {
+ derr << "error on crush map: " << ess.str() << dendl;
+ ss << "Failed to parse crushmap: " << ess.str();
+ err = r;
+ goto reply;
+ }
}
dout(10) << " result " << ess.str() << dendl;