You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by ev...@apache.org on 2019/08/09 04:13:37 UTC

[bigtop] branch master updated: BIGTOP-3168: Kafka smoke tests implementation (#537)

This is an automated email from the ASF dual-hosted git repository.

evansye pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bigtop.git


The following commit(s) were added to refs/heads/master by this push:
     new 8aca335  BIGTOP-3168: Kafka smoke tests implementation (#537)
8aca335 is described below

commit 8aca335bab0955273b38069457ee8162ef5aaa26
Author: Yuqi <yu...@arm.com>
AuthorDate: Fri Aug 9 12:13:32 2019 +0800

    BIGTOP-3168: Kafka smoke tests implementation (#537)
    
    * BIGTOP-3168: Kafka smoke tests implementation
    
    Add Kafka smoke tests.
    
    Change-Id: I19fe02fa74bab2c539e2e9aca62b8940927471da
    Signed-off-by: Yuqi Gu <yu...@arm.com>
    
    * Remove 'ZK Server start' and 'Kafka server start'
    
    Change-Id: I50a7ccae5249a816772e0dce7ff0c294582d1001
    
    * Delete kafka topics
    
    Change-Id: Icdf1e9590b8e38ff7a3ddca14dc20ecf5fd02341
    Signed-off-by: Yuqi Gu <yu...@arm.com>
    
    * Keep broker unchanged.
    
    Change-Id: I351592cf37af6b2b755f326b1d01a2c2a9a41b77
---
 .../smoke-tests/kafka/TestKafkaSmoke.groovy        | 65 ++++++++++++++++++++++
 bigtop-tests/smoke-tests/kafka/build.gradle        | 35 ++++++++++++
 provisioner/utils/smoke-tests.sh                   |  1 +
 3 files changed, 101 insertions(+)

diff --git a/bigtop-tests/smoke-tests/kafka/TestKafkaSmoke.groovy b/bigtop-tests/smoke-tests/kafka/TestKafkaSmoke.groovy
new file mode 100644
index 0000000..9dafd47
--- /dev/null
+++ b/bigtop-tests/smoke-tests/kafka/TestKafkaSmoke.groovy
@@ -0,0 +1,65 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.bigtop.itest.kafka
+
+import org.junit.BeforeClass
+import org.junit.AfterClass
+import org.apache.bigtop.itest.shell.Shell
+import static org.junit.Assert.assertNotNull
+import static org.junit.Assert.assertTrue
+import org.junit.Test
+import org.apache.bigtop.itest.JarContent
+import org.apache.bigtop.itest.TestUtils
+import org.junit.runner.RunWith
+
+class TestKafkaSmoke {
+  static Shell sh = new Shell("/bin/bash -s");
+
+  static final String KAFKA_HOME = "/usr/lib/kafka"
+  static final String KAFKA_CONFIG = KAFKA_HOME + "/config/server.properties "
+  static final String KAFKA_TOPICS = KAFKA_HOME + "/bin/kafka-topics.sh "
+  static final String KAFKA_SERVER_START = KAFKA_HOME + "/bin/kafka-server-start.sh "
+  static final String KAFKA_SERVER_STOP = KAFKA_HOME + "/bin/kafka-server-stop.sh "
+
+  @BeforeClass
+  static void kafkaSetUp() {
+    /* Restart kafka server for Enabling 'delete.topic.enable' */
+    sh.exec(KAFKA_SERVER_STOP);
+    sh.exec(KAFKA_SERVER_START + KAFKA_CONFIG
+      + " --override delete.topic.enable=true &"
+    );
+    assertTrue("Restart Kafka server failed. ", sh.getRet() == 0);
+  }
+
+  @AfterClass
+  public static void deleteKafkaTopics() {
+    sh.exec(KAFKA_TOPICS
+      + " --zookeeper localhost:2181"
+      + " --delete --topic test"
+    );
+    assertTrue("Delete Kafka topics failed. ", sh.getRet() == 0);
+  }
+
+  @Test
+  public void testCreateTopics() {
+    sh.exec(KAFKA_TOPICS + " --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test");
+    sh.exec(KAFKA_TOPICS + " --list --zookeeper localhost:2181");
+    assertTrue(" Create Kafka topics failed. " + sh.getOut() + " " + sh.getErr(), sh.getRet() == 0);
+  }
+}
diff --git a/bigtop-tests/smoke-tests/kafka/build.gradle b/bigtop-tests/smoke-tests/kafka/build.gradle
new file mode 100644
index 0000000..cc7fa65
--- /dev/null
+++ b/bigtop-tests/smoke-tests/kafka/build.gradle
@@ -0,0 +1,35 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ */
+def tests_to_include() {
+  return [
+      "TestKafkaSmoke.groovy"
+  ];
+}
+
+sourceSets {
+  test {
+    groovy {
+      srcDirs = ["${BIGTOP_HOME}/bigtop-tests/smoke-tests/kafka/"]
+      exclude { FileTreeElement elem -> (doExclude(elem.getName())) }
+    }
+  }
+}
+
+test.doFirst {
+  checkEnv(["KAFKA_HOME"])
+}
diff --git a/provisioner/utils/smoke-tests.sh b/provisioner/utils/smoke-tests.sh
index 1ef75ce..43b3ff2 100755
--- a/provisioner/utils/smoke-tests.sh
+++ b/provisioner/utils/smoke-tests.sh
@@ -50,6 +50,7 @@ export ZOOKEEPER_HOME=${ZOOKEEPER_HOME:-/usr/lib/zookeeper}
 export GIRAPH_HOME=${GIRAPH_HOME:-/usr/lib/giraph}
 export FLINK_HOME=${FLINK_HOME:-/usr/lib/flink}
 export LIVY_HOME=${LIVY_HOME:-/usr/lib/livy}
+export KAFKA_HOME=${KAFKA_HOME:-/usr/lib/kafka}
 
 echo -e "\n===== START TO RUN SMOKE TESTS: $SMOKE_TESTS =====\n"