first draft of adding option to kill processes

This commit is contained in:
Jon Fu 2019-11-04 15:46:45 -08:00
parent d9d1cdc470
commit ba2c5dd2a6
1 changed files with 14 additions and 2 deletions

View File

@ -66,6 +66,7 @@ struct MachineAttritionWorkload : TestWorkload {
bool killDc;
bool killMachine;
bool killDatahall;
bool killProcess;
bool killSelf;
Standalone<StringRef> targetId;
bool replacement;
@ -88,6 +89,7 @@ struct MachineAttritionWorkload : TestWorkload {
killDc = getOption( options, LiteralStringRef("killDc"), deterministicRandom()->random01() < 0.25 );
killMachine = getOption( options, LiteralStringRef("killMachine"), false);
killDatahall = getOption( options, LiteralStringRef("killDatahall"), false);
killProcess = getOption( options, LiteralStringRef("killProcess"), false);
killSelf = getOption( options, LiteralStringRef("killSelf"), false );
targetId = getOption( options, LiteralStringRef("targetId"), LiteralStringRef(""));
replacement = getOption( options, LiteralStringRef("replacement"), reboot && deterministicRandom()->random01() < 0.5 );
@ -147,8 +149,7 @@ struct MachineAttritionWorkload : TestWorkload {
}
static bool noSimIsViableKill(WorkerDetails worker) {
if (worker.processClass == ProcessClass::ClassType::TesterClass) return false;
return true;
return (worker.processClass == ProcessClass::ClassType::TesterClass);
}
ACTOR static Future<Void> noSimMachineKillWorker(MachineAttritionWorkload *self, Database cx) {
@ -204,6 +205,17 @@ struct MachineAttritionWorkload : TestWorkload {
worker.interf.clientInterface.reboot.send(rbReq);
}
}
} else if (self->killProcess) {
// Pick a process to kill
Optional<Standalone<StringRef>> killProcessId = self->targetId.toString().empty() ? workers.back().interf.locality.processId() : self->targetId;
TraceEvent("Assassination").detail("TargetProcessId", killProcessId);
for (const auto& worker : workers) {
// kill matching processes
if (worker.interf.locality.processId().present() && worker.interf.locality.processId() == killProcessId) {
TraceEvent("SendingRebootRequest").detail("TargetMachine", worker.interf.locality.toString());
worker.interf.clientInterface.reboot.send(rbReq);
}
}
} else {
while (killedMachines < self->machinesToKill && workers.size() > self->machinesToLeave) {
TraceEvent("WorkerKillBegin")