Search in sources :

Example 91 with Topology

use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.

the class JobConfigOverlaysFileTest method testWithIsolate.

@Test
public void testWithIsolate() throws Exception {
    // Just a simple graph, which won't be executed.
    Topology topology = newTopology("testNoConfig");
    topology.constants(Collections.emptyList()).isolate().forEach(tuple -> {
    });
    sab = bundler().submit(topology).get();
    JsonObject jcos = assertSabGetJcos(topology);
    assertLegacyDeployment(jcos);
    JsonObject jco = jobConfigOverlay(jcos);
    assertMissing(jco, "jobConfig");
    assertMissing(jco, "operatorConfigs");
    assertMissing(jco, "configInstructions");
}
Also used : JsonObject(com.google.gson.JsonObject) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Test(org.junit.Test)

Example 92 with Topology

use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.

the class PythonFunctionalOperatorsKwargsTest method testFilterOptionalOutput.

@Test
public void testFilterOptionalOutput() throws Exception {
    assumeTrue(!isStreamingAnalyticsRun());
    Topology topology = new Topology("testFilterOptionalOutput");
    SPLStream tuples = sampleFilterStream(topology);
    PythonFunctionalOperatorsTest.addTestToolkit(tuples);
    List<SPLStream> filtered = SPL.invokeOperator(topology, "CFOpt", "com.ibm.streamsx.topology.pysamples.kwargs::ContainsFilter", Collections.singletonList(tuples), Collections.nCopies(2, tuples.getSchema()), Collections.singletonMap("term", "23"));
    SPLStream pass = filtered.get(0);
    SPLStream failed = filtered.get(1);
    Tester tester = topology.getTester();
    Condition<Long> expectedPassCount = tester.tupleCount(pass, 2);
    Condition<Long> expectedFailedCount = tester.tupleCount(failed, 2);
    Condition<List<Tuple>> passResult = tester.tupleContents(pass);
    Condition<List<Tuple>> failedResult = tester.tupleContents(failed);
    getConfig().put(ContextProperties.KEEP_ARTIFACTS, true);
    complete(tester, expectedPassCount.and(expectedFailedCount), 10, TimeUnit.SECONDS);
    assertEquals(TEST_TUPLES[1], passResult.getResult().get(0));
    assertEquals(TEST_TUPLES[3], passResult.getResult().get(1));
    assertEquals(TEST_TUPLES[0], failedResult.getResult().get(0));
    assertEquals(TEST_TUPLES[2], failedResult.getResult().get(1));
}
Also used : Tester(com.ibm.streamsx.topology.tester.Tester) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) Test(org.junit.Test)

Example 93 with Topology

use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.

the class PythonFunctionalOperatorsKwargsTest method testMap.

@Test
public void testMap() throws Exception {
    assumeTrue(!isStreamingAnalyticsRun());
    Topology topology = new Topology("testMap");
    SPLStream tuples = sampleFilterStream(topology);
    PythonFunctionalOperatorsTest.addTestToolkit(tuples);
    SPLStream mapped = SPL.invokeOperator("Mp", "com.ibm.streamsx.topology.pytest.pymap::OffByOne", tuples, tuples.getSchema(), null);
    Tester tester = topology.getTester();
    Condition<Long> expectedCount = tester.tupleCount(mapped, 3);
    Condition<List<Tuple>> result = tester.tupleContents(mapped, TEST_TUPLES[0], TEST_TUPLES[1], TEST_TUPLES[2]);
    getConfig().put(ContextProperties.KEEP_ARTIFACTS, true);
    complete(tester, expectedCount, 10, TimeUnit.SECONDS);
    assertTrue(result.getResult().toString(), result.valid());
}
Also used : Tester(com.ibm.streamsx.topology.tester.Tester) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) Test(org.junit.Test)

Example 94 with Topology

use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.

the class PythonFunctionalOperatorsKwargsTest method testFilter.

@Test
public void testFilter() throws Exception {
    assumeTrue(!isStreamingAnalyticsRun());
    Topology topology = new Topology("testFilter");
    SPLStream tuples = sampleFilterStream(topology);
    PythonFunctionalOperatorsTest.addTestToolkit(tuples);
    SPLStream pass = SPL.invokeOperator("com.ibm.streamsx.topology.pysamples.kwargs::ContainsFilter", tuples, tuples.getSchema(), Collections.singletonMap("term", "23"));
    Tester tester = topology.getTester();
    Condition<Long> expectedCount = tester.tupleCount(pass, 2);
    Condition<List<Tuple>> passResult = tester.tupleContents(pass);
    this.getConfig().put(ContextProperties.KEEP_ARTIFACTS, true);
    complete(tester, expectedCount, 10, TimeUnit.SECONDS);
    assertEquals(TEST_TUPLES[1], passResult.getResult().get(0));
    assertEquals(TEST_TUPLES[3], passResult.getResult().get(1));
    assertTrue(expectedCount.valid());
}
Also used : Tester(com.ibm.streamsx.topology.tester.Tester) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) Test(org.junit.Test)

Example 95 with Topology

use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.

the class BeaconTest method testLongFixedCount.

@Test
public void testLongFixedCount() throws Exception {
    Topology topology = newTopology("testLongFixedCount");
    final int count = 7;
    TStream<Long> fb = BeaconStreams.longBeacon(topology, count);
    TStream<String> fs = StringStreams.toString(fb);
    Tester tester = topology.getTester();
    Condition<Long> expectedCount = tester.tupleCount(fs, count);
    Condition<List<String>> expectedContents = tester.stringContents(fs, "0", "1", "2", "3", "4", "5", "6");
    complete(tester, expectedCount, 20, TimeUnit.SECONDS);
    assertTrue(expectedCount.valid());
    assertTrue(expectedContents.valid());
}
Also used : Tester(com.ibm.streamsx.topology.tester.Tester) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Test(org.junit.Test)

Aggregations

Topology (com.ibm.streamsx.topology.Topology)372 TestTopology (com.ibm.streamsx.topology.test.TestTopology)315 Test (org.junit.Test)301 List (java.util.List)116 Tester (com.ibm.streamsx.topology.tester.Tester)115 ArrayList (java.util.ArrayList)70 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)68 HashMap (java.util.HashMap)49 TStream (com.ibm.streamsx.topology.TStream)42 Condition (com.ibm.streamsx.topology.tester.Condition)28 File (java.io.File)27 TimeUnit (java.util.concurrent.TimeUnit)27 StreamSchema (com.ibm.streams.operator.StreamSchema)26 Random (java.util.Random)26 JSONObject (com.ibm.json.java.JSONObject)23 HashSet (java.util.HashSet)23 RString (com.ibm.streams.operator.types.RString)21 StreamsContext (com.ibm.streamsx.topology.context.StreamsContext)21 Message (com.ibm.streamsx.topology.tuple.Message)20 SimpleMessage (com.ibm.streamsx.topology.tuple.SimpleMessage)20