use of io.pravega.test.common.TestingServerStarter in project pravega by pravega.
the class IntermittentCnxnFailureTest method setup.
@Before
public void setup() throws Exception {
zkServer = new TestingServerStarter().start();
zkServer.start();
zkClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new ExponentialBackoffRetry(200, 10, 5000));
zkClient.start();
streamStore = StreamStoreFactory.createZKStore(zkClient, executor);
TaskMetadataStore taskMetadataStore = TaskStoreFactory.createZKStore(zkClient, executor);
HostControllerStore hostStore = HostStoreFactory.createInMemoryStore(HostMonitorConfigImpl.dummyConfig());
segmentHelperMock = spy(new SegmentHelper());
doReturn(Controller.NodeUri.newBuilder().setEndpoint("localhost").setPort(Config.SERVICE_PORT).build()).when(segmentHelperMock).getSegmentUri(anyString(), anyString(), anyInt(), any());
ConnectionFactoryImpl connectionFactory = new ConnectionFactoryImpl(ClientConfig.builder().build());
streamMetadataTasks = new StreamMetadataTasks(streamStore, hostStore, taskMetadataStore, segmentHelperMock, executor, "host", connectionFactory, false, "");
streamTransactionMetadataTasks = new StreamTransactionMetadataTasks(streamStore, hostStore, segmentHelperMock, executor, "host", connectionFactory, false, "");
controllerService = new ControllerService(streamStore, hostStore, streamMetadataTasks, streamTransactionMetadataTasks, segmentHelperMock, executor, null);
controllerService.createScope(SCOPE).get();
}
use of io.pravega.test.common.TestingServerStarter in project pravega by pravega.
the class SegmentContainerMonitorTest method startZookeeper.
@Before
public void startZookeeper() throws Exception {
zkTestServer = new TestingServerStarter().start();
String zkUrl = zkTestServer.getConnectString();
zkClient = CuratorFrameworkFactory.newClient(zkUrl, new ExponentialBackoffRetry(200, 10, 5000));
zkClient.start();
cluster = new ClusterZKImpl(zkClient, ClusterType.HOST);
}
use of io.pravega.test.common.TestingServerStarter in project pravega by pravega.
the class ZKControllerServiceMainTest method setup.
@Override
public void setup() {
try {
zkServer = new TestingServerStarter().start();
} catch (Exception e) {
log.error("Error starting test zk server");
Assert.fail("Error starting test zk server");
}
ZKClientConfig zkClientConfig = ZKClientConfigImpl.builder().connectionString(zkServer.getConnectString()).initialSleepInterval(500).maxRetries(10).sessionTimeoutMs(10 * 1000).namespace("pravega/" + UUID.randomUUID()).build();
storeClientConfig = StoreClientConfigImpl.withZKClient(zkClientConfig);
}
use of io.pravega.test.common.TestingServerStarter in project pravega by pravega.
the class ControllerEventProcessorTest method setUp.
@Before
public void setUp() throws Exception {
executor = Executors.newScheduledThreadPool(10);
zkServer = new TestingServerStarter().start();
zkServer.start();
zkClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new RetryOneTime(2000));
zkClient.start();
streamStore = StreamStoreFactory.createZKStore(zkClient, executor);
hostStore = HostStoreFactory.createInMemoryStore(HostMonitorConfigImpl.dummyConfig());
segmentHelperMock = SegmentHelperMock.getSegmentHelperMock();
streamMetadataTasks = new StreamMetadataTasks(streamStore, hostStore, TaskStoreFactory.createInMemoryStore(executor), segmentHelperMock, executor, "1", mock(ConnectionFactory.class), false, "");
// region createStream
final ScalingPolicy policy1 = ScalingPolicy.fixed(2);
final StreamConfiguration configuration1 = StreamConfiguration.builder().scope(SCOPE).streamName(STREAM).scalingPolicy(policy1).build();
streamStore.createScope(SCOPE).join();
long start = System.currentTimeMillis();
streamStore.createStream(SCOPE, STREAM, configuration1, start, null, executor).join();
streamStore.setState(SCOPE, STREAM, State.ACTIVE, null, executor).join();
// endregion
}
use of io.pravega.test.common.TestingServerStarter in project pravega by pravega.
the class ZkStoreRetentionTest method testOwnershipOfExistingBucket.
@Test(timeout = 10000)
public void testOwnershipOfExistingBucket() throws Exception {
TestingServer zkServer2 = new TestingServerStarter().start();
zkServer2.start();
CuratorFramework zkClient2 = CuratorFrameworkFactory.newClient(zkServer2.getConnectString(), 10000, 1000, (r, e, s) -> false);
zkClient2.start();
ScheduledExecutorService executor2 = Executors.newScheduledThreadPool(10);
String hostId = UUID.randomUUID().toString();
StreamMetadataStore streamMetadataStore2 = StreamStoreFactory.createZKStore(zkClient2, 1, executor2);
TaskMetadataStore taskMetadataStore = TaskStoreFactory.createInMemoryStore(executor2);
HostControllerStore hostStore = HostStoreFactory.createInMemoryStore(HostMonitorConfigImpl.dummyConfig());
SegmentHelper segmentHelper = SegmentHelperMock.getSegmentHelperMock();
ConnectionFactoryImpl connectionFactory = new ConnectionFactoryImpl(ClientConfig.builder().build());
StreamMetadataTasks streamMetadataTasks2 = new StreamMetadataTasks(streamMetadataStore2, hostStore, taskMetadataStore, segmentHelper, executor2, hostId, connectionFactory, false, "");
String scope = "scope1";
String streamName = "stream1";
streamMetadataStore2.addUpdateStreamForAutoStreamCut(scope, streamName, RetentionPolicy.builder().build(), null, executor2).join();
String scope2 = "scope2";
String streamName2 = "stream2";
streamMetadataStore2.addUpdateStreamForAutoStreamCut(scope2, streamName2, RetentionPolicy.builder().build(), null, executor2).join();
StreamCutService service2 = new StreamCutService(1, hostId, streamMetadataStore2, streamMetadataTasks2, executor2);
service2.startAsync();
service2.awaitRunning();
assertTrue(service2.getBuckets().stream().allMatch(x -> x.getRetentionFutureMap().size() == 2));
service2.stopAsync();
service2.awaitTerminated();
zkClient2.close();
zkServer2.close();
streamMetadataTasks2.close();
connectionFactory.close();
executor2.shutdown();
}
Aggregations