private static TestingServer createTestingServer() throws Exception { while (true) { try { return new TestingServer(); } catch (final BindException e) { /* There is a race condition in TestingServer between the point it picks a random port and the time it binds to the random port. This occasionally results in a BindException. When this happens... retry! */ log.info("Failed to create test ZK instance due to known race condition. Will retry"); } } } }
@Override public void start() { log.info("starting zookeeper TestingServer at port={}, dataDir={}", port, dataDir); try { server = new TestingServer(port, dataDir); awaitUp(2, MINUTES); } catch (Exception e) { Throwables.throwIfUnchecked(e); throw new RuntimeException(e); } }
@BeforeClass public void setUp() throws Exception { testingServer = new TestingServer(-1); }
@BeforeClass public static void setup() throws Exception { zkServer = new TestingServer(true); }
TestingServer zkTestServer; @Before public void startZookeeper() throws Exception { zkTestServer = new TestingServer(2181); cli = CuratorFrameworkFactory.newClient(zkTestServer.getConnectString(), new RetryOneTime(2000)); } @After public void stopZookeeper() throws IOException { cli.close(); zkTestServer.stop(); }
private void initZooKeeper() throws Exception { this.testingZKServer = new TestingServer(false); log.info( "Created testing ZK Server. Connection string : " + testingZKServer.getConnectString()); }
public void setUp() throws Exception { // setup ZK zookeeper = new TestingServer(true); // setup Broker kafkaDir = new TmpPath(Files.createTempDirectory("kafka-").toAbsolutePath().toString()); Properties brokerProps = new Properties(); brokerProps.setProperty("zookeeper.connect", zookeeper.getConnectString()); brokerProps.setProperty("broker.id", "0"); brokerProps.setProperty("log.dirs", kafkaDir.getPath()); brokerProps.setProperty("listeners", String.format("PLAINTEXT://%s:%d", KAFKA_HOST, KAFKA_PORT)); brokerProps.setProperty("offsets.topic.replication.factor", "1"); KafkaConfig config = new KafkaConfig(brokerProps); MockTime mock = new MockTime(); kafkaServer = TestUtils.createServer(config, mock); // setup default Producer createProducer(); kafkaAdminClient = AdminClient.create(Collections.singletonMap(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, KAFKA_HOST + ":" + KAFKA_PORT)); }
protected void setupServerAndCurator() throws Exception { server = new TestingServer(); timing = new Timing(); curator = CuratorFrameworkFactory .builder() .connectString(server.getConnectString()) .sessionTimeoutMs(timing.session()) .connectionTimeoutMs(timing.connection()) .retryPolicy(new RetryOneTime(1)) .compressionProvider(new PotentiallyGzippedCompressionProvider(true)) .build(); }
private void setupServerAndCurator() throws Exception { server = new TestingServer(); timing = new Timing(); curator = CuratorFrameworkFactory .builder() .connectString(server.getConnectString()) .sessionTimeoutMs(timing.session()) .connectionTimeoutMs(timing.connection()) .retryPolicy(new RetryOneTime(1)) .compressionProvider(new PotentiallyGzippedCompressionProvider(true)) .build(); }
@BeforeClass public static void setup() throws Exception { zkServer = new TestingServer(); storageDir = FOLDER.newFolder().getAbsolutePath(); // startYARNWithConfig should be implemented by subclass YARN_CONFIGURATION.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, ResourceScheduler.class); YARN_CONFIGURATION.set(YarnTestBase.TEST_CLUSTER_NAME_KEY, LOG_DIR); YARN_CONFIGURATION.setInt(YarnConfiguration.NM_PMEM_MB, 4096); startYARNWithConfig(YARN_CONFIGURATION); }
@Before public void setUp() throws Exception { // Start ZooKeeper server if not done already. if (zkServer == null) { zkServer = new TestingServer(); // Add ZK specific configurations, so that the metastore can register itself to ZK when // started. MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, zkServer.getConnectString()); MetastoreConf.setVar(conf, ConfVars.THRIFT_ZOOKEEPER_NAMESPACE, this.getClass().getSimpleName()); MetastoreConf.setVar(conf, ConfVars.THRIFT_SERVICE_DISCOVERY_MODE, "zookeeper"); } super.setUp(); }
@Test public void testExternalizedFSCheckpointsWithLocalRecoveryZookeeper() throws Exception { TestingServer zkServer = new TestingServer(); zkServer.start(); try { final File checkpointDir = temporaryFolder.newFolder(); testExternalizedCheckpoints( checkpointDir, zkServer.getConnectString(), createFsStateBackend(checkpointDir), true); } finally { zkServer.stop(); } }
@Test public void testExternalizedIncrementalRocksDBCheckpointsZookeeper() throws Exception { TestingServer zkServer = new TestingServer(); zkServer.start(); try { final File checkpointDir = temporaryFolder.newFolder(); testExternalizedCheckpoints( checkpointDir, zkServer.getConnectString(), createRocksDBStateBackend(checkpointDir, true), false); } finally { zkServer.stop(); } }
@Test public void testExternalizedFullRocksDBCheckpointsWithLocalRecoveryZookeeper() throws Exception { TestingServer zkServer = new TestingServer(); zkServer.start(); try { final File checkpointDir = temporaryFolder.newFolder(); testExternalizedCheckpoints( checkpointDir, zkServer.getConnectString(), createRocksDBStateBackend(checkpointDir, false), true); } finally { zkServer.stop(); } }
@Test public void testExternalizedFullRocksDBCheckpointsZookeeper() throws Exception { TestingServer zkServer = new TestingServer(); zkServer.start(); try { final File checkpointDir = temporaryFolder.newFolder(); testExternalizedCheckpoints( checkpointDir, zkServer.getConnectString(), createRocksDBStateBackend(checkpointDir, false), false); } finally { zkServer.stop(); } }
@Test public void testExternalizedIncrementalRocksDBCheckpointsWithLocalRecoveryZookeeper() throws Exception { TestingServer zkServer = new TestingServer(); zkServer.start(); try { final File checkpointDir = temporaryFolder.newFolder(); testExternalizedCheckpoints( checkpointDir, zkServer.getConnectString(), createRocksDBStateBackend(checkpointDir, true), true); } finally { zkServer.stop(); } }
@Test public void testExternalizedFSCheckpointsZookeeper() throws Exception { TestingServer zkServer = new TestingServer(); zkServer.start(); try { final File checkpointDir = temporaryFolder.newFolder(); testExternalizedCheckpoints( checkpointDir, zkServer.getConnectString(), createFsStateBackend(checkpointDir), false); } finally { zkServer.stop(); } }
@Test public void testNimbodesWithLatestVersionOfBlob() throws Exception { try (TestingServer server = new TestingServer(); CuratorFramework zkClient = CuratorFrameworkFactory .newClient(server.getConnectString(), new ExponentialBackoffRetry(1000, 3))) { zkClient.start(); // Creating nimbus hosts containing latest version of blob zkClient.create().creatingParentContainersIfNeeded().forPath("/blobstore/key1/nimbus1:7800-1"); zkClient.create().creatingParentContainersIfNeeded().forPath("/blobstore/key1/nimbus2:7800-2"); Set<NimbusInfo> set = BlobStoreUtils.getNimbodesWithLatestSequenceNumberOfBlob(zkClient, "key1"); assertEquals("Failed to get the correct nimbus hosts with latest blob version", (set.iterator().next()).getHost(), "nimbus2"); zkClient.delete().deletingChildrenIfNeeded().forPath("/blobstore/key1/nimbus1:7800-1"); zkClient.delete().deletingChildrenIfNeeded().forPath("/blobstore/key1/nimbus2:7800-2"); } }
@BeforeClass public static void setup() throws Exception { zkServer = new TestingServer(); // we have to manage this manually because we have to create the ZooKeeper server // ahead of this miniClusterResource = new MiniClusterWithClientResource( new MiniClusterResourceConfiguration.Builder() .setConfiguration(getConfig()) .setNumberTaskManagers(NUM_TMS) .setNumberSlotsPerTaskManager(NUM_SLOTS_PER_TM) .build()); miniClusterResource.before(); client = new QueryableStateClient("localhost", QS_PROXY_PORT_RANGE_START); clusterClient = miniClusterResource.getClusterClient(); }
@BeforeClass public static void setup() throws Exception { zkServer = new TestingServer(); // we have to manage this manually because we have to create the ZooKeeper server // ahead of this miniClusterResource = new MiniClusterWithClientResource( new MiniClusterResourceConfiguration.Builder() .setConfiguration(getConfig()) .setNumberTaskManagers(NUM_TMS) .setNumberSlotsPerTaskManager(NUM_SLOTS_PER_TM) .build()); miniClusterResource.before(); client = new QueryableStateClient("localhost", QS_PROXY_PORT_RANGE_START); clusterClient = miniClusterResource.getClusterClient(); }