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());
}
use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class ParallelTest method testAdjacentEndParallelUnionSource.
@Test
public void testAdjacentEndParallelUnionSource() throws Exception {
checkUdpSupported();
List<String> stringList = getListOfUniqueStrings(800);
String[] stringArray = new String[800];
stringArray = stringList.toArray(stringArray);
Topology topology = newTopology("testAdj");
TStream<String> out0 = topology.strings(stringArray).parallel(of(20), TStream.Routing.HASH_PARTITIONED);
out0 = out0.transform(randomStringProducer("region1")).endParallel();
TStream<String> out2 = topology.strings(stringArray).union(out0).parallel(of(5), TStream.Routing.HASH_PARTITIONED);
out2 = out2.transform(randomStringProducer("region2")).endParallel();
TStream<String> numRegions = out2.multiTransform(uniqueStringCounter(1600, "region"));
Tester tester = topology.getTester();
Condition<List<String>> assertFinished = tester.stringContentsUnordered(numRegions, "20", "5");
Condition<Long> expectedCount = tester.tupleCount(out2, 1600);
complete(tester, allConditions(assertFinished, expectedCount), 60, TimeUnit.SECONDS);
assertTrue(expectedCount.getResult().toString(), expectedCount.valid());
assertTrue(assertFinished.getResult().toString(), assertFinished.valid());
}
use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class MqttStreamsTest method completeAndValidate.
private void completeAndValidate(String msg, Topology topology, TStream<String> stream, int secTimeout, String... expected) throws Exception {
Tester tester = topology.getTester();
Condition<Long> sCount = tester.tupleCount(stream, expected.length);
Condition<List<String>> sContents = tester.stringContents(stream, expected);
complete(tester, sCount, secTimeout, TimeUnit.SECONDS);
assertTrue(msg + " contents:" + sContents, sContents.valid());
assertTrue("valid:" + sCount, sCount.valid());
}
Aggregations