abstractdog commented on code in PR #4540: URL: https://github.com/apache/hive/pull/4540#discussion_r1478142951
########## kafka-handler/src/test/org/apache/hadoop/hive/kafka/KafkaStorageHandlerInfoTest.java: ########## @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hive.kafka; + +import org.apache.hadoop.conf.Configuration; +import org.apache.kafka.clients.consumer.ConsumerConfig; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.apache.kafka.common.serialization.ByteArrayDeserializer; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.charset.Charset; +import java.util.List; +import java.util.Properties; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class KafkaStorageHandlerInfoTest { + private static final Logger LOG = LoggerFactory.getLogger(KafkaStorageHandlerInfoTest.class); + + private static final int RECORD_NUMBER = 17384; + private static final String TOPIC = "TEST1"; + private static final byte[] KEY_BYTES = "KEY".getBytes(Charset.forName("UTF-8")); + private static final KafkaBrokerResource KAFKA_BROKER_RESOURCE = new KafkaBrokerResource(); + + private static List<ConsumerRecord<byte[], byte[]>> getRecords(String topic) { + return IntStream.range(0, RECORD_NUMBER).mapToObj(number -> { + final byte[] value = ("VALUE-" + Integer.toString(number)).getBytes(Charset.forName("UTF-8")); + return new ConsumerRecord<>(topic, 0, (long) number, 0L, null, 0L, 0, 0, KEY_BYTES, value); + }).collect(Collectors.toList()); + } + private final Configuration conf = new Configuration(); + private KafkaConsumer<byte[], byte[]> consumer; + + private Properties consumerProps; + + private static final String RESULT = "Partition(topic = TEST1, partition = 0, leader = 0, replicas = [0], isr = [0], offlineReplicas = [])" + + " [start offset = [0], end offset = [" + RECORD_NUMBER + "]]"; + + @BeforeClass + public static void setupCluster() throws Throwable { + KAFKA_BROKER_RESOURCE.before(); + sendData(); + } + + @AfterClass + public static void tearDownCluster() { + KAFKA_BROKER_RESOURCE.deleteTopic(TOPIC); + KAFKA_BROKER_RESOURCE.after(); + } + + @Before + public void setUp() { + LOG.info("setting up Config"); + setupConsumer(); + } + + @After + public void tearDown() { + consumer.close(); + LOG.info("tearDown"); Review Comment: nit: this looks to be a debug thing to me instead of info, or you can remove it, I can rarely see unit test lifecycle-related logs without further context -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org