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/11/30 07:03:08 UTC

[2/2] incubator-kylin git commit: Update test metadata, make them be runable from UI

Update test metadata, make them be runable from UI


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

Branch: refs/heads/2.x-staging
Commit: 05e1f612afca2f6097d54c8f629f5971cafcb32b
Parents: 623635d
Author: shaofengshi <sh...@apache.org>
Authored: Fri Nov 27 14:56:18 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Mon Nov 30 14:02:38 2015 +0800

----------------------------------------------------------------------
 .../model/validation/rule/FunctionRule.java     |  4 ++
 .../cube/test_kylin_cube_with_slr_empty.json    |  1 +
 .../cube/test_kylin_cube_without_slr_empty.json |  1 +
 .../localmeta/project/default.json              | 43 ++++++++++++++++++--
 .../kylin/rest/controller/CubeController.java   |  8 +---
 .../apache/kylin/rest/service/CubeService.java  | 25 +++---------
 .../kylin/rest/service/CubeServiceTest.java     |  3 --
 7 files changed, 52 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/05e1f612/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/FunctionRule.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/FunctionRule.java b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/FunctionRule.java
index 1920fc7..5f400d7 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/FunctionRule.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/FunctionRule.java
@@ -122,6 +122,10 @@ public class FunctionRule implements IValidatorRule<CubeDesc> {
             if (rtype.isNumberFamily() == false) {
                 context.addResult(ResultLevel.ERROR, "Return type for function " + func + " must be one of " + DataType.NUMBER_FAMILY);
             }
+        } else if (funcDesc.isTopN()) {
+            if (rtype.isTopN() == false) {
+                context.addResult(ResultLevel.ERROR, "Return type for function " + func + " must be one of topn");
+            }
         } else {
             if (StringUtils.equalsIgnoreCase(KylinConfig.getInstanceFromEnv().getProperty(KEY_IGNORE_UNKNOWN_FUNC, "false"), "false")) {
                 context.addResult(ResultLevel.ERROR, "Unrecognized function: [" + func + "]");

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/05e1f612/examples/test_case_data/localmeta/cube/test_kylin_cube_with_slr_empty.json
----------------------------------------------------------------------
diff --git a/examples/test_case_data/localmeta/cube/test_kylin_cube_with_slr_empty.json b/examples/test_case_data/localmeta/cube/test_kylin_cube_with_slr_empty.json
index 70d89ea..69032bc 100644
--- a/examples/test_case_data/localmeta/cube/test_kylin_cube_with_slr_empty.json
+++ b/examples/test_case_data/localmeta/cube/test_kylin_cube_with_slr_empty.json
@@ -6,5 +6,6 @@
   "version" : null,
   "descriptor" : "test_kylin_cube_with_slr_desc",
   "segments" : [ ],
+  "status" : "DISABLED",
   "create_time" : null
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/05e1f612/examples/test_case_data/localmeta/cube/test_kylin_cube_without_slr_empty.json
----------------------------------------------------------------------
diff --git a/examples/test_case_data/localmeta/cube/test_kylin_cube_without_slr_empty.json b/examples/test_case_data/localmeta/cube/test_kylin_cube_without_slr_empty.json
index 6bd566a..fe3c4d7 100644
--- a/examples/test_case_data/localmeta/cube/test_kylin_cube_without_slr_empty.json
+++ b/examples/test_case_data/localmeta/cube/test_kylin_cube_without_slr_empty.json
@@ -6,5 +6,6 @@
   "version" : null,
   "descriptor" : "test_kylin_cube_without_slr_desc",
   "segments" : [ ],
+  "status" : "DISABLED",
   "create_time" : null
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/05e1f612/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..aeb79bd 100644
--- a/examples/test_case_data/localmeta/project/default.json
+++ b/examples/test_case_data/localmeta/project/default.json
@@ -3,26 +3,61 @@
   "name": "default",
   "realizations": [
     {
-      "name": "test_kylin_with_slr_model_desc",
+      "name": "test_kylin_cube_with_slr_empty",
       "type": "CUBE",
       "realization": "test_kylin_cube_with_slr_empty"
     },
     {
-      "name": "test_kylin_without_slr_model_desc",
+      "name": "test_kylin_cube_without_slr_empty",
       "type": "CUBE",
       "realization": "test_kylin_cube_without_slr_empty"
     },
     {
-      "name": "test_kylin_with_slr_left_join_model_desc",
+      "name": "test_kylin_cube_with_slr_left_join_empty",
       "type": "CUBE",
       "realization": "test_kylin_cube_with_slr_left_join_empty"
     },
     {
-      "name": "test_kylin_without_slr_left_join_model_desc",
+      "name": "test_kylin_cube_without_slr_left_join_empty",
       "type": "CUBE",
       "realization": "test_kylin_cube_without_slr_left_join_empty"
     },
     {
+      "name": "test_kylin_cube_with_slr_1_new_segment",
+      "type": "CUBE",
+      "realization": "test_kylin_cube_with_slr_1_new_segment"
+    },
+    {
+      "name": "test_kylin_cube_with_slr_left_join_ready",
+      "type": "CUBE",
+      "realization": "test_kylin_cube_with_slr_left_join_ready"
+    },
+    {
+      "name": "test_kylin_cube_with_slr_ready",
+      "type": "CUBE",
+      "realization": "test_kylin_cube_with_slr_ready"
+    },
+    {
+      "name": "test_kylin_cube_with_slr_ready_2_segments",
+      "type": "CUBE",
+      "realization": "test_kylin_cube_with_slr_ready_2_segments"
+    },
+    {
+      "name": "test_kylin_cube_without_slr_left_join_ready",
+      "type": "CUBE",
+      "realization": "test_kylin_cube_without_slr_left_join_ready"
+    },
+    {
+      "name": "test_kylin_cube_without_slr_left_join_ready_2_segments",
+      "type": "CUBE",
+      "realization": "test_kylin_cube_without_slr_left_join_ready_2_segments"
+    },
+    {
+      "name": "test_kylin_cube_without_slr_ready",
+      "type": "CUBE",
+      "realization": "test_kylin_cube_without_slr_ready"
+    },
+    {
       "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/05e1f612/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java b/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
index b0c3387..1427ff2 100644
--- a/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
+++ b/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
@@ -328,7 +328,7 @@ public class CubeController extends BasicController {
             cubeRequest.setMessage("CubeDesc is null.");
             return cubeRequest;
         }
-        String name = CubeService.getCubeNameFromDesc(desc.getName());
+        String name = cubeRequest.getCubeName();
         if (StringUtils.isEmpty(name)) {
             logger.info("Cube name should not be empty.");
             throw new BadRequestException("Cube name should not be empty.");
@@ -431,12 +431,6 @@ public class CubeController extends BasicController {
             return cubeRequest;
         }
 
-        //cube renaming:
-        if (!cubeRequest.getCubeName().equalsIgnoreCase(CubeService.getCubeNameFromDesc(desc.getName()))) {
-            deleteCube(cubeRequest.getCubeName());
-            saveCubeDesc(cubeRequest);
-        }
-
         try {
             CubeInstance cube = cubeService.getCubeManager().getCube(cubeRequest.getCubeName());
             String projectName = (null == cubeRequest.getProject()) ? ProjectInstance.DEFAULT_PROJECT_NAME : cubeRequest.getProject();

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/05e1f612/server/src/main/java/org/apache/kylin/rest/service/CubeService.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/service/CubeService.java b/server/src/main/java/org/apache/kylin/rest/service/CubeService.java
index 6670de1..5e1a3d9 100644
--- a/server/src/main/java/org/apache/kylin/rest/service/CubeService.java
+++ b/server/src/main/java/org/apache/kylin/rest/service/CubeService.java
@@ -289,29 +289,16 @@ public class CubeService extends BasicService {
     }
 
     public boolean isCubeDescEditable(CubeDesc cd) {
-        String cubeName = getCubeNameFromDesc(cd.getName());
-        CubeInstance cube = getCubeManager().getCube(cubeName);
-        if (cube == null) {
-            return true;
-        }
-        if (cube.getSegments().size() != 0) {
-            return false;
+        List<CubeInstance> cubes = getCubeManager().getCubesByDesc(cd.getName());
+        for (CubeInstance cube : cubes) {
+            if (cube.getSegments().size() != 0) {
+                logger.debug("cube '" + cube.getName() + " has " + cube.getSegments().size() + " segments, couldn't edit cube desc.");
+                return false;
+            }
         }
         return true;
     }
 
-    public static String getCubeDescNameFromCube(String cubeName) {
-        return cubeName + DESC_SUFFIX;
-    }
-
-    public static String getCubeNameFromDesc(String descName) {
-        if (descName.toLowerCase().endsWith(DESC_SUFFIX)) {
-            return descName.substring(0, descName.toLowerCase().indexOf(DESC_SUFFIX));
-        } else {
-            return descName;
-        }
-    }
-
     /**
      * Stop all jobs belonging to this cube and clean out all segments
      *

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/05e1f612/server/src/test/java/org/apache/kylin/rest/service/CubeServiceTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/kylin/rest/service/CubeServiceTest.java b/server/src/test/java/org/apache/kylin/rest/service/CubeServiceTest.java
index 226380c..d86935e 100644
--- a/server/src/test/java/org/apache/kylin/rest/service/CubeServiceTest.java
+++ b/server/src/test/java/org/apache/kylin/rest/service/CubeServiceTest.java
@@ -48,9 +48,6 @@ public class CubeServiceTest extends ServiceTestBase {
         Assert.assertNotNull(cubeService.getMetadataManager());
         Assert.assertNotNull(cacheService.getOLAPDataSource(ProjectInstance.DEFAULT_PROJECT_NAME));
 
-        Assert.assertTrue(CubeService.getCubeDescNameFromCube("testCube").equals("testCube_desc"));
-        Assert.assertTrue(CubeService.getCubeNameFromDesc("testCube_desc").equals("testCube"));
-
         List<CubeInstance> cubes = cubeService.getCubes(null, null, null, null, null);
         Assert.assertNotNull(cubes);
         CubeInstance cube = cubes.get(0);