use of org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor in project samza by apache.
the class TestContext method testSyncTaskWithSinglePartitionMultithreaded.
@Test
public void testSyncTaskWithSinglePartitionMultithreaded() throws Exception {
List<Integer> inputList = Arrays.asList(1, 2, 3, 4, 5);
List<Integer> outputList = Arrays.asList(10, 20, 30, 40, 50);
InMemorySystemDescriptor isd = new InMemorySystemDescriptor("test");
InMemoryInputDescriptor<Integer> imid = isd.getInputDescriptor("input", new NoOpSerde<Integer>());
InMemoryOutputDescriptor<Integer> imod = isd.getOutputDescriptor("output", new NoOpSerde<Integer>());
TestRunner.of(MyStreamTestTask.class).addInputStream(imid, inputList).addOutputStream(imod, 1).addConfig("job.container.thread.pool.size", "4").addExternalContext(new TestContext(10)).run(Duration.ofSeconds(1));
StreamAssert.containsInOrder(outputList, imod, Duration.ofMillis(1000));
}
use of org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor in project samza by apache.
the class TestContext method testSyncTaskWithSinglePartition.
@Test
public void testSyncTaskWithSinglePartition() throws Exception {
List<Integer> inputList = Arrays.asList(1, 2, 3, 4, 5);
List<Integer> outputList = Arrays.asList(10, 20, 30, 40, 50);
InMemorySystemDescriptor isd = new InMemorySystemDescriptor("test");
InMemoryInputDescriptor<Integer> imid = isd.getInputDescriptor("input", new NoOpSerde<Integer>());
InMemoryOutputDescriptor<Integer> imod = isd.getOutputDescriptor("output", new NoOpSerde<Integer>());
TestRunner.of(MyStreamTestTask.class).addInputStream(imid, inputList).addOutputStream(imod, 1).addExternalContext(new TestContext(10)).run(Duration.ofSeconds(1));
Assert.assertThat(TestRunner.consumeStream(imod, Duration.ofMillis(1000)).get(0), IsIterableContainingInOrder.contains(outputList.toArray()));
}
use of org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor in project samza by apache.
the class TestContext method testSamzaJobFailureForSyncTask.
/**
* Samza job logic expects integers, but doubles are passed here which results in failure
*/
@Test(expected = SamzaException.class)
public void testSamzaJobFailureForSyncTask() {
List<Double> inputList = Arrays.asList(1.2, 2.3, 3.33, 4.5);
InMemorySystemDescriptor isd = new InMemorySystemDescriptor("test");
InMemoryInputDescriptor<Double> imid = isd.getInputDescriptor("doubles", new NoOpSerde<Double>());
InMemoryOutputDescriptor imod = isd.getOutputDescriptor("output", new NoOpSerde<>());
TestRunner.of(MyStreamTestTask.class).addInputStream(imid, inputList).addOutputStream(imod, 1).addExternalContext(new TestContext(10)).run(Duration.ofSeconds(1));
}
use of org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor in project samza by apache.
the class AsyncStreamTaskIntegrationTest method testAsyncTaskWithSinglePartition.
@Test
public void testAsyncTaskWithSinglePartition() throws Exception {
List<Integer> inputList = Arrays.asList(1, 2, 3, 4, 5);
List<Integer> outputList = Arrays.asList(10, 20, 30, 40, 50);
InMemorySystemDescriptor isd = new InMemorySystemDescriptor("async-test");
InMemoryInputDescriptor<Integer> imid = isd.getInputDescriptor("ints", new NoOpSerde<Integer>());
InMemoryOutputDescriptor imod = isd.getOutputDescriptor("ints-out", new NoOpSerde<>());
TestRunner.of(MyAsyncStreamTask.class).addInputStream(imid, inputList).addOutputStream(imod, 1).run(Duration.ofSeconds(2));
Assert.assertThat(TestRunner.consumeStream(imod, Duration.ofMillis(1000)).get(0), IsIterableContainingInOrder.contains(outputList.toArray()));
}
use of org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor in project samza by apache.
the class TestLocalTableWithConfigRewriterEndToEnd method testWithConfigRewriter.
/**
* MyTaskApplication does not include table descriptor, so if the rewriter does not add the table configs properly,
* then the application will fail to execute.
*/
@Test
public void testWithConfigRewriter() {
InMemorySystemDescriptor isd = new InMemorySystemDescriptor("test");
InMemoryInputDescriptor<TestTableData.PageView> inputDescriptor = isd.getInputDescriptor("PageView", new NoOpSerde<>());
TestRunner.of(new MyTaskApplication()).addInputStream(inputDescriptor, TestTableData.generatePartitionedPageViews(40, 4)).addConfig("job.config.rewriters", "my-rewriter").addConfig("job.config.rewriter.my-rewriter.class", MyConfigRewriter.class.getName()).run(Duration.ofSeconds(10));
}
Aggregations