Search in sources :

Example 6 with TopologyLayout

use of com.hortonworks.streamline.streams.layout.component.TopologyLayout in project streamline by hortonworks.

the class StormTopologyTimeSeriesMetricsImplTest method testGetSinkComponentStatsWithoutAssigningTimeSeriesQuerier.

@Test
public void testGetSinkComponentStatsWithoutAssigningTimeSeriesQuerier() throws Exception {
    stormTopologyTimeSeriesMetrics.setTimeSeriesQuerier(null);
    final TopologyLayout topology = getTopologyLayoutForTest();
    final long from = 1L;
    final long to = 3L;
    final Map<String, Map<Long, Double>> expectedMisc = new HashMap<>();
    expectedMisc.put(StormMappedMetric.ackedRecords.name(), Collections.emptyMap());
    expectedMisc.put(StormMappedMetric.executeTime.name(), Collections.emptyMap());
    TopologyTimeSeriesMetrics.TimeSeriesComponentMetric actual = stormTopologyTimeSeriesMetrics.getComponentStats(topology, sink, from, to, null);
    assertEquals(Collections.emptyMap(), actual.getInputRecords());
    assertEquals(Collections.emptyMap(), actual.getOutputRecords());
    assertEquals(Collections.emptyMap(), actual.getFailedRecords());
    assertEquals(Collections.emptyMap(), actual.getRecordsInWaitQueue());
    assertEquals(Collections.emptyMap(), actual.getProcessedTime());
    assertEquals(expectedMisc, actual.getMisc());
}
Also used : TopologyLayout(com.hortonworks.streamline.streams.layout.component.TopologyLayout) HashMap(java.util.HashMap) TopologyTimeSeriesMetrics(com.hortonworks.streamline.streams.metrics.topology.TopologyTimeSeriesMetrics) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 7 with TopologyLayout

use of com.hortonworks.streamline.streams.layout.component.TopologyLayout in project streamline by hortonworks.

the class StormTopologyActionsImpl method runTest.

@Override
public void runTest(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 {
    TopologyDag originalTopologyDag = topology.getTopologyDag();
    TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originalTopologyDag, testRunSourcesForEachSource, testRunProcessorsForEachProcessor, testRunRulesProcessorsForEachProcessor, testRunSinksForEachSink);
    originalTopologyDag.traverse(visitor);
    TopologyDag testTopologyDag = visitor.getTestTopologyDag();
    TopologyLayout testTopology = copyTopologyLayout(topology, testTopologyDag);
    Path jarToDeploy = addArtifactsToJar(getArtifactsLocation(testTopology));
    String fileName = createYamlFileForTest(testTopology);
    List<String> commands = new ArrayList<String>();
    commands.add(stormCliPath);
    commands.add("jar");
    commands.add(jarToDeploy.toString());
    commands.addAll(getExtraJarsArg(testTopology));
    commands.addAll(getMavenArtifactsRelatedArgs(mavenArtifacts));
    commands.addAll(getNimbusConf());
    commands.addAll(getForceNonSecuredClusterConf());
    commands.addAll(getTempWorkerArtifactArgs());
    commands.add("org.apache.storm.flux.Flux");
    commands.add("--local");
    commands.add("-s");
    if (durationSecs.isPresent()) {
        commands.add(String.valueOf(durationSecs.get() * 1000));
    } else {
        commands.add(String.valueOf(TEST_RUN_TOPOLOGY_DEFAULT_WAIT_MILLIS_FOR_SHUTDOWN));
    }
    commands.add(fileName);
    Process process = executeShellProcess(commands);
    ShellProcessResult shellProcessResult = waitTestRunProcess(process, testRunHistory.getId());
    int exitValue = shellProcessResult.exitValue;
    if (exitValue != 0) {
        LOG.error("Topology deploy command as test mode failed - exit code: {} / output: {}", exitValue, shellProcessResult.stdout);
        throw new Exception("Topology could not be run " + "successfully as test mode: storm deploy command failed");
    }
}
Also used : Path(java.nio.file.Path) TopologyLayout(com.hortonworks.streamline.streams.layout.component.TopologyLayout) ArrayList(java.util.ArrayList) TopologyNotAliveException(com.hortonworks.streamline.streams.exception.TopologyNotAliveException) IOException(java.io.IOException) TopologyDag(com.hortonworks.streamline.streams.layout.component.TopologyDag)

Example 8 with TopologyLayout

use of com.hortonworks.streamline.streams.layout.component.TopologyLayout in project streamline by hortonworks.

the class StormTopologyTimeSeriesMetricsImplTest method getSinkComponentStats.

@Test
public void getSinkComponentStats() throws Exception {
    final TopologyLayout topology = getTopologyLayoutForTest();
    final long from = 1L;
    final long to = 3L;
    final TopologyTimeSeriesMetrics.TimeSeriesComponentMetric expectedMetric = setupExpectionToBoltComponent(sink, from, to);
    TopologyTimeSeriesMetrics.TimeSeriesComponentMetric actual = stormTopologyTimeSeriesMetrics.getComponentStats(topology, sink, from, to, null);
    assertEquals(expectedMetric, actual);
}
Also used : TopologyLayout(com.hortonworks.streamline.streams.layout.component.TopologyLayout) TopologyTimeSeriesMetrics(com.hortonworks.streamline.streams.metrics.topology.TopologyTimeSeriesMetrics) Test(org.junit.Test)

Example 9 with TopologyLayout

use of com.hortonworks.streamline.streams.layout.component.TopologyLayout in project streamline by hortonworks.

the class StormTopologyTimeSeriesMetricsImplTest method testGetSourceComponentStatsWithoutAssigningTimeSeriesQuerier.

@Test
public void testGetSourceComponentStatsWithoutAssigningTimeSeriesQuerier() throws Exception {
    stormTopologyTimeSeriesMetrics.setTimeSeriesQuerier(null);
    final TopologyLayout topology = getTopologyLayoutForTest();
    final long from = 1L;
    final long to = 3L;
    final Map<String, Map<Long, Double>> expectedMisc = new HashMap<>();
    expectedMisc.put(StormMappedMetric.ackedRecords.name(), Collections.emptyMap());
    expectedMisc.put(StormMappedMetric.completeLatency.name(), Collections.emptyMap());
    TopologyTimeSeriesMetrics.TimeSeriesComponentMetric actual = stormTopologyTimeSeriesMetrics.getComponentStats(topology, source, from, to, null);
    assertEquals(Collections.emptyMap(), actual.getInputRecords());
    assertEquals(Collections.emptyMap(), actual.getOutputRecords());
    assertEquals(Collections.emptyMap(), actual.getFailedRecords());
    assertEquals(Collections.emptyMap(), actual.getRecordsInWaitQueue());
    assertEquals(Collections.emptyMap(), actual.getProcessedTime());
    assertEquals(expectedMisc, actual.getMisc());
}
Also used : TopologyLayout(com.hortonworks.streamline.streams.layout.component.TopologyLayout) HashMap(java.util.HashMap) TopologyTimeSeriesMetrics(com.hortonworks.streamline.streams.metrics.topology.TopologyTimeSeriesMetrics) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 10 with TopologyLayout

use of com.hortonworks.streamline.streams.layout.component.TopologyLayout 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;
                }
            };
        }
    };
}
Also used : Expectations(mockit.Expectations) Topology(com.hortonworks.streamline.streams.catalog.Topology) BeforeClass(org.junit.BeforeClass) Expectations(mockit.Expectations) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) TopologyLayout(com.hortonworks.streamline.streams.layout.component.TopologyLayout) TopologyActions(com.hortonworks.streamline.streams.actions.TopologyActions) Edge(com.hortonworks.streamline.streams.layout.component.Edge) TopologyDag(com.hortonworks.streamline.streams.layout.component.TopologyDag) VerificationsInOrder(mockit.VerificationsInOrder) Collectors.toMap(java.util.stream.Collectors.toMap) Files(com.google.common.io.Files) TestRunSource(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource) Map(java.util.Map) JMockit(mockit.integration.junit4.JMockit) StreamlineSource(com.hortonworks.streamline.streams.layout.component.StreamlineSource) Before(org.junit.Before) Stream(com.hortonworks.streamline.streams.layout.component.Stream) TestRunProcessor(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor) Assert.assertNotNull(org.junit.Assert.assertNotNull) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FileWriter(java.io.FileWriter) Assert.assertTrue(org.junit.Assert.assertTrue) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.Test) IOException(java.io.IOException) Delegate(mockit.Delegate) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) File(java.io.File) TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) TestRunSink(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSink) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) TopologyTestHelper(com.hortonworks.streamline.streams.actions.utils.TopologyTestHelper) Assert.assertFalse(org.junit.Assert.assertFalse) StreamCatalogService(com.hortonworks.streamline.streams.catalog.service.StreamCatalogService) TestRunRulesProcessor(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunRulesProcessor) Optional(java.util.Optional) StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) Injectable(mockit.Injectable) StreamlineSink(com.hortonworks.streamline.streams.layout.component.StreamlineSink) TopologyTestRunCaseSink(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) TestRunProcessor(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor) Optional(java.util.Optional) TestRunRulesProcessor(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunRulesProcessor) FileWriter(java.io.FileWriter) TestRunSink(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSink) IOException(java.io.IOException) TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) TopologyLayout(com.hortonworks.streamline.streams.layout.component.TopologyLayout) List(java.util.List) TestRunSource(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource) HashMap(java.util.HashMap) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map)

Aggregations

TopologyLayout (com.hortonworks.streamline.streams.layout.component.TopologyLayout)10 Test (org.junit.Test)7 TopologyTimeSeriesMetrics (com.hortonworks.streamline.streams.metrics.topology.TopologyTimeSeriesMetrics)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 TopologyDag (com.hortonworks.streamline.streams.layout.component.TopologyDag)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 TopologyActions (com.hortonworks.streamline.streams.actions.TopologyActions)2 TopologyTestRunHistory (com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory)2 TopologyNotAliveException (com.hortonworks.streamline.streams.exception.TopologyNotAliveException)2 TestRunProcessor (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor)2 TestRunRulesProcessor (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunRulesProcessor)2 TestRunSink (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSink)2 TestRunSource (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource)2 File (java.io.File)2 IOException (java.io.IOException)2 Collectors.toList (java.util.stream.Collectors.toList)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1