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());
}
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);
}
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());
}
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());
}
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());
}
Aggregations