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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations