Skip to content

Commit

Permalink
added logs to testing module
Browse files Browse the repository at this point in the history
  • Loading branch information
avneesh-akto committed Mar 18, 2024
1 parent 06f296c commit 1493520
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 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 @@ -190,6 +190,7 @@ public static void main(String[] args) throws InterruptedException {

while (true) {
AccountTask.instance.executeTask(account -> {
int accountId = account.getId();

int start = Context.now();

Expand All @@ -201,16 +202,18 @@ public static void main(String[] args) throws InterruptedException {
testingRun = findPendingTestingRun();
} else {
summaryId = trrs.getId();
loggerMaker.infoAndAddToDb("Found trrs " + trrs.getHexId() + " for account: " + accountId);
testingRun = TestingRunDao.instance.findOne("_id", trrs.getTestingRunId());
}

if (testingRun == null) {
return;
}

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

boolean isTestingRunRunning = testingRun.getState().equals(State.RUNNING);

int accountId = account.getId();
if (UsageMetricUtils.checkTestRunsOverage(accountId)) {
int lastSent = logSentMap.getOrDefault(accountId, 0);
if (start - lastSent > LoggerMaker.LOG_SAVE_INTERVAL) {
Expand All @@ -233,6 +236,7 @@ public static void main(String[] args) throws InterruptedException {
setTestingRunConfig(testingRun, trrs);

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());
if (testingRunResultSummary != null) {
Expand Down Expand Up @@ -287,6 +291,8 @@ public static void main(String[] args) throws InterruptedException {
trrs = createTRRSummaryIfAbsent(testingRun, start);
summaryId = trrs.getId();
}
} else {
loggerMaker.infoAndAddToDb("No summary found. Let's run it as usual");
}
}

Expand Down Expand Up @@ -329,7 +335,7 @@ public static void main(String[] args) throws InterruptedException {
TestExecutor.updateTestSummary(summaryId);
}

loggerMaker.infoAndAddToDb("Tests completed in " + (Context.now() - start) + " seconds", LogDb.TESTING);
loggerMaker.infoAndAddToDb("Tests completed in " + (Context.now() - start) + " seconds for account: " + accountId, LogDb.TESTING);
}, "testing");
Thread.sleep(1000);
}
Expand Down

0 comments on commit 1493520

Please sign in to comment.