use of com.hp.octane.integrations.services.SupportsConsoleLog in project octane-ci-java-sdk by MicroFocus.
the class TestExecutionServiceImpl method prepareTestExecutionForSuites.
@Override
public List<TestExecutionContext> prepareTestExecutionForSuites(Long workspaceId, List<Long> suiteIds, final SupportsConsoleLog supportsConsoleLog) {
SupportsConsoleLog mySupportsConsoleLog = getSupportConsoleLogOrCreateEmpty(supportsConsoleLog);
List<TestExecutionContext> output = new ArrayList<>();
mySupportsConsoleLog.println("Fetching test data for suite ids " + suiteIds + " from " + configurer.octaneConfiguration.getLocationForLog() + ":" + workspaceId);
suiteIds.forEach(suiteId -> {
List<Entity> suiteLinks = getSuiteLinks(workspaceId, suiteId, mySupportsConsoleLog);
List<Entity> suiteLinksWithTestRunner = suiteLinks.stream().filter(e -> e.containsFieldAndValue(EntityConstants.TestSuiteLinkToTest.TEST_RUNNER_FIELD)).collect(Collectors.toList());
int noRunnerCount = (suiteLinks.size() - suiteLinksWithTestRunner.size());
if (noRunnerCount > 0) {
String noRunnerMsg = String.format("Suite %s: found %s test(s) without test runner, such tests will be skipped", suiteId, noRunnerCount);
mySupportsConsoleLog.println(noRunnerMsg);
}
mySupportsConsoleLog.println(String.format("suite %s: found %s test(s) eligible for execution", suiteId, suiteLinks.size()));
Map<String, List<Entity>> testRunnerId2links = suiteLinksWithTestRunner.stream().collect(Collectors.groupingBy(e -> ((Entity) e.getField(EntityConstants.TestSuiteLinkToTest.TEST_RUNNER_FIELD)).getId()));
// test runners
Map<String, Entity> id2testRunners = getTestRunners(workspaceId, testRunnerId2links.keySet()).stream().collect(Collectors.toMap(Entity::getId, Function.identity()));
List<Entity> testRunnersFromAnotherCiServer = id2testRunners.values().stream().filter(e -> !this.configurer.octaneConfiguration.getInstanceId().equals(e.getEntityValue("ci_server").getStringValue(EntityConstants.CIServer.INSTANCE_ID_FIELD))).collect(Collectors.toList());
if (!testRunnersFromAnotherCiServer.isEmpty()) {
// if there are test runners from another ci server, need to remove such tests from execution
String runnerNames = testRunnersFromAnotherCiServer.stream().map(Entity::getName).collect(Collectors.joining(","));
mySupportsConsoleLog.println(String.format("Suite %s: found tests with test runner(s) belong to another ci server, such tests will be skipped. Test runners are : %s", suiteId, runnerNames));
// remove not relevant test runners
testRunnersFromAnotherCiServer.forEach(e -> testRunnerId2links.remove(e.getId()));
}
testRunnerId2links.keySet().forEach(testRunnerId -> {
try {
List<Entity> links = testRunnerId2links.get(testRunnerId);
String testsToRunJson = convertLinksToJson(links);
output.add(new TestExecutionContext(id2testRunners.get(testRunnerId), testsToRunJson, links, TestExecutionIdentifierType.SUITE, Long.toString(suiteId)));
} catch (Exception e) {
throw new RuntimeException("Failed to build testsToRun for test runner " + testRunnerId + " : " + e.getMessage());
}
});
});
return output;
}
use of com.hp.octane.integrations.services.SupportsConsoleLog in project octane-ci-java-sdk by MicroFocus.
the class TestExecutionServiceImpl method executeSuiteRuns.
@Override
public void executeSuiteRuns(Long workspaceId, List<Long> suiteIds, Long optionalReleaseId, String optionalSuiteRunName, SupportsConsoleLog supportsConsoleLog) throws IOException {
SupportsConsoleLog mySupportsConsoleLog = getSupportConsoleLogOrCreateEmpty(supportsConsoleLog);
mySupportsConsoleLog.println("Executing suite ids " + suiteIds + " in " + configurer.octaneConfiguration.getLocationForLog() + ", workspace " + workspaceId);
for (Long suiteId : suiteIds) {
this.validateSuiteRun(workspaceId, suiteId);
}
Entity release = getReleaseOrThrow(workspaceId, optionalReleaseId);
mySupportsConsoleLog.println("Using release - " + release.getId());
List<Entity> suiteRuns = this.planSuiteRuns(workspaceId, suiteIds, release, optionalSuiteRunName);
for (Entity suiteRun : suiteRuns) {
String suiteId = suiteRun.getEntityValue(EntityConstants.Run.TEST_FIELD).getId();
String url = this.configurer.octaneConfiguration.getUrl() + String.format("/ui/?p=%s/%s#/entity-navigation?entityType=run&id=%s", this.configurer.octaneConfiguration.getSharedSpace(), workspaceId, suiteRun.getId());
mySupportsConsoleLog.println(String.format("Suite %s - suite run id is %s , %s", suiteId, suiteRun.getId(), url));
this.runSuiteRun(workspaceId, Long.parseLong(suiteRun.getId()));
}
mySupportsConsoleLog.println("Suite runs are started ");
}
Aggregations