use of com.ibm.streamsx.topology.tester.Tester 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());
}
use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class ParallelTest method testParallelNonPartitioned.
@Test
public void testParallelNonPartitioned() throws Exception {
checkUdpSupported();
Topology topology = newTopology("testParallel");
final int count = new Random().nextInt(1000) + 37;
TStream<BeaconTuple> fb = BeaconStreams.beacon(topology, count);
TStream<BeaconTuple> pb = fb.parallel(5);
TStream<Integer> is = pb.transform(randomHashProducer());
TStream<Integer> joined = is.endParallel();
TStream<String> numRegions = joined.transform(uniqueIdentifierMap(count));
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(numRegions, 1);
Condition<List<String>> regionCount = tester.stringContents(numRegions, "5");
complete(tester, allConditions(regionCount, expectedCount), 10, TimeUnit.SECONDS);
assertTrue(expectedCount.valid());
assertTrue(regionCount.valid());
}
use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class ParallelTest method testUnionUnparallel.
@Test
public void testUnionUnparallel() throws Exception {
Topology topology = newTopology();
TStream<String> strings = topology.strings("A", "B", "C", "D", "E");
TStream<String> stringsP = strings.parallel(3);
TStream<String> stringsP_AB = stringsP.filter(allowAB());
TStream<String> stringsP_CDE = stringsP.filter(allowCDE());
stringsP = stringsP_AB.union(stringsP_CDE).endParallel();
Tester tester = topology.getTester();
Condition<Long> fiveTuples = tester.tupleCount(stringsP, 5);
Condition<List<String>> contents = tester.stringContentsUnordered(stringsP, "A", "B", "C", "D", "E");
complete(tester, allConditions(fiveTuples, contents), 10, TimeUnit.SECONDS);
assertTrue("contents: " + contents, contents.valid());
}
use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class ParallelTest method testParallelWidthSupplier.
@Test
public void testParallelWidthSupplier() throws Exception {
checkUdpSupported();
Topology topology = newTopology("testParallelWidthValue");
final int count = new Random().nextInt(1000) + 37;
String submissionWidthName = "width";
final Integer submissionWidth = 5;
TStream<BeaconTuple> fb = BeaconStreams.beacon(topology, count);
TStream<BeaconTuple> pb = fb.parallel(() -> submissionWidth);
TStream<Integer> is = pb.transform(randomHashProducer());
TStream<Integer> joined = is.endParallel();
TStream<String> numRegions = joined.transform(uniqueIdentifierMap(count));
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(numRegions, 1);
Condition<List<String>> regionCount = tester.stringContents(numRegions, submissionWidth.toString());
complete(tester, allConditions(regionCount, expectedCount), 10, TimeUnit.SECONDS);
assertTrue(expectedCount.valid());
assertTrue(regionCount.valid());
}
use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class ParallelTest method testObjectHashPartition.
@Test
public void testObjectHashPartition() throws Exception {
checkUdpSupported();
Topology topology = newTopology("testObjectHashPartition");
final int count = new Random().nextInt(10) + 37;
TStream<String> kb = topology.source(stringTuple5Counter(count));
TStream<String> pb = kb.parallel(Value.of(5), TStream.Routing.HASH_PARTITIONED);
TStream<ChannelAndSequence> cs = pb.transform(stringTupleChannelSeqTransformer());
TStream<ChannelAndSequence> joined = cs.endParallel();
TStream<String> valid_count = joined.transform(partitionCounter(count));
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(valid_count, 1);
Condition<List<String>> validCount = tester.stringContents(valid_count, "5");
complete(tester, allConditions(expectedCount, validCount), 10, TimeUnit.SECONDS);
assertTrue(expectedCount.valid());
assertTrue(validCount.valid());
}
Aggregations