Search in sources :

Example 6 with InMemoryOutputDescriptor

use of org.apache.samza.test.framework.system.descriptors.InMemoryOutputDescriptor in project samza by apache.

the class AsyncStreamTaskIntegrationTest method testAsyncTaskWithSinglePartitionUsingStreamAssert.

@Test
public void testAsyncTaskWithSinglePartitionUsingStreamAssert() throws Exception {
    List<Integer> inputList = Arrays.asList(1, 2, 3, 4, 5);
    List<Integer> outputList = Arrays.asList(50, 10, 20, 30, 40);
    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));
    StreamAssert.containsInAnyOrder(outputList, imod, Duration.ofMillis(1000));
}
Also used : InMemoryOutputDescriptor(org.apache.samza.test.framework.system.descriptors.InMemoryOutputDescriptor) InMemorySystemDescriptor(org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor) Test(org.junit.Test)

Example 7 with InMemoryOutputDescriptor

use of org.apache.samza.test.framework.system.descriptors.InMemoryOutputDescriptor in project samza by apache.

the class AsyncStreamTaskIntegrationTest method testSamzaJobTimeoutFailureForAsyncTask.

/**
 * Job should fail because it times out too soon
 */
@Test(expected = SamzaException.class)
public void testSamzaJobTimeoutFailureForAsyncTask() {
    InMemorySystemDescriptor isd = new InMemorySystemDescriptor("async-test");
    InMemoryInputDescriptor<Integer> imid = isd.getInputDescriptor("ints", new NoOpSerde<>());
    InMemoryOutputDescriptor imod = isd.getOutputDescriptor("ints-out", new NoOpSerde<>());
    TestRunner.of(MyAsyncStreamTask.class).addInputStream(imid, Arrays.asList(1, 2, 3, 4)).addOutputStream(imod, 1).run(Duration.ofMillis(1));
}
Also used : InMemoryOutputDescriptor(org.apache.samza.test.framework.system.descriptors.InMemoryOutputDescriptor) InMemorySystemDescriptor(org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor) Test(org.junit.Test)

Example 8 with InMemoryOutputDescriptor

use of org.apache.samza.test.framework.system.descriptors.InMemoryOutputDescriptor in project samza by apache.

the class AsyncStreamTaskIntegrationTest method testAsyncTaskWithMultiplePartition.

@Test
public void testAsyncTaskWithMultiplePartition() throws Exception {
    Map<Integer, List<KV>> inputPartitionData = new HashMap<>();
    Map<Integer, List<Integer>> expectedOutputPartitionData = new HashMap<>();
    genData(inputPartitionData, expectedOutputPartitionData);
    InMemorySystemDescriptor isd = new InMemorySystemDescriptor("async-test");
    InMemoryInputDescriptor<KV> imid = isd.getInputDescriptor("ints", new NoOpSerde<KV>());
    InMemoryOutputDescriptor imod = isd.getOutputDescriptor("ints-out", new NoOpSerde<>());
    TestRunner.of(MyAsyncStreamTask.class).addInputStream(imid, inputPartitionData).addOutputStream(imod, 5).run(Duration.ofSeconds(2));
    StreamAssert.containsInOrder(expectedOutputPartitionData, imod, Duration.ofMillis(1000));
}
Also used : InMemoryOutputDescriptor(org.apache.samza.test.framework.system.descriptors.InMemoryOutputDescriptor) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) KV(org.apache.samza.operators.KV) InMemorySystemDescriptor(org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor) Test(org.junit.Test)

Aggregations

InMemoryOutputDescriptor (org.apache.samza.test.framework.system.descriptors.InMemoryOutputDescriptor)8 InMemorySystemDescriptor (org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor)8 Test (org.junit.Test)7 List (java.util.List)4 KV (org.apache.samza.operators.KV)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Duration (java.time.Duration)2 Collectors (java.util.stream.Collectors)2 SamzaException (org.apache.samza.SamzaException)2 OutgoingMessageEnvelope (org.apache.samza.system.OutgoingMessageEnvelope)2 Preconditions (com.google.common.base.Preconditions)1 File (java.io.File)1 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Random (java.util.Random)1 Set (java.util.Set)1 RandomStringUtils (org.apache.commons.lang3.RandomStringUtils)1