Skip to content

Commit

Permalink
Add controller config ignore some stop reasons (naver#883)
Browse files Browse the repository at this point in the history
* Add controller config ignore some stop reasons

ignore TOO_LOW_TPS, TOO_MANY_ERRORS, TOO_MUCH_TRAFFIC_ON_REGION by set property value as true

* Change property values '... ignore.' to '... ignore_'

* Move ignoreStop from Config to PerfTestRunnable

Move stop reason determination role from Config to PerfTestRunnable

* Change property key '... ignore.' to '... ignore_

* Rename ignoreStop and Change parameters spec

- Rename ignoreStop to isValidStopReason and using Config by field not by passing param
- long complex conditions -> if statements

* Remove unused import

* Fix bug from typo mistake

* Change its log level to debug

* Move isValidStopReason condition to if block below

check condition only if status is stoppable

* Fix typo

Co-authored-by: Imbyungjun <[email protected]>

* Remove unnecessary properties

* Remove unnecessary log

* cleanup

Co-authored-by: ingeol.song <[email protected]>
Co-authored-by: Imbyungjun <[email protected]>
Co-authored-by: imb <[email protected]>
  • Loading branch information
4 people authored Jul 7, 2022
1 parent eb068e0 commit 345f1d3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ public interface ControllerConstants {
String PROP_CONTROLLER_ENABLE_STATISTICS = "controller.enable_statistics";
String PROP_CONTROLLER_CSV_SEPARATOR = "controller.csv_separator";
String PROP_CONTROLLER_GITHUB_BASE_URL = "controller.github_base_url";
String PROP_CONTROLLER_IGNORE_TOO_LOW_TPS = "controller.ignore_too_low_tps";
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.ngrinder.agent.service.AgentService;
import org.ngrinder.common.constant.ControllerConstants;
import org.ngrinder.common.exception.PerfTestPrepareException;
import org.ngrinder.common.util.PropertiesWrapper;
import org.ngrinder.extension.OnTestLifeCycleRunnable;
import org.ngrinder.extension.OnTestSamplingRunnable;
import org.ngrinder.infra.config.Config;
Expand Down Expand Up @@ -383,6 +384,15 @@ void startAgentsOn(PerfTest perfTest, GrinderProperties grinderProperties, Singl
+ " agents are ready.");
}

private boolean isValidStopReason(StopReason stopReason) {
PropertiesWrapper properties = config.getControllerProperties();
if (stopReason == StopReason.TOO_LOW_TPS &&
properties.getPropertyBoolean(PROP_CONTROLLER_IGNORE_TOO_LOW_TPS, false)) {
return true;
}
return false;
}

/**
* Run a given {@link PerfTest} with the given {@link GrinderProperties} and
* the {@link SingleConsole} .
Expand All @@ -404,6 +414,9 @@ void runTestOn(final PerfTest perfTest, GrinderProperties grinderProperties, fin
singleConsole.addListener(stopReason -> {
PerfTest fetchedPerftest = perfTestService.getOne(perfTest.getId());
if (fetchedPerftest.getStatus().isStoppable()) {
if (isValidStopReason(stopReason)) {
return;
}
perfTestService.markAbnormalTermination(perfTest, stopReason);
LOG.error(format(perfTest, "Abnormal test due to {}", stopReason.name()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ controller.inactive_client_time_out,30000
controller.enable_statistics,false
controller.csv_separator,comma,
controller.github_base_url,https://api.github.com,
controller.ignore_too_low_tps,false,
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
# The default base url for searching scripts from github.
#controller.github_base_url=https://api.github.com

# Ignore if ConsoleShutdownListener triggered by TOO_LOW_TPS
#controller.ignore_too_low_tps=false

######################################################################################
# clustering configuration.
# This is not the option applied on the fly. You need to reboot to apply this.
Expand Down

0 comments on commit 345f1d3

Please sign in to comment.