Skip to content

Commit

Permalink
fixed a bug where Restart was not parsed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
LitschiW committed May 12, 2022
1 parent aa8c879 commit a397949
Showing 1 changed file with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,27 +168,25 @@ private void parseTimedFaultload(Collection<ISelfScheduled> scheduables, String
throw new ParsingException(String.format("Could not find target service '%s'", artifact));
}

if (currentStimulus.startsWith("KILL")) {

String[] stimuliArray = currentStimulus.split(" ");
String[] stimuliArray = currentStimulus.split(" ");

int instances = Integer.MAX_VALUE;
int instances = Integer.MAX_VALUE;

if (stimuliArray.length == 2) {
try {
instances = Integer.parseInt(stimuliArray[1]);
} catch (NumberFormatException e) {
service = NameResolver.resolveMicroserviceName(model, stimuliArray[1]);
}
} else if (stimuliArray.length == 3) {
if (stimuliArray.length == 2) {
try {
instances = Integer.parseInt(stimuliArray[1]);
} catch (NumberFormatException e) {
service = NameResolver.resolveMicroserviceName(model, stimuliArray[1]);
instances = Integer.parseInt(stimuliArray[2]);
} else if (stimuliArray.length != 1) {
throw new ParsingException("KILL was not defined correctly (KILL [<service_name>] "
+ "[<#instances>]@<target_time>)");
}
} else if (stimuliArray.length == 3) {
service = NameResolver.resolveMicroserviceName(model, stimuliArray[1]);
instances = Integer.parseInt(stimuliArray[2]);
} else if (stimuliArray.length != 1) {
throw new ParsingException("Command was not defined correctly (KILL/START/RESTART [<service_name>] "
+ "[<#instances>]@<target_time>)");
}


if (currentStimulus.startsWith("KILL")) {
scheduables.add(
new ChaosMonkeyEvent(model, "Chaosmonkey", true, service, instances) {
{
Expand All @@ -197,9 +195,6 @@ private void parseTimedFaultload(Collection<ISelfScheduled> scheduables, String
}
);
} else if (currentStimulus.startsWith("RESTART") || currentStimulus.startsWith("START")) {
int instances = Integer.parseInt(currentStimulus.replaceAll("(RE)?START", "").trim());


scheduables.add(
new SummonerMonkeyEvent(model, "Summoner", true, service, instances) {
{
Expand Down

0 comments on commit a397949

Please sign in to comment.