Search in sources :

Example 31 with TestingServerStarter

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

the class StreamTransactionMetadataTasksTest method setup.

@Before
public void setup() {
    try {
        zkServer = new TestingServerStarter().start();
    } catch (Exception e) {
        log.error("Error starting ZK server", e);
    }
    zkClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new ExponentialBackoffRetry(200, 10, 5000));
    zkClient.start();
    streamStore = StreamStoreFactory.createZKStore(zkClient, executor);
    TaskMetadataStore taskMetadataStore = TaskStoreFactory.createZKStore(zkClient, executor);
    hostStore = HostStoreFactory.createInMemoryStore(HostMonitorConfigImpl.dummyConfig());
    segmentHelperMock = SegmentHelperMock.getSegmentHelperMock();
    connectionFactory = Mockito.mock(ConnectionFactory.class);
    streamMetadataTasks = new StreamMetadataTasks(streamStore, hostStore, taskMetadataStore, segmentHelperMock, executor, "host", connectionFactory, this.authEnabled, "secret");
}
Also used : ConnectionFactory(io.pravega.client.netty.impl.ConnectionFactory) TestingServerStarter(io.pravega.test.common.TestingServerStarter) TaskMetadataStore(io.pravega.controller.store.task.TaskMetadataStore) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) CheckpointStoreException(io.pravega.controller.store.checkpoint.CheckpointStoreException) Before(org.junit.Before)

Example 32 with TestingServerStarter

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

the class ControllerClusterListenerTest method setup.

@Before
public void setup() throws Exception {
    // 1. Start ZK server.
    zkServer = new TestingServerStarter().start();
    // 2. Start ZK client.
    curatorClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new ExponentialBackoffRetry(200, 10, 5000));
    curatorClient.start();
    // 3. Start executor service.
    executor = Executors.newScheduledThreadPool(5);
    // 4. start cluster event listener
    clusterZK = new ClusterZKImpl(curatorClient, ClusterType.CONTROLLER);
    clusterZK.addListener((eventType, host) -> {
        switch(eventType) {
            case HOST_ADDED:
                nodeAddedQueue.offer(host.getHostId());
                break;
            case HOST_REMOVED:
                nodeRemovedQueue.offer(host.getHostId());
                break;
            case ERROR:
            default:
                break;
        }
    });
}
Also used : TestingServerStarter(io.pravega.test.common.TestingServerStarter) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) ClusterZKImpl(io.pravega.common.cluster.zkImpl.ClusterZKImpl) Before(org.junit.Before)

Example 33 with TestingServerStarter

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

the class ControllerServiceWithZKStreamTest method setup.

@Before
public void setup() {
    try {
        zkServer = new TestingServerStarter().start();
    } catch (Exception e) {
        log.error("Error starting ZK server", e);
    }
    zkClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new ExponentialBackoffRetry(200, 10, 5000));
    zkClient.start();
    StreamMetadataStore streamStore = StreamStoreFactory.createZKStore(zkClient, executor);
    TaskMetadataStore taskMetadataStore = TaskStoreFactory.createZKStore(zkClient, executor);
    HostControllerStore hostStore = HostStoreFactory.createInMemoryStore(HostMonitorConfigImpl.dummyConfig());
    SegmentHelper segmentHelperMock = SegmentHelperMock.getSegmentHelperMock();
    connectionFactory = new ConnectionFactoryImpl(ClientConfig.builder().controllerURI(URI.create("tcp://localhost")).build());
    streamMetadataTasks = new StreamMetadataTasks(streamStore, hostStore, taskMetadataStore, segmentHelperMock, executor, "host", connectionFactory, false, "");
    this.streamRequestHandler = new StreamRequestHandler(new AutoScaleTask(streamMetadataTasks, streamStore, executor), new ScaleOperationTask(streamMetadataTasks, streamStore, executor), new UpdateStreamTask(streamMetadataTasks, streamStore, executor), new SealStreamTask(streamMetadataTasks, streamStore, executor), new DeleteStreamTask(streamMetadataTasks, streamStore, executor), new TruncateStreamTask(streamMetadataTasks, streamStore, executor), executor);
    streamMetadataTasks.setRequestEventWriter(new ControllerEventStreamWriterMock(streamRequestHandler, executor));
    streamTransactionMetadataTasks = new StreamTransactionMetadataTasks(streamStore, hostStore, segmentHelperMock, executor, "host", connectionFactory, false, "");
    consumer = new ControllerService(streamStore, hostStore, streamMetadataTasks, streamTransactionMetadataTasks, segmentHelperMock, executor, null);
}
Also used : SealStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.SealStreamTask) TestingServerStarter(io.pravega.test.common.TestingServerStarter) TaskMetadataStore(io.pravega.controller.store.task.TaskMetadataStore) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) UpdateStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.UpdateStreamTask) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) ScaleOperationTask(io.pravega.controller.server.eventProcessor.requesthandlers.ScaleOperationTask) AutoScaleTask(io.pravega.controller.server.eventProcessor.requesthandlers.AutoScaleTask) StreamRequestHandler(io.pravega.controller.server.eventProcessor.requesthandlers.StreamRequestHandler) HostControllerStore(io.pravega.controller.store.host.HostControllerStore) DeleteStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.DeleteStreamTask) ControllerEventStreamWriterMock(io.pravega.controller.mocks.ControllerEventStreamWriterMock) StreamTransactionMetadataTasks(io.pravega.controller.task.Stream.StreamTransactionMetadataTasks) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) ConnectionFactoryImpl(io.pravega.client.netty.impl.ConnectionFactoryImpl) TruncateStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.TruncateStreamTask) Before(org.junit.Before)

Example 34 with TestingServerStarter

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

the class ZKControllerServiceStarterTest 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).namespace("pravega/" + UUID.randomUUID()).sessionTimeoutMs(10 * 1000).build();
    storeClientConfig = StoreClientConfigImpl.withZKClient(zkClientConfig);
    storeClient = StoreClientFactory.createStoreClient(storeClientConfig);
    Assert.assertNotNull(storeClient);
}
Also used : ZKClientConfig(io.pravega.controller.store.client.ZKClientConfig) TestingServerStarter(io.pravega.test.common.TestingServerStarter) IOException(java.io.IOException)

Example 35 with TestingServerStarter

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

the class ScaleRequestHandlerTest method setup.

@Before
public void setup() throws Exception {
    zkServer = new TestingServerStarter().start();
    zkServer.start();
    zkClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new ExponentialBackoffRetry(20, 1, 50));
    zkClient.start();
    String hostId;
    try {
        // On each controller process restart, it gets a fresh hostId,
        // which is a combination of hostname and random GUID.
        hostId = InetAddress.getLocalHost().getHostAddress() + UUID.randomUUID().toString();
    } catch (UnknownHostException e) {
        hostId = UUID.randomUUID().toString();
    }
    streamStore = StreamStoreFactory.createZKStore(zkClient, executor);
    taskMetadataStore = TaskStoreFactory.createZKStore(zkClient, executor);
    hostStore = HostStoreFactory.createInMemoryStore(HostMonitorConfigImpl.dummyConfig());
    SegmentHelper segmentHelper = SegmentHelperMock.getSegmentHelperMock();
    connectionFactory = new ConnectionFactoryImpl(ClientConfig.builder().build());
    clientFactory = mock(ClientFactory.class);
    streamMetadataTasks = new StreamMetadataTasks(streamStore, hostStore, taskMetadataStore, segmentHelper, executor, hostId, connectionFactory, false, "");
    streamMetadataTasks.initializeStreamWriters(clientFactory, Config.SCALE_STREAM_NAME);
    streamTransactionMetadataTasks = new StreamTransactionMetadataTasks(streamStore, hostStore, segmentHelper, executor, hostId, connectionFactory, false, "");
    long createTimestamp = System.currentTimeMillis();
    // add a host in zk
    // mock pravega
    // create a stream
    streamStore.createScope(scope).get();
    streamMetadataTasks.createStream(scope, stream, config, createTimestamp).get();
}
Also used : TestingServerStarter(io.pravega.test.common.TestingServerStarter) UnknownHostException(java.net.UnknownHostException) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) ClientFactory(io.pravega.client.ClientFactory) StreamTransactionMetadataTasks(io.pravega.controller.task.Stream.StreamTransactionMetadataTasks) SegmentHelper(io.pravega.controller.server.SegmentHelper) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) ConnectionFactoryImpl(io.pravega.client.netty.impl.ConnectionFactoryImpl) Before(org.junit.Before)

Aggregations

TestingServerStarter (io.pravega.test.common.TestingServerStarter)36 Before (org.junit.Before)24 StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)22 PravegaConnectionListener (io.pravega.segmentstore.server.host.handler.PravegaConnectionListener)22 ControllerWrapper (io.pravega.test.integration.demo.ControllerWrapper)17 ConnectionFactoryImpl (io.pravega.client.netty.impl.ConnectionFactoryImpl)11 ServiceBuilder (io.pravega.segmentstore.server.store.ServiceBuilder)11 TestingServer (org.apache.curator.test.TestingServer)10 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)9 Cleanup (lombok.Cleanup)8 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)8 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)7 Controller (io.pravega.client.stream.impl.Controller)7 HostControllerStore (io.pravega.controller.store.host.HostControllerStore)6 TaskMetadataStore (io.pravega.controller.store.task.TaskMetadataStore)6 Test (org.junit.Test)6 ClientConfig (io.pravega.client.ClientConfig)5 ClientFactory (io.pravega.client.ClientFactory)5 Stream (io.pravega.client.stream.Stream)5 ClientFactoryImpl (io.pravega.client.stream.impl.ClientFactoryImpl)5