BIGTOP-3703. Add smoke tests for Ranger. (#1076)
diff --git a/bigtop-tests/smoke-tests/ranger/TestRangerSimple.groovy b/bigtop-tests/smoke-tests/ranger/TestRangerSimple.groovy
new file mode 100644
index 0000000..4401419
--- /dev/null
+++ b/bigtop-tests/smoke-tests/ranger/TestRangerSimple.groovy
@@ -0,0 +1,47 @@
+/**
+ * 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.bigtop.itest.ranger
+
+import groovy.json.JsonSlurper
+import org.junit.Test
+import static org.junit.Assert.assertNotNull
+import static org.junit.Assert.assertTrue
+
+class TestRangerSmoke {
+
+ static String prop(String key) {
+ def value = System.getenv(key)
+ assertNotNull(value)
+ return value
+ }
+
+ def url = "${prop('RANGER_URL')}/service/"
+ def header = ['Authorization':
+ "Basic ${new String(Base64.getEncoder().encode('admin:Admin01234'.getBytes()))}"]
+
+ @Test
+ void testServiceDefs() {
+ def json = new URL(url + 'public/v2/api/servicedef').getText(requestProperties: header)
+ def serviceDefs = new JsonSlurper().parseText(json)
+ assertTrue(0 < serviceDefs.size())
+
+ // Check if some major service definitions were registered through setup
+ def serviceNames = serviceDefs.stream().map{ it.name }.collect()
+ assertTrue(['hdfs', 'hbase', 'hive'].every { serviceNames.contains(it) })
+ }
+}
diff --git a/bigtop-tests/smoke-tests/ranger/build.gradle b/bigtop-tests/smoke-tests/ranger/build.gradle
new file mode 100644
index 0000000..ffd14fa
--- /dev/null
+++ b/bigtop-tests/smoke-tests/ranger/build.gradle
@@ -0,0 +1,33 @@
+/**
+ * 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 junitVersion = '4.13.2'
+dependencies {
+ compile group: 'junit', name: 'junit', version: junitVersion, transitive: 'true'
+}
+
+sourceSets {
+ test {
+ groovy {
+ srcDirs = ["./"]
+ }
+ }
+}
+
+test.doFirst {
+ checkEnv(["RANGER_URL"])
+}
diff --git a/provisioner/utils/smoke-tests.sh b/provisioner/utils/smoke-tests.sh
index d6fdb71..9ce639f 100755
--- a/provisioner/utils/smoke-tests.sh
+++ b/provisioner/utils/smoke-tests.sh
@@ -48,6 +48,7 @@
export LIVY_HOME=${LIVY_HOME:-/usr/lib/livy}
export OOZIE_TAR_HOME=${OOZIE_TAR_HOME:-/usr/lib/oozie}
export OOZIE_URL=${OOZIE_URL:-http://localhost:11000/oozie}
+export RANGER_URL=${RANGER_URL:-http://localhost:6080}
export SPARK_HOME=${SPARK_HOME:-/usr/lib/spark}
export TEZ_HOME=${TEZ_HOME:-/usr/lib/tez}
export WEBHDFS_URL=${WEBHDFS_URL:-$(hostname):50070/webhdfs/v1}