You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2015/09/21 04:16:16 UTC

[10/13] incubator-kylin git commit: KYLIN-943 Update test case

KYLIN-943 Update test case


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

Branch: refs/heads/KYLIN-943
Commit: 97de708e62f0830fef029c39f7b4d7c8fdaac3a6
Parents: 809403c
Author: shaofengshi <sh...@apache.org>
Authored: Sun Sep 6 17:01:53 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Mon Sep 21 10:11:54 2015 +0800

----------------------------------------------------------------------
 .../kylin/job/BuildCubeWithEngineTest.java      | 18 ++++++++++++++-
 .../common/topn/TopNCounterCombinationTest.java |  2 ++
 .../serializer/TopNCounterSerializerTest.java   | 24 ++++++++++++++++++--
 .../kylin/storage/hybrid/HybridInstance.java    |  2 +-
 .../localmeta/project/default.json              |  5 ++++
 .../test_case_data/sandbox/kylin.properties     | 10 ++++----
 6 files changed, 52 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/97de708e/assembly/src/test/java/org/apache/kylin/job/BuildCubeWithEngineTest.java
----------------------------------------------------------------------
diff --git a/assembly/src/test/java/org/apache/kylin/job/BuildCubeWithEngineTest.java b/assembly/src/test/java/org/apache/kylin/job/BuildCubeWithEngineTest.java
index d7eb3cf..7c6b028 100644
--- a/assembly/src/test/java/org/apache/kylin/job/BuildCubeWithEngineTest.java
+++ b/assembly/src/test/java/org/apache/kylin/job/BuildCubeWithEngineTest.java
@@ -125,7 +125,8 @@ public class BuildCubeWithEngineTest {
     }
 
     private void testInner() throws Exception {
-        String[] testCase = new String[] { "testInnerJoinCube", "testInnerJoinCube2", };
+       String[] testCase = new String[] { "testInnerJoinCube", "testInnerJoinCube2", "testInnerJoinTopNCube"};
+//        String[] testCase = new String[] { "testInnerJoinTopNCube" };
         runTestAndAssertSucceed(testCase);
     }
 
@@ -183,6 +184,21 @@ public class BuildCubeWithEngineTest {
         }
     }
 
+
+    @SuppressWarnings("unused")
+    // called by reflection
+    private List<String> testInnerJoinTopNCube() throws Exception {
+        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
+        f.setTimeZone(TimeZone.getTimeZone("GMT"));
+        long date1 = 0;
+        long date2 = f.parse("2013-01-01").getTime();
+        long date3 = f.parse("2022-01-01").getTime();
+        List<String> result = Lists.newArrayList();
+        result.add(buildSegment("test_kylin_cube_topn", date1, date2));
+        result.add(buildSegment("test_kylin_cube_topn", date2, date3));
+        return result;
+    }
+
     @SuppressWarnings("unused")
     // called by reflection
     private List<String> testInnerJoinCube2() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/97de708e/core-common/src/test/java/org/apache/kylin/common/topn/TopNCounterCombinationTest.java
----------------------------------------------------------------------
diff --git a/core-common/src/test/java/org/apache/kylin/common/topn/TopNCounterCombinationTest.java b/core-common/src/test/java/org/apache/kylin/common/topn/TopNCounterCombinationTest.java
index cc0557e..3d809df 100644
--- a/core-common/src/test/java/org/apache/kylin/common/topn/TopNCounterCombinationTest.java
+++ b/core-common/src/test/java/org/apache/kylin/common/topn/TopNCounterCombinationTest.java
@@ -16,6 +16,7 @@
 
 package org.apache.kylin.common.topn;
 
+import org.junit.Ignore;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
@@ -23,6 +24,7 @@ import java.util.Arrays;
 import java.util.Collection;
 
 @RunWith(Parameterized.class)
+@Ignore ("For collecting accuracy statistics, not for functional test")
 public class TopNCounterCombinationTest extends TopNCounterTest {
 
     @Parameterized.Parameters

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/97de708e/core-metadata/src/test/java/org/apache/kylin/metadata/measure/serializer/TopNCounterSerializerTest.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/test/java/org/apache/kylin/metadata/measure/serializer/TopNCounterSerializerTest.java b/core-metadata/src/test/java/org/apache/kylin/metadata/measure/serializer/TopNCounterSerializerTest.java
index 050193b..3c88446 100644
--- a/core-metadata/src/test/java/org/apache/kylin/metadata/measure/serializer/TopNCounterSerializerTest.java
+++ b/core-metadata/src/test/java/org/apache/kylin/metadata/measure/serializer/TopNCounterSerializerTest.java
@@ -3,6 +3,7 @@ package org.apache.kylin.metadata.measure.serializer;
 import org.apache.kylin.common.topn.TopNCounter;
 import org.apache.kylin.common.util.ByteArray;
 import org.apache.kylin.common.util.Bytes;
+import org.apache.kylin.common.util.BytesUtil;
 import org.apache.kylin.metadata.model.DataType;
 import org.junit.Assert;
 import org.junit.Test;
@@ -18,14 +19,14 @@ public class TopNCounterSerializerTest {
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testCounterSerialization() {
+    public void testSerialization() {
         TopNCounter<ByteArray> vs = new TopNCounter<ByteArray>(50);
         Integer[] stream = { 1, 1, 2, 9, 1, 2, 3, 7, 7, 1, 3, 1, 1 };
         for (Integer i : stream) {
             vs.offer(new ByteArray(Bytes.toBytes(i)));
         }
 
-        ByteBuffer out = ByteBuffer.allocate(1024 * 1024);
+        ByteBuffer out = ByteBuffer.allocate(1024);
         serializer.serialize(vs, out);
         
         byte[] copyBytes = new byte[out.position()];
@@ -37,5 +38,24 @@ public class TopNCounterSerializerTest {
         Assert.assertEquals(vs.toString(), vsNew.toString());
 
     }
+    
+    @Test
+    public void testValueOf() {
+
+        TopNCounter<ByteArray> origin = new TopNCounter<ByteArray>(10);
+        ByteArray key = new ByteArray(1);
+        ByteBuffer byteBuffer = key.asBuffer();
+        BytesUtil.writeVLong(20l, byteBuffer);
+        origin.offer(key, 1.0);
+
+        byteBuffer = ByteBuffer.allocate(1024);
+        byteBuffer.putInt(1);
+        byteBuffer.putInt(20);
+        byteBuffer.putDouble(1.0);
+        TopNCounter<ByteArray> counter = serializer.valueOf(byteBuffer.array());
+
+
+        Assert.assertEquals(origin.toString(), counter.toString());
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/97de708e/core-storage/src/main/java/org/apache/kylin/storage/hybrid/HybridInstance.java
----------------------------------------------------------------------
diff --git a/core-storage/src/main/java/org/apache/kylin/storage/hybrid/HybridInstance.java b/core-storage/src/main/java/org/apache/kylin/storage/hybrid/HybridInstance.java
index e9f0975..6ad27d5 100644
--- a/core-storage/src/main/java/org/apache/kylin/storage/hybrid/HybridInstance.java
+++ b/core-storage/src/main/java/org/apache/kylin/storage/hybrid/HybridInstance.java
@@ -277,7 +277,7 @@ public class HybridInstance extends RootPersistentEntity implements IRealization
     }
 
     public IRealization getLatestRealization() {
-        if (realizations.length > 0) {
+        if (getRealizations().length > 0) {
             return realizations[realizations.length - 1];
         }
         return null;

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/97de708e/examples/test_case_data/localmeta/project/default.json
----------------------------------------------------------------------
diff --git a/examples/test_case_data/localmeta/project/default.json b/examples/test_case_data/localmeta/project/default.json
index e4118ca..71eb1fa 100644
--- a/examples/test_case_data/localmeta/project/default.json
+++ b/examples/test_case_data/localmeta/project/default.json
@@ -23,6 +23,11 @@
       "realization": "test_kylin_cube_without_slr_left_join_empty"
     },
     {
+      "name": "test_kylin_cube_topn",
+      "type": "CUBE",
+      "realization": "test_kylin_cube_topn"
+    },
+    {
       "name": "test_kylin_ii_left_join",
       "type": "INVERTED_INDEX",
       "realization": "test_kylin_ii_left_join"

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/97de708e/examples/test_case_data/sandbox/kylin.properties
----------------------------------------------------------------------
diff --git a/examples/test_case_data/sandbox/kylin.properties b/examples/test_case_data/sandbox/kylin.properties
index beb9c44..5b05f87 100644
--- a/examples/test_case_data/sandbox/kylin.properties
+++ b/examples/test_case_data/sandbox/kylin.properties
@@ -16,16 +16,16 @@ kylin.job.mapreduce.default.reduce.input.mb=500
 
 # If true, job engine will not assume that hadoop CLI reside on the same server as it self
 # you will have to specify kylin.job.remote.cli.hostname, kylin.job.remote.cli.username and kylin.job.remote.cli.password
-kylin.job.run.as.remote.cmd=false
+kylin.job.run.as.remote.cmd=true
 
 # Only necessary when kylin.job.run.as.remote.cmd=true
-kylin.job.remote.cli.hostname=
+kylin.job.remote.cli.hostname=sandbox
 
 # Only necessary when kylin.job.run.as.remote.cmd=true
-kylin.job.remote.cli.username=
+kylin.job.remote.cli.username=root
 
 # Only necessary when kylin.job.run.as.remote.cmd=true
-kylin.job.remote.cli.password=
+kylin.job.remote.cli.password=hadoop
 
 # Used by test cases to prepare synthetic data for sample cube
 kylin.job.remote.cli.working.dir=/tmp/kylin
@@ -34,7 +34,7 @@ kylin.job.remote.cli.working.dir=/tmp/kylin
 kylin.job.concurrent.max.limit=10
 
 # Whether calculate cube in mem in each mapper;
-kylin.job.cubing.inMem=true
+kylin.job.cubing.inMem=false
 
 #the percentage of the sampling, default 25%
 kylin.job.cubing.inMem.sampling.percent=25