diff --git a/ngrinder-controller/src/main/java/org/ngrinder/perftest/service/PerfTestRunnable.java b/ngrinder-controller/src/main/java/org/ngrinder/perftest/service/PerfTestRunnable.java index d8b835a94c..a5f658a782 100644 --- a/ngrinder-controller/src/main/java/org/ngrinder/perftest/service/PerfTestRunnable.java +++ b/ngrinder-controller/src/main/java/org/ngrinder/perftest/service/PerfTestRunnable.java @@ -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); diff --git a/ngrinder-controller/src/main/java/org/ngrinder/perftest/service/PerfTestService.java b/ngrinder-controller/src/main/java/org/ngrinder/perftest/service/PerfTestService.java index 7c234a17db..c6897ff731 100644 --- a/ngrinder-controller/src/main/java/org/ngrinder/perftest/service/PerfTestService.java +++ b/ngrinder-controller/src/main/java/org/ngrinder/perftest/service/PerfTestService.java @@ -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.*; /** @@ -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); } /** diff --git a/ngrinder-core/src/main/java/net/grinder/StopReason.java b/ngrinder-core/src/main/java/net/grinder/StopReason.java index 87a43f3381..a2e048b010 100644 --- a/ngrinder-core/src/main/java/net/grinder/StopReason.java +++ b/ngrinder-core/src/main/java/net/grinder/StopReason.java @@ -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"), diff --git a/ngrinder-core/src/main/java/org/ngrinder/model/Status.java b/ngrinder-core/src/main/java/org/ngrinder/model/Status.java index c71a80e447..0a0797f4c1 100644 --- a/ngrinder-core/src/main/java/org/ngrinder/model/Status.java +++ b/ngrinder-core/src/main/java/org/ngrinder/model/Status.java @@ -90,7 +90,7 @@ public enum Status { /** * Detected Abnormal testing. */ - ABNORMAL_TESTING(StatusCategory.TESTING), + ABNORMAL_TESTING(StatusCategory.ABNORMAL_TESTING), /** * Test finished. */ @@ -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; } /** diff --git a/ngrinder-core/src/main/java/org/ngrinder/model/StatusCategory.java b/ngrinder-core/src/main/java/org/ngrinder/model/StatusCategory.java index 482bfe40e3..429ee41175 100644 --- a/ngrinder-core/src/main/java/org/ngrinder/model/StatusCategory.java +++ b/ngrinder-core/src/main/java/org/ngrinder/model/StatusCategory.java @@ -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. */