You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by sd...@apache.org on 2015/08/14 09:28:46 UTC
[12/50] [abbrv] incubator-sentry git commit: SENTRY-797:
TestHDFSIntegration#testEngToEnd is flaky (Sravya Tirukkovalur,
Reviewed by: Colin Ma)
SENTRY-797: TestHDFSIntegration#testEngToEnd is flaky (Sravya Tirukkovalur, Reviewed by: Colin Ma)
Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/8bd827b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/8bd827b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/8bd827b2
Branch: refs/heads/hive_plugin_v2
Commit: 8bd827b28b8a6df69f2d075ffbc10b305fc98380
Parents: 499074e
Author: Sravya Tirukkovalur <sr...@clouera.com>
Authored: Thu Jul 9 15:07:18 2015 -0700
Committer: Sravya Tirukkovalur <sr...@clouera.com>
Committed: Fri Jul 10 08:04:01 2015 -0700
----------------------------------------------------------------------
.../tests/e2e/hdfs/TestHDFSIntegration.java | 38 ++++++++++++++------
1 file changed, 27 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/8bd827b2/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
index 1c89b3b..53d71d6 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
@@ -74,6 +74,7 @@ import org.apache.hadoop.mapred.TextOutputFormat;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.sentry.binding.hive.SentryHiveAuthorizationTaskFactoryImpl;
import org.apache.sentry.binding.hive.conf.HiveAuthzConf;
+import org.apache.sentry.hdfs.SentryAuthorizationConstants;
import org.apache.sentry.hdfs.SentryAuthorizationProvider;
import org.apache.sentry.provider.db.SimpleDBProviderBackend;
import org.apache.sentry.provider.file.LocalGroupResourceAuthorizationProvider;
@@ -147,6 +148,7 @@ public class TestHDFSIntegration {
private static int sentryPort = -1;
protected static SentrySrv sentryServer;
protected static boolean testSentryHA = false;
+ private static final long STALE_THRESHOLD = 5000;
private static String fsURI;
private static int hmsPort;
@@ -271,9 +273,9 @@ public class TestHDFSIntegration {
out.close();
Reflection.staticField("hiveSiteURL")
- .ofType(URL.class)
- .in(HiveConf.class)
- .set(hiveSite.toURI().toURL());
+ .ofType(URL.class)
+ .in(HiveConf.class)
+ .set(hiveSite.toURI().toURL());
metastore = new InternalMetastoreServer(hiveConf);
new Thread() {
@@ -281,7 +283,8 @@ public class TestHDFSIntegration {
public void run() {
try {
metastore.start();
- while(true){}
+ while (true) {
+ }
} catch (Exception e) {
LOGGER.info("Could not start Hive Server");
}
@@ -358,7 +361,7 @@ public class TestHDFSIntegration {
conf.set("sentry.authorization-provider.hdfs-path-prefixes", "/user/hive/warehouse,/tmp/external");
conf.set("sentry.authorization-provider.cache-refresh-retry-wait.ms", "5000");
- conf.set("sentry.authorization-provider.cache-stale-threshold.ms", "3000");
+ conf.set("sentry.authorization-provider.cache-stale-threshold.ms", String.valueOf(STALE_THRESHOLD));
conf.set("sentry.hdfs.service.security.mode", "none");
conf.set("sentry.hdfs.service.client.server.rpc-address", "localhost");
@@ -508,8 +511,12 @@ public class TestHDFSIntegration {
hiveServer2.shutdown();
}
} finally {
- if (metastore != null) {
- metastore.shutdown();
+ try {
+ if (metastore != null) {
+ metastore.shutdown();
+ }
+ } finally {
+ sentryServer.close();
}
}
}
@@ -617,14 +624,23 @@ public class TestHDFSIntegration {
//TODO: SENTRY-795: HDFS permissions do not sync when Sentry restarts in HA mode.
if(!testSentryHA) {
- sentryServer.stop(0);
- // Verify that Sentry permission are still enforced for the "stale" period
- verifyOnAllSubDirs("/user/hive/warehouse/p3", FsAction.WRITE_EXECUTE, "hbase", true);
+ long beforeStop = System.currentTimeMillis();
+ sentryServer.stopAll();
+ long timeTakenForStopMs = System.currentTimeMillis() - beforeStop;
+ LOGGER.info("Time taken for Sentry server stop: " + timeTakenForStopMs);
+
+ // Verify that Sentry permission are still enforced for the "stale" period only if stop did not take too long
+ if(timeTakenForStopMs < STALE_THRESHOLD) {
+ verifyOnAllSubDirs("/user/hive/warehouse/p3", FsAction.WRITE_EXECUTE, "hbase", true);
+ Thread.sleep((STALE_THRESHOLD - timeTakenForStopMs));
+ } else {
+ LOGGER.warn("Sentry server stop took too long");
+ }
// Verify that Sentry permission are NOT enforced AFTER "stale" period
verifyOnAllSubDirs("/user/hive/warehouse/p3", null, "hbase", false);
- sentryServer.start(0);
+ sentryServer.startAll();
}
// Verify that After Sentry restart permissions are re-enforced