Search in sources :

Example 16 with TestingServer

use of org.apache.curator.test.TestingServer in project metron by apache.

the class ConfigurationFunctionsTest method setup.

@BeforeClass
public static void setup() throws Exception {
    testZkServer = new TestingServer(true);
    zookeeperUrl = testZkServer.getConnectString();
    client = ConfigurationsUtils.getClient(zookeeperUrl);
    client.start();
    pushConfigs(SAMPLE_CONFIG_PATH);
    pushConfigs(PARSER_CONFIGS_PATH);
}
Also used : TestingServer(org.apache.curator.test.TestingServer) BeforeClass(org.junit.BeforeClass)

Example 17 with TestingServer

use of org.apache.curator.test.TestingServer in project metron by apache.

the class ZKServerComponent method start.

@Override
public void start() throws UnableToStartException {
    try {
        testZkServer = new TestingServer(true);
        zookeeperUrl = testZkServer.getConnectString();
        if (postStartCallback.isPresent()) {
            postStartCallback.get().accept(this);
        }
    } catch (Exception e) {
        throw new UnableToStartException("Unable to start TestingServer", e);
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) UnableToStartException(org.apache.metron.integration.UnableToStartException) UnableToStartException(org.apache.metron.integration.UnableToStartException) IOException(java.io.IOException)

Example 18 with TestingServer

use of org.apache.curator.test.TestingServer in project hive by apache.

the class TestActivePassiveHA method beforeTest.

@BeforeClass
public static void beforeTest() throws Exception {
    MiniHS2.cleanupLocalDir();
    zkServer = new TestingServer();
    Class.forName(MiniHS2.getJdbcDriverName());
}
Also used : TestingServer(org.apache.curator.test.TestingServer) BeforeClass(org.junit.BeforeClass)

Example 19 with TestingServer

use of org.apache.curator.test.TestingServer in project hive by apache.

the class TestZookeeperLockManager method setup.

@Before
public void setup() {
    conf = new HiveConf();
    lockObjData = new HiveLockObjectData("1", "10", "SHARED", "show tables", conf);
    hiveLock = new HiveLockObject(TABLE, lockObjData);
    zLock = new ZooKeeperHiveLock(TABLE_LOCK_PATH, hiveLock, HiveLockMode.SHARED);
    while (server == null) {
        try {
            server = new TestingServer();
            CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();
            client = builder.connectString(server.getConnectString()).retryPolicy(new RetryOneTime(1)).build();
            client.start();
        } catch (Exception e) {
            System.err.println("Getting bind exception - retrying to allocate server");
            server = null;
        }
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) HiveLockObject(org.apache.hadoop.hive.ql.lockmgr.HiveLockObject) RetryOneTime(org.apache.curator.retry.RetryOneTime) CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) HiveLockObjectData(org.apache.hadoop.hive.ql.lockmgr.HiveLockObject.HiveLockObjectData) HiveConf(org.apache.hadoop.hive.conf.HiveConf) KeeperException(org.apache.zookeeper.KeeperException) Before(org.junit.Before)

Example 20 with TestingServer

use of org.apache.curator.test.TestingServer 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();
}
Also used : TestingServer(org.apache.curator.test.TestingServer) CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) StreamStoreFactory(io.pravega.controller.store.stream.StreamStoreFactory) StreamImpl(io.pravega.client.stream.impl.StreamImpl) SegmentHelper(io.pravega.controller.server.SegmentHelper) RetentionPolicy(io.pravega.client.stream.RetentionPolicy) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) Lists(com.google.common.collect.Lists) TaskMetadataStore(io.pravega.controller.store.task.TaskMetadataStore) TestingServerStarter(io.pravega.test.common.TestingServerStarter) Stream(io.pravega.client.stream.Stream) Duration(java.time.Duration) After(org.junit.After) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TestingServer(org.apache.curator.test.TestingServer) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) HostMonitorConfigImpl(io.pravega.controller.store.host.impl.HostMonitorConfigImpl) RetryHelper(io.pravega.controller.util.RetryHelper) Before(org.junit.Before) SegmentHelperMock(io.pravega.controller.mocks.SegmentHelperMock) Executor(java.util.concurrent.Executor) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) HostStoreFactory(io.pravega.controller.store.host.HostStoreFactory) Executors(java.util.concurrent.Executors) List(java.util.List) TaskStoreFactory(io.pravega.controller.store.task.TaskStoreFactory) CuratorFramework(org.apache.curator.framework.CuratorFramework) ConnectionFactoryImpl(io.pravega.client.netty.impl.ConnectionFactoryImpl) HostControllerStore(io.pravega.controller.store.host.HostControllerStore) Assert.assertFalse(org.junit.Assert.assertFalse) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) ClientConfig(io.pravega.client.ClientConfig) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TestingServerStarter(io.pravega.test.common.TestingServerStarter) TaskMetadataStore(io.pravega.controller.store.task.TaskMetadataStore) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) SegmentHelper(io.pravega.controller.server.SegmentHelper) CuratorFramework(org.apache.curator.framework.CuratorFramework) HostControllerStore(io.pravega.controller.store.host.HostControllerStore) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) ConnectionFactoryImpl(io.pravega.client.netty.impl.ConnectionFactoryImpl) Test(org.junit.Test)

Aggregations

TestingServer (org.apache.curator.test.TestingServer)60 Before (org.junit.Before)23 Test (org.junit.Test)13 TestingServerStarter (io.pravega.test.common.TestingServerStarter)9 Cleanup (lombok.Cleanup)8 BeforeClass (org.junit.BeforeClass)8 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)7 Controller (io.pravega.client.stream.impl.Controller)7 StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)7 PravegaConnectionListener (io.pravega.segmentstore.server.host.handler.PravegaConnectionListener)7 ServiceBuilder (io.pravega.segmentstore.server.store.ServiceBuilder)7 File (java.io.File)7 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 CuratorFramework (org.apache.curator.framework.CuratorFramework)7 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)7 RetryOneTime (org.apache.curator.retry.RetryOneTime)6 ConnectionFactoryImpl (io.pravega.client.netty.impl.ConnectionFactoryImpl)5 Stream (io.pravega.client.stream.Stream)5 StreamImpl (io.pravega.client.stream.impl.StreamImpl)5