@Override public boolean killTest(TopologyTestRunHistory testRunHistory) { // just turn on the flag only if it exists LOG.info("Turning on force kill flag on test run history {}", testRunHistory.getId()); Boolean newValue = forceKillRequests.computeIfPresent(testRunHistory.getId(), (id, flag) -> true); return newValue != null; }
private List<TopologyTestRunHistory> filterHistories(Integer limit, Collection<TopologyTestRunHistory> histories) { if (limit == null) { limit = DEFAULT_LIST_ENTITIES_COUNT; } return histories.stream() // reverse order .sorted((h1, h2) -> (int) (h2.getId() - h1.getId())) .limit(limit) .collect(toList()); }
public TopologyTestRunHistory addTopologyTestRunHistory(TopologyTestRunHistory history) { if (history.getId() == null) { history.setId(dao.nextId(TopologyTestRunHistory.NAMESPACE)); } history.setTimestamp(System.currentTimeMillis()); dao.add(history); return history; }
ShellProcessResult shellProcessResult = waitTestRunProcess(process, testRunHistory.getId()); int exitValue = shellProcessResult.exitValue; if (exitValue != 0) {
@Override public int hashCode() { int result = getId() != null ? getId().hashCode() : 0; result = 31 * result + (getTopologyId() != null ? getTopologyId().hashCode() : 0); result = 31 * result + (getVersionId() != null ? getVersionId().hashCode() : 0); result = 31 * result + (getTestCaseId() != null ? getTestCaseId().hashCode() : 0); result = 31 * result + (getFinished() != null ? getFinished().hashCode() : 0); result = 31 * result + (getSuccess() != null ? getSuccess().hashCode() : 0); result = 31 * result + (getExpectedOutputRecords() != null ? getExpectedOutputRecords().hashCode() : 0); result = 31 * result + (getActualOutputRecords() != null ? getActualOutputRecords().hashCode() : 0); result = 31 * result + (getMatched() != null ? getMatched().hashCode() : 0); result = 31 * result + (getEventLogFilePath() != null ? getEventLogFilePath().hashCode() : 0); result = 31 * result + (getStartTime() != null ? getStartTime().hashCode() : 0); result = 31 * result + (getFinishTime() != null ? getFinishTime().hashCode() : 0); result = 31 * result + (getTimestamp() != null ? getTimestamp().hashCode() : 0); return result; }
SimplifiedTopologyTestRunHistory(TopologyTestRunHistory history) { id = history.getId(); topologyId = history.getTopologyId(); versionId = history.getVersionId(); finished = history.getFinished(); success = history.getSuccess(); matched = history.getMatched(); startTime = history.getStartTime(); finishTime = history.getFinishTime(); timestamp = history.getTimestamp(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TopologyTestRunHistory)) return false; TopologyTestRunHistory that = (TopologyTestRunHistory) o; if (getId() != null ? !getId().equals(that.getId()) : that.getId() != null) return false; if (getTopologyId() != null ? !getTopologyId().equals(that.getTopologyId()) : that.getTopologyId() != null) return false; if (getVersionId() != null ? !getVersionId().equals(that.getVersionId()) : that.getVersionId() != null) return false; if (getTestCaseId() != null ? !getTestCaseId().equals(that.getTestCaseId()) : that.getTestCaseId() != null) return false; if (getFinished() != null ? !getFinished().equals(that.getFinished()) : that.getFinished() != null) return false; if (getSuccess() != null ? !getSuccess().equals(that.getSuccess()) : that.getSuccess() != null) return false; if (getExpectedOutputRecords() != null ? !getExpectedOutputRecords().equals(that.getExpectedOutputRecords()) : that.getExpectedOutputRecords() != null) return false; if (getActualOutputRecords() != null ? !getActualOutputRecords().equals(that.getActualOutputRecords()) : that.getActualOutputRecords() != null) return false; if (getMatched() != null ? !getMatched().equals(that.getMatched()) : that.getMatched() != null) return false; if (getEventLogFilePath() != null ? !getEventLogFilePath().equals(that.getEventLogFilePath()) : that.getEventLogFilePath() != null) return false; if (getStartTime() != null ? !getStartTime().equals(that.getStartTime()) : that.getStartTime() != null) return false; if (getFinishTime() != null ? !getFinishTime().equals(that.getFinishTime()) : that.getFinishTime() != null) return false; return getTimestamp() != null ? getTimestamp().equals(that.getTimestamp()) : that.getTimestamp() == null; }
private Void runTestInBackground(TopologyActions topologyActions, Topology topology, TopologyTestRunHistory history, Map<String, TestRunSource> testRunSourceMap, Map<String, TestRunProcessor> testRunProcessorMap, Map<String, TestRunRulesProcessor> testRunRulesProcessorMap, Map<String, TestRunSink> testRunSinkMap, Map<String, List<Map<String, Object>>> expectedOutputRecordsMap, Optional<Long> durationSecs) throws IOException { TopologyLayout topologyLayout = CatalogToLayoutConverter.getTopologyLayout(topology, topology.getTopologyDag()); try { topologyActionsService.setUpClusterArtifacts(topology, topologyActions); String mavenArtifacts = topologyActionsService.setUpExtraJars(topology, topologyActions); topologyActions.runTest(topologyLayout, history, mavenArtifacts, testRunSourceMap, testRunProcessorMap, testRunRulesProcessorMap, testRunSinkMap, durationSecs); history.finishSuccessfully(); Map<String, List<Map<String, Object>>> actualOutputRecordsMap = parseTestRunOutputFiles(testRunSinkMap); history.setActualOutputRecords(objectMapper.writeValueAsString(actualOutputRecordsMap)); if (expectedOutputRecordsMap != null) { boolean matched = equalsOutputRecords(expectedOutputRecordsMap, actualOutputRecordsMap); history.setMatched(matched); } } catch (Throwable e) { LOG.warn("Exception thrown while running Topology as test mode. Marking as 'failed'. topology id: {}", topology.getId(), e); history.finishWithFailures(); } catalogService.addOrUpdateTopologyTestRunHistory(history.getId(), history); return null; }
runHistories.forEach(history -> removeTopologyTestRunHistory(history.getId()));