Repository: kylin
Updated Branches:
  refs/heads/master 9cd6c7075 -> 19252848e


KYLIN-2426 fix hardcode path

Signed-off-by: lidongsjtu <lid...@apache.org>


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

Branch: refs/heads/master
Commit: 19252848e27423edeb6f3ebed6dea453db1904e9
Parents: 9cd6c70
Author: etherge <ethe...@163.com>
Authored: Mon Feb 6 11:38:42 2017 +0800
Committer: lidongsjtu <lid...@apache.org>
Committed: Mon Feb 6 13:48:38 2017 +0800

----------------------------------------------------------------------
 .../storage/hdfs/ITHDFSResourceStoreTest.java   | 39 +++++++++++---------
 1 file changed, 21 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/19252848/kylin-it/src/test/java/org/apache/kylin/storage/hdfs/ITHDFSResourceStoreTest.java
----------------------------------------------------------------------
diff --git 
a/kylin-it/src/test/java/org/apache/kylin/storage/hdfs/ITHDFSResourceStoreTest.java
 
b/kylin-it/src/test/java/org/apache/kylin/storage/hdfs/ITHDFSResourceStoreTest.java
index ec12722..aa5a104 100644
--- 
a/kylin-it/src/test/java/org/apache/kylin/storage/hdfs/ITHDFSResourceStoreTest.java
+++ 
b/kylin-it/src/test/java/org/apache/kylin/storage/hdfs/ITHDFSResourceStoreTest.java
@@ -18,6 +18,9 @@
 
 package org.apache.kylin.storage.hdfs;
 
+import static junit.framework.TestCase.assertTrue;
+
+import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.kylin.common.KylinConfig;
@@ -28,18 +31,18 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import static junit.framework.TestCase.assertTrue;
-
 public class ITHDFSResourceStoreTest extends HBaseMetadataTestCase {
 
     KylinConfig kylinConfig;
     FileSystem fs;
+    String workingDir;
 
     @Before
     public void setup() throws Exception {
         this.createTestMetadata();
         kylinConfig = KylinConfig.getInstanceFromEnv();
         fs = HadoopUtil.getWorkingFileSystem();
+        workingDir = getHdfsWorkingDirWithoutScheme(kylinConfig);
     }
 
     @After
@@ -47,32 +50,33 @@ public class ITHDFSResourceStoreTest extends 
HBaseMetadataTestCase {
         this.cleanupTestMetadata();
     }
 
+    private String getHdfsWorkingDirWithoutScheme(KylinConfig kylinConfig) {
+        String hdfsWorkingDir = kylinConfig.getHdfsWorkingDirectory();
+        int thirdIndex = StringUtils.ordinalIndexOf(hdfsWorkingDir, "/", 3);
+        int fourthIndex = StringUtils.ordinalIndexOf(hdfsWorkingDir, "/", 5);
+        return hdfsWorkingDir.substring(thirdIndex, fourthIndex);
+    }
+
     @Test
     public void testBasic() throws Exception {
-        String oldUrl = kylinConfig.getMetadataUrl();
-        String path = "/kylin/kylin_metadata/metadata";
-        kylinConfig.setProperty("kylin.metadata.url", path + "@hdfs");
-        HDFSResourceStore store = new HDFSResourceStore(kylinConfig);
-        ResourceStoreTest.testAStore(store);
-        kylinConfig.setProperty("kylin.metadata.url", oldUrl);
-        assertTrue(fs.exists(new Path(path)));
+        String path = workingDir + "/metadata_test1";
+        doTestWithPath(path);
     }
 
     @Test
     public void testQalifiedName() throws Exception {
-        String oldUrl = kylinConfig.getMetadataUrl();
-        String path = "hdfs:///kylin/kylin_metadata/metadata_test1";
-        kylinConfig.setProperty("kylin.metadata.url", path + "@hdfs");
-        HDFSResourceStore store = new HDFSResourceStore(kylinConfig);
-        ResourceStoreTest.testAStore(store);
-        kylinConfig.setProperty("kylin.metadata.url", oldUrl);
-        assertTrue(fs.exists(new Path(path)));
+        String path = "hdfs://" + workingDir + "/metadata_test2";
+        doTestWithPath(path);
     }
 
     @Test
     public void testFullQalifiedName() throws Exception {
+        String path = fs.getUri() + workingDir + "/metadata_test3";
+        doTestWithPath(path);
+    }
+
+    private void doTestWithPath(String path) throws Exception {
         String oldUrl = kylinConfig.getMetadataUrl();
-        String path = 
"hdfs://sandbox.hortonworks.com:8020/kylin/kylin_metadata/metadata_test2";
         kylinConfig.setProperty("kylin.metadata.url", path + "@hdfs");
         HDFSResourceStore store = new HDFSResourceStore(kylinConfig);
         ResourceStoreTest.testAStore(store);
@@ -80,5 +84,4 @@ public class ITHDFSResourceStoreTest extends 
HBaseMetadataTestCase {
         assertTrue(fs.exists(new Path(path)));
     }
 
-
 }

Reply via email to