#include <algorithm>
#include <stdlib.h>
-
+#include <boost/lexical_cast.hpp>
#include <common/SubProcess.h>
void CrushTester::set_device_weight(int dev, float f)
dst.push_back( data_buffer.str() );
}
-int CrushTester::test_with_crushtool(const char *crushtool_cmd, int timeout)
+int CrushTester::test_with_crushtool(const char *crushtool_cmd, int max_id, int timeout)
{
SubProcessTimed crushtool(crushtool_cmd, true, false, true, timeout);
- crushtool.add_cmd_args("-i", "-", "--test", NULL);
+ string opt_max_id = boost::lexical_cast<string>(max_id);
+ crushtool.add_cmd_args("-i", "-", "--test", "--check", opt_max_id.c_str(), NULL);
int ret = crushtool.spawn();
if (ret != 0) {
err << "failed run crushtool: " << crushtool.err();
dout(10) << " testing map" << dendl;
stringstream ess;
CrushTester tester(crush, ess);
- if (!tester.check_name_maps(osdmap.get_max_osd())) {
- err = -EINVAL;
- ss << ess.str();
- goto reply;
- }
// XXX: Use mon_lease as a timeout value for crushtool.
// If the crushtool consistently takes longer than 'mon_lease' seconds,
// then we would consistently trigger an election before the command
// finishes, having a flapping monitor unable to hold quorum.
int r = tester.test_with_crushtool(g_conf->crushtool.c_str(),
+ osdmap.get_max_osd(),
g_conf->mon_lease);
if (r < 0) {
derr << "error on crush map: " << ess.str() << dendl;