use of com.hortonworks.streamline.streams.actions.TopologyActions in project streamline by hortonworks.
the class TopologyActionsService method testRunTopology.
public TopologyTestRunHistory testRunTopology(Topology topology, TopologyTestRunCase testCase, Long durationSecs) throws Exception {
TopologyDag dag = topologyDagBuilder.getDag(topology);
topology.setTopologyDag(dag);
ensureValid(dag);
TopologyActions topologyActions = getTopologyActionsInstance(topology);
LOG.debug("Running topology {} in test mode", topology);
return topologyTestRunner.runTest(topologyActions, topology, testCase, durationSecs);
}
use of com.hortonworks.streamline.streams.actions.TopologyActions in project streamline by hortonworks.
the class TopologyStates method invokeKill.
private static void invokeKill(TopologyContext context) throws Exception {
Topology topology = context.getTopology();
TopologyActions topologyActions = context.getTopologyActions();
topologyActions.kill(CatalogToLayoutConverter.getTopologyLayout(topology), context.getAsUser());
LOG.debug("Killed topology '{}'", topology.getName());
}
use of com.hortonworks.streamline.streams.actions.TopologyActions in project streamline by hortonworks.
the class TopologyTestRunnerTest method runTest_withTestCaseId.
@Test
public void runTest_withTestCaseId() 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();
setSucceedTopologyActionsExpectations();
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);
waitForTopologyTestRunToFinish(resultHistory);
assertNotNull(resultHistory);
assertTrue(resultHistory.getFinished());
assertTrue(resultHistory.getSuccess());
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());
assertTrue(runHistory.getSuccess());
assertNotNull(runHistory.getStartTime());
assertNotNull(runHistory.getFinishTime());
assertTrue(runHistory.getFinishTime() - runHistory.getStartTime() >= 0);
assertTrue(isEmptyJson(runHistory.getExpectedOutputRecords()));
assertTrue(isNotEmptyJson(runHistory.getActualOutputRecords()));
assertFalse(runHistory.getMatched());
}
};
}
use of com.hortonworks.streamline.streams.actions.TopologyActions 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());
}
};
}
use of com.hortonworks.streamline.streams.actions.TopologyActions in project streamline by hortonworks.
the class TopologyActionsService method getTopologyActionsInstance.
public TopologyActions getTopologyActionsInstance(Topology ds) {
Namespace namespace = environmentService.getNamespace(ds.getNamespaceId());
if (namespace == null) {
throw new RuntimeException("Corresponding namespace not found: " + ds.getNamespaceId());
}
TopologyActions topologyActions = topologyActionsContainer.findInstance(namespace);
if (topologyActions == null) {
throw new RuntimeException("Can't find Topology Actions for such namespace " + ds.getNamespaceId());
}
return topologyActions;
}
Aggregations