use of com.hortonworks.streamline.streams.layout.component.StreamlineSource in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitor method copyEdges.
private void copyEdges(InputComponent inputComponent) {
List<Edge> edgesTo = originTopologyDag.getEdgesTo(inputComponent);
edgesTo.forEach(e -> {
OutputComponent from = e.getFrom();
InputComponent to = e.getTo();
Edge newEdge = new Edge(e.getId(), e.getFrom(), e.getTo(), e.getStreamGroupings());
StreamlineSource replacedSource = sourceToReplacedTestSourceMap.get(from.getName());
StreamlineProcessor replacedProcessorSource = processorToReplacedTestProcessorMap.get(from.getName());
StreamlineSink replacedSink = sinkToReplacedTestSinkMap.get(to.getName());
StreamlineProcessor replacedProcessorSink = processorToReplacedTestProcessorMap.get(to.getName());
if (replacedSource != null) {
newEdge.setFrom(replacedSource);
} else if (replacedProcessorSource != null) {
newEdge.setFrom(replacedProcessorSource);
}
if (replacedSink != null) {
newEdge.setTo(replacedSink);
} else if (replacedProcessorSink != null) {
newEdge.setTo(replacedProcessorSink);
}
testTopologyDag.addEdge(newEdge);
});
}
use of com.hortonworks.streamline.streams.layout.component.StreamlineSource in project streamline by hortonworks.
the class TopologyTestRunnerTest method injectTestTopology.
private void injectTestTopology(Topology topology) {
StreamlineSource originSource = TopologyTestHelper.createStreamlineSource("1");
StreamlineProcessor originProcessor = TopologyTestHelper.createStreamlineProcessor("2");
StreamlineSink originSink = TopologyTestHelper.createStreamlineSink("3");
TopologyDag topologyDag = new TopologyDag();
topologyDag.add(originSource);
topologyDag.add(originProcessor);
topologyDag.add(originSink);
topologyDag.addEdge(new Edge("e1", originSource, originProcessor, "default", Stream.Grouping.SHUFFLE));
topologyDag.addEdge(new Edge("e2", originProcessor, originSink, "default", Stream.Grouping.SHUFFLE));
topology.setTopologyDag(topologyDag);
}
use of com.hortonworks.streamline.streams.layout.component.StreamlineSource 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.layout.component.StreamlineSource in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method visitSource.
@Test
public void visitSource() throws Exception {
StreamlineSource originSource = TopologyTestHelper.createStreamlineSource("1");
TopologyDag originTopologyDag = new TopologyDag();
originTopologyDag.add(originSource);
TestRunSource testSource = createTestRunSource(originSource);
TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.singletonMap(originSource.getName(), testSource), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap());
visitor.visit(originSource);
TopologyDag testTopologyDag = visitor.getTestTopologyDag();
List<OutputComponent> testSources = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunSource && o.getName().equals(originSource.getName()))).collect(toList());
assertEquals(1, testSources.size());
TestRunSource testRunSource = (TestRunSource) testSources.get(0);
assertEquals(originSource.getId(), testRunSource.getId());
assertEquals(testSource.getTestRecordsForEachStream(), testRunSource.getTestRecordsForEachStream());
}
use of com.hortonworks.streamline.streams.layout.component.StreamlineSource in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method visitRulesProcessor_connectedFromSource.
@Test
public void visitRulesProcessor_connectedFromSource() throws Exception {
StreamlineSource originSource = TopologyTestHelper.createStreamlineSource("1");
RulesProcessor rulesProcessor = TopologyTestHelper.createRulesProcessor("2");
TopologyDag originTopologyDag = new TopologyDag();
originTopologyDag.add(originSource);
originTopologyDag.add(rulesProcessor);
originTopologyDag.addEdge(new Edge("e1", originSource, rulesProcessor, "default", Stream.Grouping.SHUFFLE));
TestRunSource testSource = createTestRunSource(originSource);
TestRunRulesProcessor testRulesProcessor = createTestRunRulesProcessor(rulesProcessor);
TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.singletonMap(originSource.getName(), testSource), Collections.emptyMap(), Collections.singletonMap(rulesProcessor.getName(), testRulesProcessor), Collections.emptyMap());
visitor.visit(originSource);
visitor.visit(rulesProcessor);
TopologyDag testTopologyDag = visitor.getTestTopologyDag();
List<OutputComponent> testRulesProcessors = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunRulesProcessor && o.getName().equals(rulesProcessor.getName()))).collect(toList());
List<OutputComponent> testSources = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunSource && o.getName().equals(originSource.getName()))).collect(toList());
TestRunRulesProcessor testRunRulesProcessor = (TestRunRulesProcessor) testRulesProcessors.get(0);
TestRunSource testRunSource = (TestRunSource) testSources.get(0);
assertEquals(1, testTopologyDag.getEdgesFrom(testRunSource).size());
assertEquals(1, testTopologyDag.getEdgesTo(testRunRulesProcessor).size());
assertTrue(testTopologyDag.getEdgesFrom(testRunSource).get(0) == testTopologyDag.getEdgesTo(testRunRulesProcessor).get(0));
}
Aggregations