-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add integration tests for kafka ingestion #9724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fe95b67
eee3465
3cd2135
8714cff
2c97efd
8a737c5
e12449d
fae658f
3383730
29c39cf
3f7e05e
d0a8c1a
9febc08
6db038e
fcbfcc2
f31dc7b
47d3f62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -233,11 +233,6 @@ | |
| <groupId>com.google.guava</groupId> | ||
| <artifactId>guava</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.101tec</groupId> | ||
| <artifactId>zkclient</artifactId> | ||
| <version>0.10</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>javax.validation</groupId> | ||
| <artifactId>validation-api</artifactId> | ||
|
|
@@ -304,21 +299,6 @@ | |
| <artifactId>easymock</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.kafka</groupId> | ||
| <artifactId>kafka_2.12</artifactId> | ||
| <version>${apache.kafka.version}</version> | ||
| <exclusions> | ||
| <exclusion> | ||
| <artifactId>log4j</artifactId> | ||
| <groupId>log4j</groupId> | ||
| </exclusion> | ||
| <exclusion> | ||
| <artifactId>slf4j-log4j12</artifactId> | ||
| <groupId>org.slf4j</groupId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
|
|
@@ -367,6 +347,8 @@ | |
| <id>integration-tests</id> | ||
| <properties> | ||
| <start.hadoop.docker>false</start.hadoop.docker> | ||
| <skip.start.docker>false</skip.start.docker> | ||
| <skip.stop.docker>false</skip.stop.docker> | ||
| <override.config.path></override.config.path> | ||
| <resource.file.dir.path></resource.file.dir.path> | ||
| </properties> | ||
|
|
@@ -385,6 +367,7 @@ | |
| <configuration> | ||
| <environmentVariables> | ||
| <DRUID_INTEGRATION_TEST_START_HADOOP_DOCKER>${start.hadoop.docker}</DRUID_INTEGRATION_TEST_START_HADOOP_DOCKER> | ||
| <DRUID_INTEGRATION_TEST_SKIP_START_DOCKER>${skip.start.docker}</DRUID_INTEGRATION_TEST_SKIP_START_DOCKER> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| <DRUID_INTEGRATION_TEST_JVM_RUNTIME>${jvm.runtime}</DRUID_INTEGRATION_TEST_JVM_RUNTIME> | ||
| <DRUID_INTEGRATION_TEST_GROUP>${groups}</DRUID_INTEGRATION_TEST_GROUP> | ||
| <DRUID_INTEGRATION_TEST_OVERRIDE_CONFIG_PATH>${override.config.path}</DRUID_INTEGRATION_TEST_OVERRIDE_CONFIG_PATH> | ||
|
|
@@ -400,6 +383,9 @@ | |
| </goals> | ||
| <phase>post-integration-test</phase> | ||
| <configuration> | ||
| <environmentVariables> | ||
| <DRUID_INTEGRATION_TEST_SKIP_STOP_DOCKER>${skip.stop.docker}</DRUID_INTEGRATION_TEST_SKIP_STOP_DOCKER> | ||
| </environmentVariables> | ||
| <executable>${project.basedir}/stop_cluster.sh</executable> | ||
| </configuration> | ||
| </execution> | ||
|
|
@@ -419,12 +405,6 @@ | |
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <properties> | ||
| <property> | ||
| <name>testrunfactory</name> | ||
| <value>org.testng.DruidTestRunnerFactory</value> | ||
| </property> | ||
| </properties> | ||
| <argLine> | ||
| -Duser.timezone=UTC | ||
| -Dfile.encoding=UTF-8 | ||
|
|
@@ -477,12 +457,6 @@ | |
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <properties> | ||
| <property> | ||
| <name>testrunfactory</name> | ||
| <value>org.testng.DruidTestRunnerFactory</value> | ||
| </property> | ||
| </properties> | ||
| <argLine> | ||
| -Duser.timezone=UTC | ||
| -Dfile.encoding=UTF-8 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| /* | ||
| * 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.druid.testing.utils; | ||
|
|
||
| import com.google.common.collect.ImmutableList; | ||
| import org.apache.kafka.clients.admin.AdminClient; | ||
| import org.apache.kafka.clients.admin.AdminClientConfig; | ||
| import org.apache.kafka.clients.admin.CreatePartitionsResult; | ||
| import org.apache.kafka.clients.admin.CreateTopicsResult; | ||
| import org.apache.kafka.clients.admin.DeleteTopicsResult; | ||
| import org.apache.kafka.clients.admin.DescribeTopicsResult; | ||
| import org.apache.kafka.clients.admin.NewPartitions; | ||
| import org.apache.kafka.clients.admin.NewTopic; | ||
| import org.apache.kafka.clients.admin.TopicDescription; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Properties; | ||
|
|
||
| public class KafkaAdminClient implements StreamAdminClient | ||
| { | ||
| private AdminClient adminClient; | ||
|
|
||
| public KafkaAdminClient(String kafkaInternalHost) | ||
| { | ||
| Properties config = new Properties(); | ||
| config.setProperty(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaInternalHost); | ||
| adminClient = AdminClient.create(config); | ||
| } | ||
|
|
||
| @Override | ||
| public void createStream(String streamName, int partitionCount, Map<String, String> tags) throws Exception | ||
| { | ||
| final short replicationFactor = 1; | ||
| final NewTopic newTopic = new NewTopic(streamName, partitionCount, replicationFactor); | ||
| final CreateTopicsResult createTopicsResult = adminClient.createTopics(Collections.singleton(newTopic)); | ||
| // Wait for create topic to compelte | ||
| createTopicsResult.values().get(streamName).get(); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteStream(String streamName) throws Exception | ||
| { | ||
| DeleteTopicsResult deleteTopicsResult = adminClient.deleteTopics(ImmutableList.of(streamName)); | ||
| deleteTopicsResult.values().get(streamName).get(); | ||
| } | ||
|
|
||
| /** | ||
| * This method can only increase the partition count of {@param streamName} to have a final partition | ||
| * count of {@param newPartitionCount} | ||
| * If {@param blocksUntilStarted} is set to true, then this method will blocks until the partitioning | ||
| * started (but not nessesary finished), otherwise, the method will returns right after issue the | ||
| * repartitioning command | ||
| */ | ||
| @Override | ||
| public void updatePartitionCount(String streamName, int newPartitionCount, boolean blocksUntilStarted) throws Exception | ||
| { | ||
| Map<String, NewPartitions> counts = new HashMap<>(); | ||
| counts.put(streamName, NewPartitions.increaseTo(newPartitionCount)); | ||
| CreatePartitionsResult createPartitionsResult = adminClient.createPartitions(counts); | ||
| if (blocksUntilStarted) { | ||
| createPartitionsResult.values().get(streamName).get(); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Stream state such as active/non-active does not applies to Kafka. | ||
| * Returning true since Kafka stream is always active and can always be writen and read to. | ||
| */ | ||
| @Override | ||
| public boolean isStreamActive(String streamName) | ||
| { | ||
| return true; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does "active stream" mean for Kafka?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't means anything but since it implement the interface it needs the method. Added comment. |
||
| } | ||
|
|
||
| @Override | ||
| public int getStreamPartitionCount(String streamName) throws Exception | ||
| { | ||
| DescribeTopicsResult result = adminClient.describeTopics(ImmutableList.of(streamName)); | ||
| TopicDescription topicDescription = result.values().get(streamName).get(); | ||
| return topicDescription.partitions().size(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean verfiyPartitionCountUpdated(String streamName, int oldPartitionCount, int newPartitionCount) throws Exception | ||
| { | ||
| return getStreamPartitionCount(streamName) == newPartitionCount; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
AllParallelizedTestsparallelize tests in a single class? Or can it parallelize across classes? Probably worth mentioning here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only "methods inside the test cases are executed in parallel". Updated.