Skip to content

Instantly share code, notes, and snippets.

@sheeley
Created May 27, 2015 15:39
Show Gist options
  • Save sheeley/d40075c97341cb508ba9 to your computer and use it in GitHub Desktop.
Save sheeley/d40075c97341cb508ba9 to your computer and use it in GitHub Desktop.
Curator + Kafka Unit Test
TestingServer ts = new TestingServer();
int port = TestUtils.choosePort();
Properties props = TestUtils.createBrokerConfig(0, port, false);
props.put("chroot", testChroot);
props.put("zookeeper.connect", connectString);
props.put("log.dir", KAFKA_TMP_DIR);
KafkaConfig config = new KafkaConfig(props);
Time mock = new MockTime();
KafkaServer kss = TestUtils.createServer(config, mock);
Seq<KafkaServer> servers = JavaConversions.asScalaBuffer(ImmutableList.of(kss));
ZkClient zkClient =
new ZkClient(connectString, 30000, 30000, kafka.utils.ZKStringSerializer$.MODULE$);
TestUtils.createTopic(zkClient, topic, TestUtils.createTopic$default$3(),
TestUtils.createTopic$default$4(), servers, TestUtils.createTopic$default$6());
TestUtils.waitUntilMetadataIsPropagated(servers, topic, 0, 10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment