DRILL-4143: parquet metadata is only opened in drillbituser (process user)'s security context.
Adding unit test for impersonated metadata update.
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/3d92d282
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/3d92d282
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/3d92d282
Branch: refs/heads/master
Commit: 3d92d2829db2929e53c36df27f9979d6ff7a079a
Parents: bd6079c
Author: chunhui-shi <cshi@maprtech.com>
Authored: Thu Apr 7 00:05:22 2016 -0700
Committer: Aman Sinha <asinha@maprtech.com>
Committed: Fri May 20 14:49:19 2016 -0700
----------------------------------------------------------------------
.../drill/exec/store/parquet/Metadata.java | 4 +++-
.../TestImpersonationMetadata.java | 24 ++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/3d92d282/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java
index 952f379..d7d31e5 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java
@@ -27,7 +27,9 @@ import java.util.concurrent.TimeUnit;
import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.exec.store.TimedRunnable;
+import org.apache.drill.exec.store.dfs.DrillFileSystem;
import org.apache.drill.exec.store.dfs.DrillPathFilter;
+import org.apache.drill.exec.util.ImpersonationUtil;
import org.apache.hadoop.fs.BlockLocation;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
@@ -131,7 +133,7 @@ public class Metadata {
}
private Metadata(FileSystem fs) {
- this.fs = fs;
+ this.fs = ImpersonationUtil.createFileSystem(ImpersonationUtil.getProcessUserName(),
fs.getConf());
}
/**
http://git-wip-us.apache.org/repos/asf/drill/blob/3d92d282/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java
index d5f191b..2121b6f 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java
@@ -36,6 +36,7 @@ import java.util.Map;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* Tests impersonation on metadata related queries as SHOW FILES, SHOW TABLES, CREATE VIEW,
CREATE TABLE and DROP TABLE
@@ -360,6 +361,29 @@ public class TestImpersonationMetadata extends BaseTestImpersonation
{
containsString("SYSTEM ERROR: RemoteException: Permission denied: user=drillTestUser2,
access=WRITE, inode=\"/drillTestGrp0_755/"));
}
+ @Test
+ public void testRefreshMetadata() throws Exception {
+ final String tableName = "nation1";
+ final String tableWS = "drillTestGrp1_700";
+
+ updateClient(user1);
+ test("USE " + Joiner.on(".").join(MINIDFS_STORAGE_PLUGIN_NAME, tableWS));
+
+ test("CREATE TABLE " + tableName + " partition by (n_regionkey) AS SELECT * " +
+ "FROM cp.`tpch/nation.parquet`;");
+
+ test( "refresh table metadata " + tableName + ";");
+
+ test("SELECT * FROM " + tableName + ";");
+
+ final Path tablePath = new Path(Path.SEPARATOR + tableWS + Path.SEPARATOR + tableName);
+ assertTrue ( fs.exists(tablePath) && fs.isDirectory(tablePath));
+ fs.mkdirs(new Path(tablePath, "tmp5"));
+
+ test("SELECT * from " + tableName + ";");
+
+ }
+
@AfterClass
public static void removeMiniDfsBasedStorage() throws Exception {
getDrillbitContext().getStorage().deletePlugin(MINIDFS_STORAGE_PLUGIN_NAME);
|