MINOR - Async test case result deletion (#19390)

* fix: async test case result deletion

* move async call to calling method
This commit is contained in:
Teddy 2025-01-16 16:24:20 +01:00 committed by GitHub
parent 6f63a51024
commit d8e6219200
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.json.JsonPatch;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@ -78,6 +80,7 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
private static final String PATCH_FIELDS =
"owners,entityLink,testSuite,testSuites,testDefinition,computePassedFailedRowCount,useDynamicAssertion";
public static final String FAILED_ROWS_SAMPLE_EXTENSION = "testCase.failedRowsSample";
private final ExecutorService asyncExecutor = Executors.newFixedThreadPool(1);
public TestCaseRepository() {
super(
@ -382,10 +385,17 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
}
private void deleteAllTestCaseResults(String fqn) {
// Delete all the test case results
TestCaseResultRepository testCaseResultRepository =
(TestCaseResultRepository) Entity.getEntityTimeSeriesRepository(TEST_CASE_RESULT);
testCaseResultRepository.deleteAllTestCaseResults(fqn);
asyncExecutor.submit(
() -> {
try {
testCaseResultRepository.deleteAllTestCaseResults(fqn);
} catch (Exception e) {
LOG.error("Error deleting test case results for test case {}", fqn, e);
}
});
}
@SneakyThrows