Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 92CEB200D55 for ; Sat, 9 Dec 2017 19:38:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 91421160C0E; Sat, 9 Dec 2017 18:38:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 90E9B160BFE for ; Sat, 9 Dec 2017 19:38:05 +0100 (CET) Received: (qmail 21849 invoked by uid 500); 9 Dec 2017 18:38:04 -0000 Mailing-List: contact jira-help@kafka.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jira@kafka.apache.org Delivered-To: mailing list jira@kafka.apache.org Received: (qmail 21838 invoked by uid 99); 9 Dec 2017 18:38:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Dec 2017 18:38:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 544671807B2 for ; Sat, 9 Dec 2017 18:38:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 5KWHdIodhW0G for ; Sat, 9 Dec 2017 18:38:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 775FE5F3CC for ; Sat, 9 Dec 2017 18:38:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 75E2CE0732 for ; Sat, 9 Dec 2017 18:38:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 30AEA212F5 for ; Sat, 9 Dec 2017 18:38:00 +0000 (UTC) Date: Sat, 9 Dec 2017 18:38:00 +0000 (UTC) From: "DHRUV BANSAL (JIRA)" To: jira@kafka.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (KAFKA-6339) Integration test with embedded kafka not working MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sat, 09 Dec 2017 18:38:06 -0000 [ https://issues.apache.org/jira/browse/KAFKA-6339?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] DHRUV BANSAL updated KAFKA-6339: -------------------------------- Description: I am using Kafka version - 0.11.0.2 Trying to write an integration test for one of the components I am writing over Kafka. Following code works fine with Kafka version 0.10.0.0 but not working with mentioned version (0.11.0.2) // setup Zookeeper EmbeddedZookeeper embeddedZookeeper = new EmbeddedZookeeper(); String zkConnect = ZKHOST + ":" + embeddedZookeeper.port(); ZkClient zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$); ZkUtils zkUtils = ZkUtils.apply(zkClient, false); // setup Broker Properties brokerProps = new Properties(); brokerProps.setProperty("zookeeper.connect", zkConnect); brokerProps.setProperty("broker.id", "0"); brokerProps.setProperty("offsets.topic.replication.factor", "1"); String kafka_log_path = Files.createTempDirectory("kafka-").toAbsolutePath().toString(); System.out.println("kafka log path " + kafka_log_path); brokerProps.setProperty("log.dirs", kafka_log_path); brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKERHOST + ":" + BROKERPORT); KafkaConfig config = new KafkaConfig(brokerProps); Time mock = new MockTime(); KafkaServer kafkaServer = TestUtils.createServer(config, mock); // create topic AdminUtils.createTopic(zkUtils, TOPIC, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$); // setup producer Properties producerProps = new Properties(); producerProps.setProperty("bootstrap.servers", BROKERHOST + ":" + BROKERPORT); producerProps.setProperty("key.serializer", "org.apache.kafka.common.serialization.IntegerSerializer"); producerProps.setProperty("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); KafkaProducer producer = new KafkaProducer(producerProps); // setup consumer Properties consumerProps = new Properties(); consumerProps.setProperty("bootstrap.servers", BROKERHOST + ":" + BROKERPORT); consumerProps.setProperty("group.id", "group0"); consumerProps.setProperty("client.id", "consumer0"); consumerProps.setProperty("key.deserializer", "org.apache.kafka.common.serialization.IntegerDeserializer"); consumerProps.setProperty("value.deserializer", "org.apache.kafka.common.serialization.ByteArrayDeserializer"); consumerProps.put("auto.offset.reset", "earliest"); // to make sure the consumer starts from the beginning of // the topic KafkaConsumer consumer = new KafkaConsumer<>(consumerProps); consumer.subscribe(Arrays.asList(TOPIC)); // send message ProducerRecord data = new ProducerRecord<>(TOPIC, 42, "test-message".getBytes(StandardCharsets.UTF_8)); Future record = producer.send(data); RecordMetadata metadata = record.get(); // starting consumer ConsumerRecords records = consumer.poll(3000); assertEquals(1, records.count()); Iterator> recordIterator = records.iterator(); ConsumerRecord consumedRecord = recordIterator.next(); System.out.printf("offset = %d, key = %s, value = %s", consumedRecord.offset(), consumedRecord.key(), consumedRecord.value()); assertEquals(42, (int) consumedRecord.key()); assertEquals("test-message", new String(consumedRecord.value(), StandardCharsets.UTF_8)); kafkaServer.shutdown(); zkClient.close(); embeddedZookeeper.shutdown(); Please provide support for the same and there should be proper documentation for the intergration test with each release. was: I am using Kafka version - 0.11.0.2 Trying to write an integration test for one of the components I am writing over Kafka. Following code works fine with Kafka version 0.10.0.0 but not working with mentioned version (0.11.0.2) {{ // setup Zookeeper {{EmbeddedZookeeper embeddedZookeeper = new EmbeddedZookeeper(); String zkConnect = ZKHOST + ":" + embeddedZookeeper.port(); ZkClient zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$); ZkUtils zkUtils = ZkUtils.apply(zkClient, false); }} // setup Broker Properties brokerProps = new Properties(); brokerProps.setProperty("zookeeper.connect", zkConnect); brokerProps.setProperty("broker.id", "0"); brokerProps.setProperty("offsets.topic.replication.factor", "1"); String kafka_log_path = Files.createTempDirectory("kafka-").toAbsolutePath().toString(); System.out.println("kafka log path " + kafka_log_path); brokerProps.setProperty("log.dirs", kafka_log_path); brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKERHOST + ":" + BROKERPORT); KafkaConfig config = new KafkaConfig(brokerProps); Time mock = new MockTime(); KafkaServer kafkaServer = TestUtils.createServer(config, mock); // create topic AdminUtils.createTopic(zkUtils, TOPIC, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$); // setup producer Properties producerProps = new Properties(); producerProps.setProperty("bootstrap.servers", BROKERHOST + ":" + BROKERPORT); producerProps.setProperty("key.serializer", "org.apache.kafka.common.serialization.IntegerSerializer"); producerProps.setProperty("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); KafkaProducer producer = new KafkaProducer(producerProps); // setup consumer Properties consumerProps = new Properties(); consumerProps.setProperty("bootstrap.servers", BROKERHOST + ":" + BROKERPORT); consumerProps.setProperty("group.id", "group0"); consumerProps.setProperty("client.id", "consumer0"); consumerProps.setProperty("key.deserializer", "org.apache.kafka.common.serialization.IntegerDeserializer"); consumerProps.setProperty("value.deserializer", "org.apache.kafka.common.serialization.ByteArrayDeserializer"); consumerProps.put("auto.offset.reset", "earliest"); // to make sure the consumer starts from the beginning of // the topic KafkaConsumer consumer = new KafkaConsumer<>(consumerProps); consumer.subscribe(Arrays.asList(TOPIC)); // send message ProducerRecord data = new ProducerRecord<>(TOPIC, 42, "test-message".getBytes(StandardCharsets.UTF_8)); Future record = producer.send(data); RecordMetadata metadata = record.get(); // starting consumer ConsumerRecords records = consumer.poll(3000); assertEquals(1, records.count()); Iterator> recordIterator = records.iterator(); ConsumerRecord consumedRecord = recordIterator.next(); System.out.printf("offset = %d, key = %s, value = %s", consumedRecord.offset(), consumedRecord.key(), consumedRecord.value()); assertEquals(42, (int) consumedRecord.key()); assertEquals("test-message", new String(consumedRecord.value(), StandardCharsets.UTF_8)); kafkaServer.shutdown(); zkClient.close(); embeddedZookeeper.shutdown(); }} Please provide support for the same and there should be proper documentation for the intergration test with each release. > Integration test with embedded kafka not working > ------------------------------------------------ > > Key: KAFKA-6339 > URL: https://issues.apache.org/jira/browse/KAFKA-6339 > Project: Kafka > Issue Type: Bug > Affects Versions: 0.11.0.2 > Reporter: DHRUV BANSAL > > I am using Kafka version - 0.11.0.2 > Trying to write an integration test for one of the components I am writing over Kafka. > Following code works fine with Kafka version 0.10.0.0 but not working with mentioned version (0.11.0.2) > // setup Zookeeper > EmbeddedZookeeper embeddedZookeeper = new EmbeddedZookeeper(); > String zkConnect = ZKHOST + ":" + embeddedZookeeper.port(); > ZkClient zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$); > ZkUtils zkUtils = ZkUtils.apply(zkClient, false); > // setup Broker > Properties brokerProps = new Properties(); > brokerProps.setProperty("zookeeper.connect", zkConnect); > brokerProps.setProperty("broker.id", "0"); > brokerProps.setProperty("offsets.topic.replication.factor", "1"); > String kafka_log_path = Files.createTempDirectory("kafka-").toAbsolutePath().toString(); > System.out.println("kafka log path " + kafka_log_path); > brokerProps.setProperty("log.dirs", kafka_log_path); > brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKERHOST + ":" + BROKERPORT); > KafkaConfig config = new KafkaConfig(brokerProps); > Time mock = new MockTime(); > KafkaServer kafkaServer = TestUtils.createServer(config, mock); > // create topic > AdminUtils.createTopic(zkUtils, TOPIC, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$); > // setup producer > Properties producerProps = new Properties(); > producerProps.setProperty("bootstrap.servers", BROKERHOST + ":" + BROKERPORT); > producerProps.setProperty("key.serializer", "org.apache.kafka.common.serialization.IntegerSerializer"); > producerProps.setProperty("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); > KafkaProducer producer = new KafkaProducer(producerProps); > // setup consumer > Properties consumerProps = new Properties(); > consumerProps.setProperty("bootstrap.servers", BROKERHOST + ":" + BROKERPORT); > consumerProps.setProperty("group.id", "group0"); > consumerProps.setProperty("client.id", "consumer0"); > consumerProps.setProperty("key.deserializer", "org.apache.kafka.common.serialization.IntegerDeserializer"); > consumerProps.setProperty("value.deserializer", "org.apache.kafka.common.serialization.ByteArrayDeserializer"); > consumerProps.put("auto.offset.reset", "earliest"); // to make sure the consumer starts from the beginning of > // the topic > KafkaConsumer consumer = new KafkaConsumer<>(consumerProps); > consumer.subscribe(Arrays.asList(TOPIC)); > // send message > ProducerRecord data = new ProducerRecord<>(TOPIC, 42, > "test-message".getBytes(StandardCharsets.UTF_8)); > Future record = producer.send(data); > RecordMetadata metadata = record.get(); > // starting consumer > ConsumerRecords records = consumer.poll(3000); > assertEquals(1, records.count()); > Iterator> recordIterator = records.iterator(); > ConsumerRecord consumedRecord = recordIterator.next(); > System.out.printf("offset = %d, key = %s, value = %s", consumedRecord.offset(), consumedRecord.key(), > consumedRecord.value()); > assertEquals(42, (int) consumedRecord.key()); > assertEquals("test-message", new String(consumedRecord.value(), StandardCharsets.UTF_8)); > kafkaServer.shutdown(); > zkClient.close(); > embeddedZookeeper.shutdown(); > Please provide support for the same and there should be proper documentation for the intergration test with each release. -- This message was sent by Atlassian JIRA (v6.4.14#64029)