use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class StreamCatalogServiceTest method createTopology.
private Topology createTopology(long id) {
Topology topology = new Topology();
topology.setId(id);
topology.setName("name" + id);
topology.setVersionId(id);
// not set timestamp
return topology;
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class StreamCatalogService method cloneTopologyVersion.
/**
* Clones the given version of the topology and all its dependencies to a new 'CURRENT' version.
* The ids of the topology and its dependencies are retained.
*/
public Topology cloneTopologyVersion(Long topologyId, Long versionId) {
Topology topology = getTopology(topologyId, versionId);
if (topology != null) {
try {
topology = addTopology(new Topology(topology));
copyTopologyDependencies(topologyId, versionId, topology.getVersionId());
} catch (Exception ex) {
LOG.error("Got exception while copying topology dependencies", ex);
removeTopology(topology.getId(), topology.getVersionId(), true);
throw new RuntimeException(ex);
}
}
return topology;
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyTestRunnerTest method setSucceedTopologyActionsExpectations.
private void setSucceedTopologyActionsExpectations() throws Exception {
new Expectations() {
{
topologyActions.runTest(withInstanceOf(TopologyLayout.class), withInstanceOf(TopologyTestRunHistory.class), anyString, withInstanceOf(Map.class), withInstanceOf(Map.class), withInstanceOf(Map.class), withInstanceOf(Map.class), withInstanceOf(Optional.class));
result = new Delegate<Object>() {
Object delegate(TopologyLayout topology, TopologyTestRunHistory testRunHistory, String mavenArtifacts, Map<String, TestRunSource> testRunSourcesForEachSource, Map<String, TestRunProcessor> testRunProcessorsForEachProcessor, Map<String, TestRunRulesProcessor> testRunRulesProcessorsForEachProcessor, Map<String, TestRunSink> testRunSinksForEachSink, Optional<Long> durationSecs) throws Exception {
Map<String, List<Map<String, Object>>> testOutputRecords = TopologyTestHelper.createTestOutputRecords(testRunSinksForEachSink.keySet());
testRunSinksForEachSink.entrySet().forEach(entry -> {
String sinkName = entry.getKey();
TestRunSink sink = entry.getValue();
try (FileWriter fw = new FileWriter(sink.getOutputFilePath())) {
List<Map<String, Object>> outputRecords = testOutputRecords.get(sinkName);
for (Map<String, Object> record : outputRecords) {
fw.write(objectMapper.writeValueAsString(record) + "\n");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
});
return null;
}
};
}
};
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyTestRunnerTest method createSimpleDAGInjectedTestTopology.
private Topology createSimpleDAGInjectedTestTopology() {
Long topologyId = 1L;
Long topologyVersionId = 1L;
Long namespaceId = 1L;
Topology topology = TopologyTestHelper.createTopology(topologyId, topologyVersionId, namespaceId);
injectTestTopology(topology);
return topology;
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyTestRunnerTest method runTest_topologyActionsTestRunFails.
@Test
public void runTest_topologyActionsTestRunFails() throws Exception {
Topology topology = createSimpleDAGInjectedTestTopology();
Long topologyId = topology.getId();
Long testCaseId = 1L;
TopologyTestRunCase testCase = new TopologyTestRunCase();
testCase.setId(testCaseId);
testCase.setTopologyId(topology.getId());
testCase.setName("testcase1");
testCase.setTimestamp(System.currentTimeMillis());
setTopologyCurrentVersionExpectation(topology);
setTopologyTestRunCaseExpectations(topology, testCase);
setTopologyTestRunCaseSinkNotFoundExpectations(topology, testCase);
setTopologyTestRunHistoryExpectations();
setTopologyActionsThrowingExceptionExpectations();
long sourceCount = topology.getTopologyDag().getOutputComponents().stream().filter(c -> c instanceof StreamlineSource).count();
long sinkCount = topology.getTopologyDag().getInputComponents().stream().filter(c -> c instanceof StreamlineSink).count();
TopologyTestRunHistory resultHistory = topologyTestRunner.runTest(topologyActions, topology, testCase, null);
assertNotNull(resultHistory);
waitForTopologyTestRunToFinish(resultHistory);
new VerificationsInOrder() {
{
catalogService.getTopologyTestRunCaseSourceBySourceId(testCaseId, anyLong);
times = (int) sourceCount;
catalogService.getTopologyTestRunCaseSinkBySinkId(testCaseId, anyLong);
times = (int) sinkCount;
TopologyTestRunHistory runHistory;
// some fields are already modified after calling the method, so don't need to capture it
catalogService.addTopologyTestRunHistory(withInstanceOf(TopologyTestRunHistory.class));
times = 1;
catalogService.addOrUpdateTopologyTestRunHistory(anyLong, runHistory = withCapture());
times = 1;
assertEquals(topology.getId(), runHistory.getTopologyId());
assertEquals(topology.getVersionId(), runHistory.getVersionId());
assertTrue(runHistory.getFinished());
assertFalse(runHistory.getSuccess());
assertNotNull(runHistory.getStartTime());
assertNotNull(runHistory.getFinishTime());
assertTrue(runHistory.getFinishTime() - runHistory.getStartTime() >= 0);
assertTrue(isEmptyJson(runHistory.getExpectedOutputRecords()));
assertNull(runHistory.getActualOutputRecords());
assertFalse(runHistory.getMatched());
}
};
}
Aggregations