This is an automated email from the ASF dual-hosted git repository.

shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit b31385f8e53d49ad68b5030769c1611a8a64ae9c
Author: chao long <wayn...@qq.com>
AuthorDate: Thu Dec 20 20:51:05 2018 +0800

    KYLIN-3734 Fix UT error: invalid path of global job lock
---
 examples/test_case_data/localmeta/kylin.properties             |  1 +
 pom.xml                                                        |  8 +++++++-
 server/pom.xml                                                 |  5 +++++
 .../java/org/apache/kylin/rest/service/ServiceTestBase.java    | 10 +++++++++-
 .../kylin/storage/hbase/util/ZookeeperDistributedLock.java     | 10 +++++++++-
 5 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/examples/test_case_data/localmeta/kylin.properties 
b/examples/test_case_data/localmeta/kylin.properties
index 434286e..be2ecd4 100644
--- a/examples/test_case_data/localmeta/kylin.properties
+++ b/examples/test_case_data/localmeta/kylin.properties
@@ -141,6 +141,7 @@ kylin.engine.mr.mem-hungry-config-override.test1=mem-test1
 kylin.engine.mr.mem-hungry-config-override.test2=mem-test2 
 kylin.job.lock=org.apache.kylin.job.lock.MockJobLockDup
 kylin.job.lock=org.apache.kylin.job.lock.MockJobLock
+kylin.env.zookeeper-connect-string=localhost:12181
 
 
 
diff --git a/pom.xml b/pom.xml
index ac1edf0..b20cc26 100644
--- a/pom.xml
+++ b/pom.xml
@@ -102,6 +102,7 @@
     <jamm.version>0.3.1</jamm.version>
     <mockito.version>2.7.14</mockito.version>
     <powermock.version>1.7.0</powermock.version>
+    <curator.version>2.7.1</curator.version>
 
     <!-- Commons -->
     <commons-lang3.version>3.4</commons-lang3.version>
@@ -864,7 +865,12 @@
         <artifactId>opensaml</artifactId>
         <version>${opensaml.version}</version>
       </dependency>
-
+      <dependency>
+        <groupId>org.apache.curator</groupId>
+        <artifactId>curator-test</artifactId>
+        <version>${curator.version}</version>
+        <scope>test</scope>
+      </dependency>
 
       <!-- Spring Core -->
       <dependency>
diff --git a/server/pom.xml b/server/pom.xml
index b1365a7..84f54ca 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -299,6 +299,11 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/server/src/test/java/org/apache/kylin/rest/service/ServiceTestBase.java 
b/server/src/test/java/org/apache/kylin/rest/service/ServiceTestBase.java
index cf8c2c1..ee5cbd1 100644
--- a/server/src/test/java/org/apache/kylin/rest/service/ServiceTestBase.java
+++ b/server/src/test/java/org/apache/kylin/rest/service/ServiceTestBase.java
@@ -18,8 +18,10 @@
 
 package org.apache.kylin.rest.service;
 
+import java.io.IOException;
 import java.util.Arrays;
 
+import org.apache.curator.test.TestingServer;
 import org.apache.kylin.common.KylinConfig;
 import org.apache.kylin.common.util.LocalFileMetadataTestCase;
 import org.apache.kylin.metadata.cachesync.Broadcaster;
@@ -50,6 +52,8 @@ import 
org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 @ActiveProfiles("testing")
 public class ServiceTestBase extends LocalFileMetadataTestCase {
 
+    private static TestingServer server;
+
     @Autowired
     @Qualifier("userService")
     UserService userService;
@@ -59,10 +63,14 @@ public class ServiceTestBase extends 
LocalFileMetadataTestCase {
         staticCreateTestMetadata();
         Authentication authentication = new 
TestingAuthenticationToken("ADMIN", "ADMIN", Constant.ROLE_ADMIN);
         SecurityContextHolder.getContext().setAuthentication(authentication);
+
+        server = new TestingServer(12181, true);
+        server.start();
     }
 
     @AfterClass
-    public static void tearDownResource() {
+    public static void tearDownResource() throws IOException {
+        server.stop();
     }
 
     @Before
diff --git 
a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/util/ZookeeperDistributedLock.java
 
b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/util/ZookeeperDistributedLock.java
index ae146d3..b003ca2 100644
--- 
a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/util/ZookeeperDistributedLock.java
+++ 
b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/util/ZookeeperDistributedLock.java
@@ -19,6 +19,8 @@
 package org.apache.kylin.storage.hbase.util;
 
 import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.Random;
 import java.util.concurrent.ConcurrentHashMap;
@@ -297,7 +299,13 @@ public class ZookeeperDistributedLock implements 
DistributedLock, JobLock {
             n = path.length();
             path = path.replace("//", "/");
         }
-        return path;
+
+        try {
+            return new File(path).getCanonicalPath();
+        } catch (IOException e) {
+            logger.error("get canonical path failed, use original path", e);
+            return path;
+        }
     }
 
     // 
============================================================================

Reply via email to