Skip to content

Commit

Permalink
Merge pull request #1862 from akto-api-security/base_config_fetch_retry
Browse files Browse the repository at this point in the history
remove findhost computation
  • Loading branch information
notshivansh authored Dec 24, 2024
2 parents 8a8cd88 + 4c2f042 commit b0c74eb
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions apps/testing/src/main/java/com/akto/testing/TestExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,27 +232,27 @@ public void apiWiseInit(TestingRun testingRun, ObjectId summaryId, boolean debug

loggerMaker.infoAndAddToDb("Started filling hostname map with categories at :" + Context.now());
int timeNow = Context.now();
for (String testSubCategory: testingRunSubCategories) {
TestConfig testConfig = testConfigMap.get(testSubCategory);
if (testConfig == null || testConfig.getStrategy() == null || testConfig.getStrategy().getRunOnce() == null) {
continue;
}
for (ApiInfo.ApiInfoKey apiInfoKey: apiInfoKeyList) {
try {
hostName = findHost(apiInfoKey, testingUtil.getSampleMessages(), testingUtil.getSampleMessageStore());
if (hostName == null) {
continue;
}
if(hostsToApiCollectionMap.get(hostName) == null) {
hostsToApiCollectionMap.put(hostName, apiInfoKey.getApiCollectionId());
}
apiInfoKeyToHostMap.put(apiInfoKey, hostName);
subCategoryEndpointMap.put(apiInfoKey.getApiCollectionId() + "_" + testSubCategory, hostName);
} catch (URISyntaxException e) {
loggerMaker.errorAndAddToDb("Error while finding host: " + e, LogDb.TESTING);
}
}
}
// for (String testSubCategory: testingRunSubCategories) {
// TestConfig testConfig = testConfigMap.get(testSubCategory);
// if (testConfig == null || testConfig.getStrategy() == null || testConfig.getStrategy().getRunOnce() == null) {
// continue;
// }
// for (ApiInfo.ApiInfoKey apiInfoKey: apiInfoKeyList) {
// try {
// hostName = findHost(apiInfoKey, testingUtil.getSampleMessages(), testingUtil.getSampleMessageStore());
// if (hostName == null) {
// continue;
// }
// if(hostsToApiCollectionMap.get(hostName) == null) {
// hostsToApiCollectionMap.put(hostName, apiInfoKey.getApiCollectionId());
// }
// apiInfoKeyToHostMap.put(apiInfoKey, hostName);
// subCategoryEndpointMap.put(apiInfoKey.getApiCollectionId() + "_" + testSubCategory, hostName);
// } catch (URISyntaxException e) {
// loggerMaker.errorAndAddToDb("Error while finding host: " + e, LogDb.TESTING);
// }
// }
// }
loggerMaker.infoAndAddToDb("Completed filling hostname map with categories in :" + (Context.now() - timeNow));

final int maxRunTime = testingRun.getTestRunTime() <= 0 ? 30*60 : testingRun.getTestRunTime(); // if nothing specified wait for 30 minutes
Expand Down Expand Up @@ -668,13 +668,12 @@ public boolean applyRunOnceCheck(ApiInfoKey apiInfoKey, TestConfig testConfig, C
return true;
}

String host;
host = apiInfoKeyToHostMap.get(apiInfoKey);
if (host != null) {
String val = subCategoryEndpointMap.remove(apiInfoKey.getApiCollectionId() + "_" + testSubCategory);
return val != null;
String val = subCategoryEndpointMap.get(apiInfoKey.getApiCollectionId() + "_" + testSubCategory);
if (val == null) {
subCategoryEndpointMap.put(apiInfoKey.getApiCollectionId() + "_" + testSubCategory, "true");
return true;
}
return true;
return false;
}

public TestingRunResult runTestNew(ApiInfo.ApiInfoKey apiInfoKey, ObjectId testRunId, TestingUtil testingUtil,
Expand Down

0 comments on commit b0c74eb

Please sign in to comment.