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

Feature/clean up resources #1882

Merged
merged 8 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public class StartTestAction extends UserAction {
private Map<String,Integer> issuesSummaryInfoMap = new HashMap<>();

private String testRoleId;
private boolean cleanUpTestingResources;

private static final Gson gson = new Gson();

private static List<ObjectId> getTestingRunListFromSummary(Bson filters){
Expand Down Expand Up @@ -147,7 +149,7 @@ private TestingRun createTestingRun(int scheduleTimestamp, int periodInSeconds)
}
if (this.selectedTests != null) {
int id = UUID.randomUUID().hashCode() & 0xfffffff;
TestingRunConfig testingRunConfig = new TestingRunConfig(id, null, this.selectedTests, authMechanism.getId(), this.overriddenTestAppUrl, this.testRoleId);
TestingRunConfig testingRunConfig = new TestingRunConfig(id, null, this.selectedTests, authMechanism.getId(), this.overriddenTestAppUrl, this.testRoleId, this.cleanUpTestingResources);
// add advanced setting here
if(this.testConfigsAdvancedSettings != null && !this.testConfigsAdvancedSettings.isEmpty()){
testingRunConfig.setConfigsAdvancedSettings(this.testConfigsAdvancedSettings);
Expand Down Expand Up @@ -1401,4 +1403,12 @@ public Map<String, Integer> getTestCountMap() {
public void setReportFilterList(Map<String, List<String>> reportFilterList) {
this.reportFilterList = reportFilterList;
}

public boolean getCleanUpTestingResources() {
return cleanUpTestingResources;
}

public void setCleanUpTestingResources(boolean cleanUpTestingResources) {
this.cleanUpTestingResources = cleanUpTestingResources;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -573,20 +573,20 @@ export default {
data: {}
})
},
scheduleTestForCollection(apiCollectionId, startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, testRoleId, continuousTesting, sendSlackAlert, testConfigsAdvancedSettings) {
scheduleTestForCollection(apiCollectionId, startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, testRoleId, continuousTesting, sendSlackAlert, testConfigsAdvancedSettings, cleanUpTestingResources) {
return request({
url: '/api/startTest',
method: 'post',
data: { apiCollectionId, type: "COLLECTION_WISE", startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, testRoleId, continuousTesting, sendSlackAlert, testConfigsAdvancedSettings}
data: { apiCollectionId, type: "COLLECTION_WISE", startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, testRoleId, continuousTesting, sendSlackAlert, testConfigsAdvancedSettings, cleanUpTestingResources}
}).then((resp) => {
return resp
})
},
scheduleTestForCustomEndpoints(apiInfoKeyList, startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, source, testRoleId, continuousTesting, sendSlackAlert, testConfigsAdvancedSettings) {
scheduleTestForCustomEndpoints(apiInfoKeyList, startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, source, testRoleId, continuousTesting, sendSlackAlert, testConfigsAdvancedSettings, cleanUpTestingResources) {
return request({
url: '/api/startTest',
method: 'post',
data: {apiInfoKeyList, type: "CUSTOM", startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, source, testRoleId, continuousTesting, sendSlackAlert, testConfigsAdvancedSettings}
data: {apiInfoKeyList, type: "CUSTOM", startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, source, testRoleId, continuousTesting, sendSlackAlert, testConfigsAdvancedSettings, cleanUpTestingResources}
}).then((resp) => {
return resp
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu
authMechanismPresent: false,
testRoleLabel: "No test role selected",
testRoleId: "",
sendSlackAlert: false
sendSlackAlert: false,
cleanUpTestingResources: false
}

const navigate = useNavigate()
Expand Down Expand Up @@ -413,7 +414,7 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu
}

async function handleRun() {
const { startTimestamp, recurringDaily, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, testRoleId, continuousTesting, sendSlackAlert } = testRun
const { startTimestamp, recurringDaily, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, testRoleId, continuousTesting, sendSlackAlert, cleanUpTestingResources } = testRun
const collectionId = parseInt(apiCollectionId)

const tests = testRun.tests
Expand Down Expand Up @@ -454,9 +455,9 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu
}

if (filtered || selectedResourcesForPrimaryAction.length > 0) {
await observeApi.scheduleTestForCustomEndpoints(apiInfoKeyList, startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, "TESTING_UI", testRoleId, continuousTesting, sendSlackAlert, finalAdvancedConditions)
await observeApi.scheduleTestForCustomEndpoints(apiInfoKeyList, startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, "TESTING_UI", testRoleId, continuousTesting, sendSlackAlert, finalAdvancedConditions, cleanUpTestingResources)
} else {
await observeApi.scheduleTestForCollection(collectionId, startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, testRoleId, continuousTesting, sendSlackAlert, finalAdvancedConditions)
await observeApi.scheduleTestForCollection(collectionId, startTimestamp, recurringDaily, selectedTests, testName, testRunTime, maxConcurrentRequests, overriddenTestAppUrl, testRoleId, continuousTesting, sendSlackAlert, finalAdvancedConditions, cleanUpTestingResources)
}

setActive(false)
Expand Down Expand Up @@ -767,6 +768,13 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu
}
</HorizontalGrid>

{window.ACTIVE_ACCOUNT === 1723492815 &&
<Checkbox
label={"Clean up resources after test run. This will try to delete all resources created during test run."}
checked={testRun.cleanUpTestingResources}
onChange={() => setTestRun(prev => ({ ...prev, cleanUpTestingResources: !prev.cleanUpTestingResources }))}
/>
}

</VerticalStack>
</VerticalStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ private static boolean removeCustomAuth(RawApi rawApi, List<CustomAuthType> cust
return removed;
}

private ExecutorSingleOperationResp modifyAuthTokenInRawApi(TestRoles testRole, RawApi rawApi) {
public static ExecutorSingleOperationResp modifyAuthTokenInRawApi(TestRoles testRole, RawApi rawApi) {
Map<String, List<String>> rawHeaders = rawApi.fetchReqHeaders();
for(AuthWithCond authWithCond: testRole.getAuthWithCondList()) {

Expand Down
Loading
Loading