Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unstoppable abnormal test #684

Merged
merged 2 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,14 @@ void runTestOn(final PerfTest perfTest, GrinderProperties grinderProperties, fin
singleConsole.addListener(new ConsoleShutdownListener() {
@Override
public void readyToStop(StopReason stopReason) {
perfTestService.markAbnormalTermination(perfTest, stopReason);
LOG.error("Abnormal test {} due to {}", perfTest.getId(), stopReason.name());
PerfTest fetchedPerftest = perfTestService.getOne(perfTest.getId());
if (fetchedPerftest.getStatus().isStoppable()) {
perfTestService.markAbnormalTermination(perfTest, stopReason);
LOG.error("Abnormal test {} due to {}", perfTest.getId(), stopReason.name());
}
}
});

long startTime = singleConsole.startTest(grinderProperties);
perfTest.setStartTime(ofEpochMilli(startTime));
addSamplingListeners(perfTest, singleConsole);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@
import static org.ngrinder.common.util.Preconditions.checkNotEmpty;
import static org.ngrinder.common.util.Preconditions.checkNotNull;
import static org.ngrinder.common.util.TypeConvertUtils.cast;
import static org.ngrinder.model.Status.PREPARE_DISTRIBUTION;
import static org.ngrinder.model.Status.getProcessingOrTestingTestStatus;
import static org.ngrinder.model.Status.*;
import static org.ngrinder.perftest.repository.PerfTestSpecification.*;

/**
Expand Down Expand Up @@ -1033,7 +1032,6 @@ public void stop(User user, Long id) {
// This will be not be effective on cluster mode.
consoleManager.getConsoleUsingPort(perfTest.getPort()).cancel();
perfTest.setStopRequest(true);
perfTestRepository.save(perfTest);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ngrinder-core/src/main/java/net/grinder/StopReason.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public enum StopReason {
TOO_MANY_ERRORS("Too many errors"),
/** Error while test preparation. */
ERROR_WHILE_PREPARE("Test preparation error"),
/** Error while first execution. */
/** Error while first execution or no recording. */
SCRIPT_ERROR("Script error"),
/** Error by too much overall traffic on the given region. */
TOO_MUCH_TRAFFIC_ON_REGION("Too much traffic error"),
Expand Down
8 changes: 5 additions & 3 deletions ngrinder-core/src/main/java/org/ngrinder/model/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public enum Status {
/**
* Detected Abnormal testing.
*/
ABNORMAL_TESTING(StatusCategory.TESTING),
ABNORMAL_TESTING(StatusCategory.ABNORMAL_TESTING),
/**
* Test finished.
*/
Expand Down Expand Up @@ -198,10 +198,12 @@ public static Status[] getProcessingOrTestingTestStatus() {
* Check this status is the working status.
*
* @param status status
* @return true if it's in {@link StatusCategory}'s PROCESSING or TESTING.
* @return true if it's in {@link StatusCategory}'s PROCESSING or TESTING or ABNORMAL_TESTING.
*/
private static boolean isWorkingStatus(Status status) {
return status.getCategory() == StatusCategory.PROGRESSING || status.getCategory() == StatusCategory.TESTING;
return status.getCategory() == StatusCategory.PROGRESSING ||
status.getCategory() == StatusCategory.TESTING ||
status.getCategory() == StatusCategory.ABNORMAL_TESTING;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public enum StatusCategory {
* Testing.
*/
TESTING("green_anime.gif", true, false, false),
/**
* Abnormal testing.
*/
ABNORMAL_TESTING("yellow_anime.gif", false, false, false),
/**
* Finished normally.
*/
Expand Down