Skip to content

Commit

Permalink
fixed bug to not run stopped tests and do the right check for trrs
Browse files Browse the repository at this point in the history
  • Loading branch information
avneesh-akto committed Apr 6, 2024
1 parent 28abefe commit 6d9021b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions apps/testing/src/main/java/com/akto/testing/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,19 @@ public void run() {
return;
}

if (testingRun.getState().equals(State.STOPPED)) {
loggerMaker.infoAndAddToDb("Testing run stopped");
if (trrs != null) {
loggerMaker.infoAndAddToDb("Stopping TRRS: " + trrs.getId());
TestingRunResultSummariesDao.instance.updateOneNoUpsert(
Filters.eq(Constants.ID, trrs.getId()),
Updates.set(TestingRunResultSummary.STATE, State.STOPPED)
);
loggerMaker.infoAndAddToDb("Stopped TRRS: " + trrs.getId());
}
return;
}

loggerMaker.infoAndAddToDb("Starting test for accountID: " + accountId);

boolean isTestingRunRunning = testingRun.getState().equals(State.RUNNING);
Expand Down Expand Up @@ -278,8 +291,14 @@ public void run() {

if (isSummaryRunning || isTestingRunRunning) {
loggerMaker.infoAndAddToDb("TRRS or TR is in running state, checking if it should run it or not");
Map<ObjectId, TestingRunResultSummary> objectIdTestingRunResultSummaryMap = TestingRunResultSummariesDao.instance.fetchLatestTestingRunResultSummaries(Collections.singletonList(testingRun.getId()));
TestingRunResultSummary testingRunResultSummary = objectIdTestingRunResultSummaryMap.get(testingRun.getId());
TestingRunResultSummary testingRunResultSummary;
if (trrs != null) {
testingRunResultSummary = trrs;
} else {
Map<ObjectId, TestingRunResultSummary> objectIdTestingRunResultSummaryMap = TestingRunResultSummariesDao.instance.fetchLatestTestingRunResultSummaries(Collections.singletonList(testingRun.getId()));
testingRunResultSummary = objectIdTestingRunResultSummaryMap.get(testingRun.getId());
}

if (testingRunResultSummary != null) {
List<TestingRunResult> testingRunResults = TestingRunResultDao.instance.fetchLatestTestingRunResult(Filters.eq(TestingRunResult.TEST_RUN_RESULT_SUMMARY_ID, testingRunResultSummary.getId()), 1);
if (testingRunResults != null && !testingRunResults.isEmpty()) {
Expand Down

0 comments on commit 6d9021b

Please sign in to comment.