Search in sources :

Example 1 with SetupUtils

use of io.pravega.test.integration.utils.SetupUtils in project pravega by pravega.

the class SingleThreadEndToEndTest method testReadWrite.

@Test(timeout = 60000)
public void testReadWrite() throws Exception {
    @Cleanup("stopAllServices") SetupUtils setupUtils = new SetupUtils();
    setupUtils.startAllServices(1);
    setupUtils.createTestStream("stream", 1);
    @Cleanup EventStreamWriter<Integer> writer = setupUtils.getIntegerWriter("stream");
    writer.writeEvent(1);
    writer.flush();
    @Cleanup val rgm = setupUtils.createReaderGroupManager("stream");
    @Cleanup EventStreamReader<Integer> reader = setupUtils.getIntegerReader("stream", rgm);
    EventRead<Integer> event = reader.readNextEvent(10000);
    Assert.assertEquals(1, (int) event.getEvent());
}
Also used : lombok.val(lombok.val) SetupUtils(io.pravega.test.integration.utils.SetupUtils) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Example 2 with SetupUtils

use of io.pravega.test.integration.utils.SetupUtils in project pravega by pravega.

the class SingleThreadEndToEndTest method testSealedStream.

@Test(timeout = 60000)
public void testSealedStream() throws Exception {
    @Cleanup("stopAllServices") SetupUtils setupUtils = new SetupUtils();
    setupUtils.startAllServices(1);
    @Cleanup StreamManager streamManager = StreamManager.create(setupUtils.getClientConfig());
    streamManager.createScope("scope");
    streamManager.createStream("scope", "stream", StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build());
    @Cleanup EventStreamWriter<byte[]> writer = setupUtils.getClientFactory().createEventWriter("stream", new ByteArraySerializer(), EventWriterConfig.builder().retryAttempts(2).enableLargeEvents(true).build());
    writer.writeEvent(new byte[Serializer.MAX_EVENT_SIZE + 1]).join();
    writer.flush();
    assertTrue(streamManager.sealStream("scope", "stream"));
    AssertExtensions.assertThrows(SegmentSealedException.class, () -> writer.writeEvent(new byte[Serializer.MAX_EVENT_SIZE + 1]).join());
    AssertExtensions.assertThrows(IllegalStateException.class, () -> writer.writeEvent(new byte[1]).join());
    writer.flush();
}
Also used : StreamManager(io.pravega.client.admin.StreamManager) SetupUtils(io.pravega.test.integration.utils.SetupUtils) Cleanup(lombok.Cleanup) ByteArraySerializer(io.pravega.client.stream.impl.ByteArraySerializer) Test(org.junit.Test)

Aggregations

SetupUtils (io.pravega.test.integration.utils.SetupUtils)2 Cleanup (lombok.Cleanup)2 Test (org.junit.Test)2 StreamManager (io.pravega.client.admin.StreamManager)1 ByteArraySerializer (io.pravega.client.stream.impl.ByteArraySerializer)1 lombok.val (lombok.val)1