You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ma...@apache.org on 2016/03/03 03:32:07 UTC

kylin git commit: KYLIN-1465 log improvement on query comparision test

Repository: kylin
Updated Branches:
  refs/heads/2.x-staging 61f3278e5 -> ebe9dabfe


KYLIN-1465 log improvement on query comparision test


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/ebe9dabf
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/ebe9dabf
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/ebe9dabf

Branch: refs/heads/2.x-staging
Commit: ebe9dabfe789f437d29af5e3d60cb22bc0bcf26c
Parents: 61f3278
Author: Hongbin Ma <ma...@apache.org>
Authored: Thu Mar 3 10:31:48 2016 +0800
Committer: Hongbin Ma <ma...@apache.org>
Committed: Thu Mar 3 10:31:48 2016 +0800

----------------------------------------------------------------------
 .../apache/kylin/query/ITCombinationTest.java   |  2 +
 .../apache/kylin/query/ITKylinQueryTest.java    |  1 -
 .../org/apache/kylin/query/KylinTestBase.java   | 58 ++++++++------------
 3 files changed, 26 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/ebe9dabf/kylin-it/src/test/java/org/apache/kylin/query/ITCombinationTest.java
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/java/org/apache/kylin/query/ITCombinationTest.java b/kylin-it/src/test/java/org/apache/kylin/query/ITCombinationTest.java
index f4bbe5f..0a6d8cd 100644
--- a/kylin-it/src/test/java/org/apache/kylin/query/ITCombinationTest.java
+++ b/kylin-it/src/test/java/org/apache/kylin/query/ITCombinationTest.java
@@ -58,6 +58,8 @@ public class ITCombinationTest extends ITKylinQueryTest {
 
     public ITCombinationTest(String joinType, String coprocessorToggle, String queryEngine) throws Exception {
 
+        printInfo("Into combination join type: " + joinType + ", coprocessor toggle: " + coprocessorToggle + ", query engine: " + queryEngine);
+
         ITKylinQueryTest.clean();
 
         ITKylinQueryTest.joinType = joinType;

http://git-wip-us.apache.org/repos/asf/kylin/blob/ebe9dabf/kylin-it/src/test/java/org/apache/kylin/query/ITKylinQueryTest.java
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/java/org/apache/kylin/query/ITKylinQueryTest.java b/kylin-it/src/test/java/org/apache/kylin/query/ITKylinQueryTest.java
index fd88452..0a68bc3 100644
--- a/kylin-it/src/test/java/org/apache/kylin/query/ITKylinQueryTest.java
+++ b/kylin-it/src/test/java/org/apache/kylin/query/ITKylinQueryTest.java
@@ -46,7 +46,6 @@ import org.junit.Test;
 public class ITKylinQueryTest extends KylinTestBase {
     private static CacheManager cacheManager;
 
-
     @BeforeClass
     public static void setUp() throws Exception {
         printInfo("set up in KylinQueryTest");

http://git-wip-us.apache.org/repos/asf/kylin/blob/ebe9dabf/kylin-it/src/test/java/org/apache/kylin/query/KylinTestBase.java
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/java/org/apache/kylin/query/KylinTestBase.java b/kylin-it/src/test/java/org/apache/kylin/query/KylinTestBase.java
index b5c6d10..c60553d 100644
--- a/kylin-it/src/test/java/org/apache/kylin/query/KylinTestBase.java
+++ b/kylin-it/src/test/java/org/apache/kylin/query/KylinTestBase.java
@@ -36,13 +36,17 @@ import java.sql.Statement;
 import java.sql.Timestamp;
 import java.sql.Types;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
+import java.util.TreeSet;
 import java.util.logging.LogManager;
 
+import com.google.common.base.Throwables;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionContext;
 import org.apache.kylin.common.KylinConfig;
 import org.dbunit.Assertion;
 import org.dbunit.database.DatabaseConfig;
@@ -58,6 +62,8 @@ import org.dbunit.ext.h2.H2DataTypeFactory;
 import org.junit.Assert;
 
 import com.google.common.io.Files;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  */
@@ -96,39 +102,26 @@ public class KylinTestBase {
         }
     }
 
+    private static class FileByNameComparator implements Comparator<File> {
+        @Override
+        public int compare(File o1, File o2) {
+            return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName());
+        }
+    }
+
     /**
      * @param folder
-     * @param fileType
-     *            specify the interested file type by file extension
+     * @param fileType specify the interested file type by file extension
      * @return
      */
     protected static List<File> getFilesFromFolder(final File folder, final String fileType) {
-        List<File> files = new ArrayList<File>();
+        Set<File> set = new TreeSet<>(new FileByNameComparator());
         for (final File fileEntry : folder.listFiles()) {
             if (fileEntry.getName().toLowerCase().endsWith(fileType.toLowerCase())) {
-                files.add(fileEntry);
-            }
-        }
-        return files;
-    }
-
-    protected static void getFilesFromFolderR(final String directoryStr, List<File> files, final String fileType) {
-        File folder = new File(directoryStr);
-        for (final File fileEntry : folder.listFiles()) {
-            if (fileEntry.isDirectory()) {
-                getFilesFromFolderR(fileEntry.getAbsolutePath(), files, fileType);
-            } else if (fileEntry.isFile()) {
-                if (fileEntry.getName().toLowerCase().endsWith(fileType.toLowerCase())) {
-                    files.add(fileEntry);
-                }
+                set.add(fileEntry);
             }
         }
-    }
-
-    protected static void putTextTofile(File file, String sql) throws IOException {
-        BufferedWriter writer = new BufferedWriter(new FileWriter(file));
-        writer.write(sql, 0, sql.length());
-        writer.close();
+        return new ArrayList<>(set);
     }
 
     protected static String getTextFromFile(File file) throws IOException {
@@ -293,14 +286,6 @@ public class KylinTestBase {
         return ret;
     }
 
-    protected static void batchChangeJoinType(String targetType) throws IOException {
-        List<File> files = new LinkedList<File>();
-        getFilesFromFolderR("src/test/resources/query", files, ".sql");
-        for (File file : files) {
-            String x = changeJoinType(getTextFromFile(file), targetType);
-            putTextTofile(file, x);
-        }
-    }
 
     protected void execQueryUsingH2(String queryFolder, boolean needSort) throws Exception {
         printInfo("---------- Running H2 queries: " + queryFolder);
@@ -396,8 +381,13 @@ public class KylinTestBase {
             h2Conn.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new TestH2DataTypeFactory());
             ITable h2Table = executeQuery(h2Conn, queryName, sql, needSort);
 
-            // compare the result
-            Assertion.assertEquals(h2Table, kylinTable);
+            try {
+                // compare the result
+                Assertion.assertEquals(h2Table, kylinTable);
+            } catch (Throwable t) {
+                printInfo("execAndCompQuery failed on: " + sqlFile.getAbsolutePath());
+                throw t;
+            }
 
             compQueryCount++;
             if (kylinTable.getRowCount() == 0) {