Search in sources :

Example 1 with InlineExecutor

use of io.pravega.test.common.InlineExecutor in project pravega by pravega.

the class ControllerImplLBTest method testDiscoverySuccessUsingIPAddress.

@Test
public void testDiscoverySuccessUsingIPAddress() throws Exception {
    final int serverPort1 = testRPCServer1.getPort();
    final int serverPort2 = testRPCServer2.getPort();
    // Use 2 servers to discover all the servers.
    String localIP = InetAddress.getLoopbackAddress().getHostAddress();
    @Cleanup("shutdown") InlineExecutor executor = new InlineExecutor();
    final ControllerImpl controllerClient = new ControllerImpl(ControllerImplConfig.builder().clientConfig(ClientConfig.builder().controllerURI(URI.create("pravega://" + localIP + ":" + serverPort1 + "," + localIP + ":" + serverPort2)).build()).retryAttempts(1).build(), executor);
    final Set<PravegaNodeUri> uris = fetchFromServers(controllerClient, 3);
    // Verify we could reach all 3 controllers.
    Assert.assertEquals(3, uris.size());
}
Also used : PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) InlineExecutor(io.pravega.test.common.InlineExecutor) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Example 2 with InlineExecutor

use of io.pravega.test.common.InlineExecutor in project pravega by pravega.

the class ControllerImplLBTest method testDirectSuccessUsingIPAddress.

@Test
public void testDirectSuccessUsingIPAddress() throws Exception {
    final int serverPort1 = testRPCServer1.getPort();
    final int serverPort2 = testRPCServer2.getPort();
    final int serverPort3 = testRPCServer3.getPort();
    // Directly use all 3 servers and verify.
    String localIP = InetAddress.getLoopbackAddress().getHostAddress();
    @Cleanup("shutdown") InlineExecutor executor = new InlineExecutor();
    final ControllerImpl controllerClient = new ControllerImpl(ControllerImplConfig.builder().clientConfig(ClientConfig.builder().controllerURI(URI.create("tcp://" + localIP + ":" + serverPort1 + "," + localIP + ":" + serverPort2 + "," + localIP + ":" + serverPort3)).build()).retryAttempts(1).build(), executor);
    final Set<PravegaNodeUri> uris = fetchFromServers(controllerClient, 3);
    Assert.assertEquals(3, uris.size());
}
Also used : PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) InlineExecutor(io.pravega.test.common.InlineExecutor) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Example 3 with InlineExecutor

use of io.pravega.test.common.InlineExecutor in project pravega by pravega.

the class ControllerImplLBTest method testDiscoverySuccess.

@Test
public void testDiscoverySuccess() throws Exception {
    final int serverPort1 = testRPCServer1.getPort();
    final int serverPort2 = testRPCServer2.getPort();
    // Use 2 servers to discover all the servers.
    @Cleanup("shutdown") InlineExecutor executor = new InlineExecutor();
    final ControllerImpl controllerClient = new ControllerImpl(ControllerImplConfig.builder().clientConfig(ClientConfig.builder().controllerURI(URI.create("pravega://localhost:" + serverPort1 + ",localhost:" + serverPort2)).build()).retryAttempts(1).build(), executor);
    final Set<PravegaNodeUri> uris = fetchFromServers(controllerClient, 3);
    // Verify we could reach all 3 controllers.
    Assert.assertEquals(3, uris.size());
}
Also used : PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) InlineExecutor(io.pravega.test.common.InlineExecutor) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Example 4 with InlineExecutor

use of io.pravega.test.common.InlineExecutor in project pravega by pravega.

the class ControllerImplLBTest method testDirectSuccess.

@Test
public void testDirectSuccess() throws Exception {
    final int serverPort1 = testRPCServer1.getPort();
    final int serverPort2 = testRPCServer2.getPort();
    final int serverPort3 = testRPCServer3.getPort();
    // Directly use all 3 servers and verify.
    @Cleanup("shutdown") InlineExecutor executor = new InlineExecutor();
    final ControllerImpl controllerClient = new ControllerImpl(ControllerImplConfig.builder().clientConfig(ClientConfig.builder().controllerURI(URI.create("tcp://localhost:" + serverPort1 + ",localhost:" + serverPort2 + ",localhost:" + serverPort3)).build()).retryAttempts(1).build(), executor);
    final Set<PravegaNodeUri> uris = fetchFromServers(controllerClient, 3);
    Assert.assertEquals(3, uris.size());
}
Also used : PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) InlineExecutor(io.pravega.test.common.InlineExecutor) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Example 5 with InlineExecutor

use of io.pravega.test.common.InlineExecutor in project pravega by pravega.

the class EventStreamWriterTest method testTxnFailed.

@Test
public void testTxnFailed() {
    String scope = "scope";
    String streamName = "stream";
    StreamImpl stream = new StreamImpl(scope, streamName);
    Segment segment = new Segment(scope, streamName, 0);
    UUID txid = UUID.randomUUID();
    EventWriterConfig config = EventWriterConfig.builder().transactionTimeoutTime(0).transactionTimeoutScaleGracePeriod(0).build();
    SegmentOutputStreamFactory streamFactory = Mockito.mock(SegmentOutputStreamFactory.class);
    Controller controller = Mockito.mock(Controller.class);
    Mockito.when(controller.getCurrentSegments(scope, streamName)).thenReturn(getSegmentsFuture(segment));
    FakeSegmentOutputStream outputStream = new FakeSegmentOutputStream(segment);
    FakeSegmentOutputStream bad = new FakeSegmentOutputStream(segment);
    Mockito.when(controller.createTransaction(stream, 0, 0)).thenReturn(CompletableFuture.completedFuture(new TxnSegments(getSegments(segment), txid)));
    Mockito.when(streamFactory.createOutputStreamForTransaction(eq(segment), eq(txid), any(), any(), any())).thenReturn(outputStream);
    Mockito.when(streamFactory.createOutputStreamForSegment(eq(segment), any(), any(), any())).thenReturn(bad);
    JavaSerializer<String> serializer = new JavaSerializer<>();
    @Cleanup EventStreamWriter<String> writer = new EventStreamWriterImpl<>(stream, controller, streamFactory, serializer, config, new InlineExecutor());
    Transaction<String> txn = writer.beginTxn();
    outputStream.invokeSealedCallBack();
    try {
        txn.writeEvent("Foo");
    } catch (TxnFailedException e) {
    // Expected
    }
    Mockito.verify(controller).getCurrentSegments(any(), any());
    assertTrue(bad.getUnackedEventsOnSeal().isEmpty());
    assertEquals(1, outputStream.getUnackedEventsOnSeal().size());
}
Also used : Cleanup(lombok.Cleanup) Segment(io.pravega.client.segment.impl.Segment) EventWriterConfig(io.pravega.client.stream.EventWriterConfig) SegmentOutputStreamFactory(io.pravega.client.segment.impl.SegmentOutputStreamFactory) InlineExecutor(io.pravega.test.common.InlineExecutor) TxnFailedException(io.pravega.client.stream.TxnFailedException) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

InlineExecutor (io.pravega.test.common.InlineExecutor)54 Test (org.junit.Test)52 Cleanup (lombok.Cleanup)51 PravegaNodeUri (io.pravega.shared.protocol.netty.PravegaNodeUri)17 UUID (java.util.UUID)13 Segment (io.pravega.client.segment.impl.Segment)11 WireCommands (io.pravega.shared.protocol.netty.WireCommands)11 ReaderGroup (io.pravega.client.stream.ReaderGroup)10 FailingReplyProcessor (io.pravega.shared.protocol.netty.FailingReplyProcessor)10 ReaderGroupManager (io.pravega.client.admin.ReaderGroupManager)9 Stream (io.pravega.client.stream.Stream)9 Append (io.pravega.shared.protocol.netty.Append)9 Checkpoint (io.pravega.client.stream.Checkpoint)8 StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)8 Event (io.pravega.shared.protocol.netty.WireCommands.Event)8 HashMap (java.util.HashMap)8 ClientConfig (io.pravega.client.ClientConfig)7 ReaderGroupConfig (io.pravega.client.stream.ReaderGroupConfig)7 ClientFactoryImpl (io.pravega.client.stream.impl.ClientFactoryImpl)7 SocketConnectionFactoryImpl (io.pravega.client.connection.impl.SocketConnectionFactoryImpl)6