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

Run tests through kafka #2005

Merged
merged 14 commits into from
Jan 30, 2025
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.akto.dao.testing.TestingRunResultDao;
import com.akto.dto.AccountSettings;
import com.akto.dto.ApiInfo;
import com.akto.dto.ApiInfo.ApiInfoKey;
import com.akto.dto.CustomAuthType;
import com.akto.dto.User;
import com.akto.dto.test_editor.Category;
Expand Down Expand Up @@ -45,6 +46,7 @@
import com.akto.store.TestingUtil;
import com.akto.test_editor.execution.VariableResolver;
import com.akto.testing.TestExecutor;
import com.akto.testing.Utils;
import com.akto.util.Constants;
import com.akto.util.enums.GlobalEnums;
import com.akto.util.enums.GlobalEnums.Severity;
Expand Down Expand Up @@ -334,7 +336,11 @@ public String runTestForGivenTemplate() {
int lastSampleIndex = sampleDataList.get(0).getSamples().size() - 1;

TestingRunConfig testingRunConfig = new TestingRunConfig();
testingRunResult = executor.runTestNew(infoKey, null, testingUtil, null, testConfig, testingRunConfig, true, testLogs);
List<String> samples = testingUtil.getSampleMessages().get(infoKey);
TestingRunResult testingRunResult = Utils.generateFailedRunResultForMessage(null, infoKey, testConfig.getInfo().getCategory().getName(), testConfig.getInfo().getSubCategory(), null,samples , null);
if(testingRunResult == null){
testingRunResult = executor.runTestNew(infoKey, null, testingUtil, null, testConfig, testingRunConfig, true, testLogs, samples.get(samples.size() - 1));
}
if (testingRunResult == null) {
testingRunResult = new TestingRunResult(
new ObjectId(), infoKey, testConfig.getInfo().getCategory().getName(), testConfig.getInfo().getSubCategory() ,Collections.singletonList(new TestResult(null, sampleDataList.get(0).getSamples().get(lastSampleIndex),
Expand All @@ -355,6 +361,7 @@ public String runTestForGivenTemplate() {
subCategoryMap.put(testConfig.getId(), infoObj);

List<GenericTestResult> runResults = new ArrayList<>();
this.testingRunResult = testingRunResult;

for (GenericTestResult testResult: this.testingRunResult.getTestResults()) {
if (testResult instanceof TestResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export default function Header() {
{(Object.keys(currentTestsObj).length > 0 && currentTestsObj?.testRunsArr?.length !== 0 && currentTestsObj?.totalTestsCompleted > 0) ?
<HorizontalStack gap={"2"}>
<Button plain monochrome onClick={() => {handleTestingNavigate()}}>
<SemiCircleProgress key={"progress"} progress={progress} size={60} height={55} width={75}/>
<SemiCircleProgress key={"progress"} progress={Math.min(progress, 100)} size={60} height={55} width={75}/>
</Button>
<VerticalStack gap={"0"}>
<Text fontWeight="medium">Test run status</Text>
Expand Down
10 changes: 7 additions & 3 deletions apps/testing-cli/src/main/java/com/akto/testing_cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.slf4j.LoggerFactory;

import com.akto.DaoInit;
import com.akto.dao.context.Context;
import com.akto.dao.test_editor.TestConfigYamlParser;
import com.akto.dao.test_editor.TestEditorEnums.ContextOperator;
import com.akto.dto.AccountSettings;
Expand All @@ -40,6 +41,7 @@
import com.akto.store.TestingUtil;
import com.akto.testing.ApiExecutor;
import com.akto.testing.TestExecutor;
import com.akto.testing.Utils;
import com.akto.util.ColorConstants;
import com.akto.util.VersionUtil;

Expand Down Expand Up @@ -317,11 +319,13 @@ public static void main(String[] args) {
for (String testSubCategory : testingRunConfig.getTestSubCategoryList()) {
TestConfig testConfig = testConfigMap.get(testSubCategory);
for (ApiInfo.ApiInfoKey it : apiInfoKeys) {

TestingRunResult testingRunResult = null;
try {
testingRunResult = testExecutor.runTestNew(it, null, testingUtil, null, testConfig,
testingRunConfig, false, new ArrayList<>());
List<String> samples = testingUtil.getSampleMessages().get(it);
testingRunResult = Utils.generateFailedRunResultForMessage(null, it, testConfig.getInfo().getCategory().getName(), testConfig.getInfo().getSubCategory(), null,samples , null);
if(testingRunResult == null){
testingRunResult = testExecutor.runTestNew(it, null, testingUtil, null, testConfig, null, false, new ArrayList<>(), samples.get(samples.size() - 1));
}
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Loading
Loading