Return-Path: X-Original-To: apmail-tajo-commits-archive@minotaur.apache.org Delivered-To: apmail-tajo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F402F18895 for ; Fri, 4 Mar 2016 02:12:31 +0000 (UTC) Received: (qmail 30123 invoked by uid 500); 4 Mar 2016 02:12:31 -0000 Delivered-To: apmail-tajo-commits-archive@tajo.apache.org Received: (qmail 30084 invoked by uid 500); 4 Mar 2016 02:12:31 -0000 Mailing-List: contact commits-help@tajo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tajo.apache.org Delivered-To: mailing list commits@tajo.apache.org Received: (qmail 30075 invoked by uid 99); 4 Mar 2016 02:12:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Mar 2016 02:12:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C4235DFA42; Fri, 4 Mar 2016 02:12:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jihoonson@apache.org To: commits@tajo.apache.org Message-Id: <4eabe78760264cfeaa4729f27e379bfe@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: tajo git commit: TAJO-2088: Change QueryTestCaseBase.runSimpleTests() to return a set of TajoResultSetBase. Date: Fri, 4 Mar 2016 02:12:31 +0000 (UTC) Repository: tajo Updated Branches: refs/heads/branch-0.11.2 cd1b133a5 -> d75bcd58f TAJO-2088: Change QueryTestCaseBase.runSimpleTests() to return a set of TajoResultSetBase. Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/d75bcd58 Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/d75bcd58 Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/d75bcd58 Branch: refs/heads/branch-0.11.2 Commit: d75bcd58f504a40f0484c8934ee346b22551f5da Parents: cd1b133 Author: Jihoon Son Authored: Fri Mar 4 11:11:59 2016 +0900 Committer: Jihoon Son Committed: Fri Mar 4 11:11:59 2016 +0900 ---------------------------------------------------------------------- CHANGES | 3 ++ .../java/org/apache/tajo/QueryTestCaseBase.java | 35 +++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/d75bcd58/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 90db2c8..ef2ad47 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,9 @@ Release 0.11.2 - unreleased TASKS + TAJO-2088: Change QueryTestCaseBase.runSimpleTests() to return a set of + TajoResultSetBase. (jihoon) + TAJO-2076: Add backward compatibility testing with hadoop on travis. (jinho) TAJO-2074: Upgrade hadoop and netty. (jinho) http://git-wip-us.apache.org/repos/asf/tajo/blob/d75bcd58/tajo-cluster-tests/src/test/java/org/apache/tajo/QueryTestCaseBase.java ---------------------------------------------------------------------- diff --git a/tajo-cluster-tests/src/test/java/org/apache/tajo/QueryTestCaseBase.java b/tajo-cluster-tests/src/test/java/org/apache/tajo/QueryTestCaseBase.java index 179ed36..c62f583 100644 --- a/tajo-cluster-tests/src/test/java/org/apache/tajo/QueryTestCaseBase.java +++ b/tajo-cluster-tests/src/test/java/org/apache/tajo/QueryTestCaseBase.java @@ -19,6 +19,7 @@ package org.apache.tajo; import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; @@ -44,6 +45,7 @@ import org.apache.tajo.exception.TajoException; import org.apache.tajo.exception.UndefinedTableException; import org.apache.tajo.jdbc.FetchResultSet; import org.apache.tajo.jdbc.TajoMemoryResultSet; +import org.apache.tajo.jdbc.TajoResultSetBase; import org.apache.tajo.master.GlobalEngine; import org.apache.tajo.parser.sql.SQLAnalyzer; import org.apache.tajo.plan.LogicalOptimizer; @@ -469,6 +471,7 @@ public class QueryTestCaseBase { boolean withExplainGlobal() default false; boolean parameterized() default false; boolean sort() default false; + boolean resultClose() default true; } private static class DummyQuerySpec implements QuerySpec { @@ -489,17 +492,25 @@ public class QueryTestCaseBase { private final boolean withExplainGlobal; private final boolean parameterized; private final boolean sort; - public DummyOption(boolean explain, boolean withExplainGlobal, boolean parameterized, boolean sort) { + private final boolean resultClose; + public DummyOption(boolean explain, boolean withExplainGlobal, boolean parameterized, boolean sort, + boolean resultClose) { this.explain = explain; this.withExplainGlobal = withExplainGlobal; this.parameterized = parameterized; this.sort = sort; + this.resultClose = resultClose; } public Class annotationType() { return Option.class; } public boolean withExplain() { return explain;} public boolean withExplainGlobal() { return withExplainGlobal;} public boolean parameterized() { return parameterized;} public boolean sort() { return sort;} + + @Override + public boolean resultClose() { + return resultClose; + } } protected Collection getBatchQueries(Collection paths) throws IOException, InvalidStatementException { @@ -558,7 +569,7 @@ public class QueryTestCaseBase { } } - protected void runSimpleTests() throws Exception { + protected Optional runSimpleTests() throws Exception { String methodName = getMethodName(); Method method = current.getTestClass().getMethod(methodName); SimpleTest annotation = method.getAnnotation(SimpleTest.class); @@ -570,7 +581,7 @@ public class QueryTestCaseBase { QuerySpec[] queries = annotation.queries(); Option defaultOption = method.getAnnotation(Option.class); if (defaultOption == null) { - defaultOption = new DummyOption(false, false, false, false); + defaultOption = new DummyOption(false, false, false, false, true); } boolean fromFile = false; @@ -589,6 +600,7 @@ public class QueryTestCaseBase { for (String prepare : prepares) { client.executeQueryAndGetResult(prepare).close(); } + List resultSetBases = new ArrayList<>(); for (int i = 0; i < queries.length; i++) { QuerySpec spec = queries[i]; Option option = spec.override() ? spec.option() : defaultOption; @@ -620,6 +632,7 @@ public class QueryTestCaseBase { testingCluster.getConfiguration().set(TajoConf.ConfVars.$TEST_PLAN_SHAPE_FIX_ENABLED.varname, "false"); ResultSet result = client.executeQueryAndGetResult(spec.value()); + resultSetBases.add((TajoResultSetBase) result); // result test String fileName = methodName + (fromFile ? "" : "." + (i + 1)) + ".result"; @@ -633,7 +646,15 @@ public class QueryTestCaseBase { LOG.info("New test output for " + current.getDisplayName() + " is written to " + resultPath); // should be copied to src directory } - result.close(); + if (option.resultClose()) { + result.close(); + } + } + + if (resultSetBases.size() > 0) { + return Optional.of(resultSetBases.toArray(new TajoResultSetBase[resultSetBases.size()])); + } else { + return Optional.absent(); } } finally { for (String cleanup : annotation.cleanup()) { @@ -646,6 +667,12 @@ public class QueryTestCaseBase { } } + protected void closeResultSets(ResultSet... resultSets) throws SQLException { + for (ResultSet rs : resultSets) { + rs.close(); + } + } + private boolean isNull(ResultSet result) throws SQLException { return result.getMetaData().getColumnCount() == 0; }