Search in sources :

Example 6 with AllowAll

use of com.ibm.streamsx.topology.test.AllowAll in project streamsx.topology by IBMStreams.

the class ToolkitTest method testParallel.

@Test
public void testParallel() throws Exception {
    final Topology topology = newTopology("TKParallel");
    TStream<Number> s1 = topology.numbers(1, 2, 3, 94, 5, 6).parallel(6).filter(new AllowAll<Number>()).endParallel();
    @SuppressWarnings("unused") TStream<String> sp = StringStreams.toString(s1);
    @SuppressWarnings("unchecked") StreamsContext<File> tkContext = (StreamsContext<File>) StreamsContextFactory.getStreamsContext(Type.TOOLKIT);
    File tkRoot = tkContext.submit(topology).get();
    assertNotNull(tkRoot);
    assertTrue(tkRoot.exists());
}
Also used : AllowAll(com.ibm.streamsx.topology.test.AllowAll) StreamsContext(com.ibm.streamsx.topology.context.StreamsContext) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) File(java.io.File) Test(org.junit.Test)

Example 7 with AllowAll

use of com.ibm.streamsx.topology.test.AllowAll in project streamsx.topology by IBMStreams.

the class SPLStreamsTest method testMaintainSPLStream.

@Test
public void testMaintainSPLStream() {
    assumeTrue(isMainRun());
    Topology t = new Topology();
    SPLStream splStreamA = testTupleStream(t);
    assertSPLStream(splStreamA, TEST_SCHEMA);
    SPLStream splStreamB = splStreamA.filter(new AllowAll<Tuple>());
    assertSPLStream(splStreamB, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
    splStreamA = splStreamB.sample(1.0);
    assertSPLStream(splStreamA, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
    splStreamB = splStreamA.throttle(1, TimeUnit.MICROSECONDS);
    assertSPLStream(splStreamB, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
    splStreamA = splStreamB.lowLatency();
    assertSPLStream(splStreamA, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
    splStreamA = splStreamA.filter(new AllowAll<Tuple>());
    splStreamB = splStreamA.endLowLatency();
    assertSPLStream(splStreamB, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
    splStreamA = splStreamB.parallel(3);
    assertSPLStream(splStreamA, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
    splStreamA = splStreamA.filter(new AllowAll<Tuple>());
    splStreamB = splStreamA.endParallel();
    assertSPLStream(splStreamB, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
    splStreamB = splStreamB.filter(new AllowAll<Tuple>());
    splStreamA = splStreamB.parallel(of(2), Routing.ROUND_ROBIN);
    assertSPLStream(splStreamA, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
    splStreamA = splStreamA.filter(new AllowAll<Tuple>());
    splStreamB = splStreamA.endParallel();
    assertSPLStream(splStreamB, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
    splStreamB = splStreamB.filter(new AllowAll<Tuple>());
    splStreamA = splStreamB.isolate();
    assertSPLStream(splStreamA, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
    splStreamB = splStreamA.autonomous();
    assertSPLStream(splStreamB, TEST_SCHEMA);
    assertNotSame(splStreamA, splStreamB);
}
Also used : AllowAll(com.ibm.streamsx.topology.test.AllowAll) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) OutputTuple(com.ibm.streams.operator.OutputTuple) Tuple(com.ibm.streams.operator.Tuple) Test(org.junit.Test)

Example 8 with AllowAll

use of com.ibm.streamsx.topology.test.AllowAll in project streamsx.topology by IBMStreams.

the class StreamTest method testUnionSet.

@Test
public void testUnionSet() throws Exception {
    final Topology topology = newTopology("Union");
    TStream<String> s1 = topology.strings("A1", "B1", "C1");
    TStream<String> s2 = topology.strings("A2", "B2", "C2", "D2");
    TStream<String> s3 = topology.strings("A3", "B3", "C3");
    Set<TStream<String>> streams = new HashSet<TStream<String>>();
    streams.add(s2);
    streams.add(s3);
    TStream<String> su = s1.union(streams);
    // TODO - testing doesn't work against union streams in embedded.
    su = su.filter(new AllowAll<String>());
    Tester tester = topology.getTester();
    Condition<Long> suCount = tester.tupleCount(su, 10);
    Condition<List<String>> suContents = tester.stringContentsUnordered(su, "A1", "B1", "C1", "A2", "B2", "C2", "D2", "A3", "B3", "C3");
    assertTrue(complete(tester, suCount, 10, TimeUnit.SECONDS));
    // assertTrue("SU:" + suContents, suContents.valid());
    assertTrue("SU:" + suCount, suCount.valid());
    assertTrue("SUContents:" + suContents, suContents.valid());
}
Also used : TStream(com.ibm.streamsx.topology.TStream) Tester(com.ibm.streamsx.topology.tester.Tester) AllowAll(com.ibm.streamsx.topology.test.AllowAll) ArrayList(java.util.ArrayList) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 9 with AllowAll

use of com.ibm.streamsx.topology.test.AllowAll in project streamsx.topology by IBMStreams.

the class StreamTest method testSimpleParallel.

@Test
public void testSimpleParallel() throws Exception {
    final Topology topology = newTopology("EmbeddedParallel");
    TStream<Number> s1 = topology.numbers(1, 2, 3, 94, 5, 6).parallel(6).filter(new AllowAll<Number>()).endParallel();
    TStream<String> sp = StringStreams.toString(s1);
    Tester tester = topology.getTester();
    Condition<Long> spCount = tester.tupleCount(sp, 6);
    Condition<List<String>> spContents = tester.stringContentsUnordered(sp, "1", "2", "3", "94", "5", "6");
    complete(tester, spCount, 60, TimeUnit.SECONDS);
    // assertTrue("SU:" + suContents, suContents.valid());
    assertTrue("SP:" + spCount, spCount.valid());
    assertTrue("SPContents:" + spContents, spContents.valid());
}
Also used : Tester(com.ibm.streamsx.topology.tester.Tester) AllowAll(com.ibm.streamsx.topology.test.AllowAll) ArrayList(java.util.ArrayList) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Test(org.junit.Test)

Example 10 with AllowAll

use of com.ibm.streamsx.topology.test.AllowAll in project streamsx.topology by IBMStreams.

the class LowLatencyTest method nestedTest.

@Test
public void nestedTest() throws Exception {
    // ensure nested low latency yields all fns in the same container
    final Topology topology = newTopology("nestedTest");
    final Tester tester = topology.getTester();
    // getConfig().put(ContextProperties.KEEP_ARTIFACTS, true);
    String[] s1Strs = { "a" };
    TStream<String> s1 = topology.strings(s1Strs);
    TStream<String> s2 = s1.isolate().lowLatency().modify(getContainerIdAppend()).lowLatency().modify(getContainerIdAppend()).endLowLatency().modify(getContainerIdAppend()).endLowLatency();
    // NOTE, this works in the sense that all end up in the same container,
    // but currently only because of the default fuse-island behavior.
    // There are two issues with the json:
    // a) the 3rd modify is missing a lowLatencyTag
    // b) the 2nd modify has a different tag than the first.
    //    logically it must net out to being in the same container,
    //    so its just easiest if they're the same tag.
    //    It's not clear that having them be different is an absolute wrong,
    //    it's just that it doesn't add any value and complicates things.
    // s2.print();
    Condition<Long> uCount = tester.tupleCount(s2.filter(new AllowAll<String>()), 1);
    Condition<List<String>> contents = tester.stringContents(s2.filter(new AllowAll<String>()), "");
    complete(tester, uCount, 10, TimeUnit.SECONDS);
    Set<String> ids = getContainerIds(contents.getResult());
    assertEquals("ids: " + ids, 1, ids.size());
}
Also used : Tester(com.ibm.streamsx.topology.tester.Tester) AllowAll(com.ibm.streamsx.topology.test.AllowAll) ArrayList(java.util.ArrayList) 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)11 AllowAll (com.ibm.streamsx.topology.test.AllowAll)11 TestTopology (com.ibm.streamsx.topology.test.TestTopology)11 Test (org.junit.Test)11 List (java.util.List)8 Tester (com.ibm.streamsx.topology.tester.Tester)7 ArrayList (java.util.ArrayList)6 TStream (com.ibm.streamsx.topology.TStream)3 HashSet (java.util.HashSet)3 Ignore (org.junit.Ignore)3 OutputTuple (com.ibm.streams.operator.OutputTuple)1 Tuple (com.ibm.streams.operator.Tuple)1 StreamsContext (com.ibm.streamsx.topology.context.StreamsContext)1 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)1 File (java.io.File)1 HashMap (java.util.HashMap)1