aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryeongeon <yeongeon@gmail.com>2015-12-17 11:31:22 +0900
committerKonstantin Boudnik <cos@apache.org>2016-01-29 17:04:30 -0800
commit6b88f2c32aa22a286c160a15251a7d636497bffd (patch)
tree414a8f9b01bcb66e583cfd248520d30ed5400f67
parent0c0091e535d5c799dd6db404cffe8859fd234852 (diff)
downloadbigtop-odpi-6b88f2c32aa22a286c160a15251a7d636497bffd.tar.gz
BIGTOP-2180: Add smoke-test scripts using gradle for Apache Tajo.
Signed-off-by: Konstantin Boudnik <cos@apache.org>
-rw-r--r--bigtop-tests/smoke-tests/README1
-rw-r--r--bigtop-tests/smoke-tests/tajo/TestTajo.groovy116
-rw-r--r--bigtop-tests/smoke-tests/tajo/build.gradle39
-rw-r--r--bigtop-tests/smoke-tests/tajo/table1/data.csv5
-rw-r--r--build.gradle1
5 files changed, 162 insertions, 0 deletions
diff --git a/bigtop-tests/smoke-tests/README b/bigtop-tests/smoke-tests/README
index 430d03b2..67ed7ea3 100644
--- a/bigtop-tests/smoke-tests/README
+++ b/bigtop-tests/smoke-tests/README
@@ -27,6 +27,7 @@ export JAVA_HOME="/usr/lib/jvm/java-openjdk/"
export MAHOUT_HOME="/usr/lib/mahout"
export KITE_HOME="/usr/lib/kite"
export SPARK_HOME="/usr/lib/spark"
+export TAJO_HOME="/usr/lib/tajo"
```
Then, simply invoke the tests you want to run, as described below.
diff --git a/bigtop-tests/smoke-tests/tajo/TestTajo.groovy b/bigtop-tests/smoke-tests/tajo/TestTajo.groovy
new file mode 100644
index 00000000..128e0772
--- /dev/null
+++ b/bigtop-tests/smoke-tests/tajo/TestTajo.groovy
@@ -0,0 +1,116 @@
+/**
+ * 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.tajo
+
+import org.junit.BeforeClass
+import org.junit.AfterClass
+import org.junit.FixMethodOrder
+import org.junit.runners.MethodSorters
+import org.junit.Test
+
+import org.apache.bigtop.itest.shell.Shell
+import static org.apache.bigtop.itest.LogErrorsUtils.logError
+import org.apache.commons.logging.LogFactory
+import org.apache.commons.logging.Log
+
+import java.sql.*
+
+import static org.junit.Assert.assertEquals
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class TestTajo {
+ static private Log LOG = LogFactory.getLog(Object.class)
+
+ static Shell sh = new Shell("/bin/bash -s")
+ static String pwd = ""
+
+ static Connection conn = null
+ static Statement stmt = null
+ static ResultSet rs = null
+
+ @BeforeClass
+ static void setUp() {
+ try {
+ Class.forName("org.apache.tajo.jdbc.TajoDriver")
+ } catch (ClassNotFoundException e) {
+ logError(e)
+ }
+
+ String url = "jdbc:tajo://localhost/default"
+ conn = DriverManager.getConnection(url)
+ stmt = conn.createStatement()
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ dropTable()
+ if (stmt != null) stmt.close()
+ if (conn != null) conn.close()
+ }
+
+ static void dropTable() {
+ stmt.executeQuery("drop table if exists table1")
+ }
+
+ @Test
+ void test1CreateSQL() {
+ try {
+ sh.exec("pwd")
+ pwd = sh.out
+ int lastIndex = pwd.length() - 1
+ pwd = pwd.substring(1, lastIndex)
+
+ String query = "create external table if not exists table1 (" +
+ " id int," +
+ " name text," +
+ " score float," +
+ " type text)" +
+ " using text with ('text.delimiter'='|') location 'file://"+ pwd +"/table1'"
+ LOG.info(query)
+ rs = stmt.executeQuery(query)
+ while (rs.next()) {
+ LOG.info(rs.getString(1) + "," + rs.getString(3))
+ }
+ } finally {
+ if (rs != null) rs.close()
+ }
+ }
+
+ @Test
+ void test2SelectSQL() {
+ StringBuffer answer = new StringBuffer()
+ StringBuffer correct = new StringBuffer()
+ correct.append("1,1.1")
+ correct.append("2,2.3")
+ correct.append("3,3.4")
+ correct.append("4,4.5")
+ correct.append("5,5.6")
+ try {
+ rs = stmt.executeQuery("select * from table1")
+ while (rs.next()) {
+ String str = rs.getString(1) + "," + rs.getString(3)
+ LOG.info(str)
+ answer.append(str)
+ }
+ } finally {
+ if (rs != null) rs.close()
+ }
+ assertEquals(answer.toString(), correct.toString())
+ }
+}
diff --git a/bigtop-tests/smoke-tests/tajo/build.gradle b/bigtop-tests/smoke-tests/tajo/build.gradle
new file mode 100644
index 00000000..2ed9085b
--- /dev/null
+++ b/bigtop-tests/smoke-tests/tajo/build.gradle
@@ -0,0 +1,39 @@
+/**
+ * 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.
+ */
+
+dependencies {
+ testCompile group: 'org.apache.tajo', name:'tajo-jdbc', version:'0.11.0'
+}
+
+
+def tests_to_include() {
+ return ["TestTajo.groovy"];
+}
+
+sourceSets {
+ test {
+ groovy {
+ srcDirs = ["./"]
+ exclude { FileTreeElement elem -> (doExclude(elem.getName())) }
+ }
+ }
+}
+
+test.doFirst {
+ checkEnv(["TAJO_HOME"])
+}
diff --git a/bigtop-tests/smoke-tests/tajo/table1/data.csv b/bigtop-tests/smoke-tests/tajo/table1/data.csv
new file mode 100644
index 00000000..cd469fa2
--- /dev/null
+++ b/bigtop-tests/smoke-tests/tajo/table1/data.csv
@@ -0,0 +1,5 @@
+1|abc|1.1|a
+2|def|2.3|b
+3|ghi|3.4|c
+4|jkl|4.5|d
+5|mno|5.6|e \ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 07e38367..a7b5cc8d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -79,6 +79,7 @@ rat {
"bigtop-tests/smoke-tests/phoenix/*.csv",
"bigtop-tests/smoke-tests/phoenix/*.sql",
"bigtop-tests/smoke-tests/ignite-hadoop/*.data",
+ "bigtop-tests/smoke-tests/tajo/table1/*.csv",
"**/target/**",
"**/build/**",
"**/.gradle/**",