You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by co...@apache.org on 2015/08/31 02:55:43 UTC

incubator-sentry git commit: SENTRY-860: Fix intermittent test failure for TestPrivilegesAtFunctionScope.testFuncPrivileges1 (Anne Yu Via Colin Ma)

Repository: incubator-sentry
Updated Branches:
  refs/heads/master b99fa7559 -> d4e6bbf7e


SENTRY-860: Fix intermittent test failure for TestPrivilegesAtFunctionScope.testFuncPrivileges1 (Anne Yu Via 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/d4e6bbf7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/d4e6bbf7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/d4e6bbf7

Branch: refs/heads/master
Commit: d4e6bbf7e8e355cc05777033f9318673022b53fc
Parents: b99fa75
Author: Colin Ma <co...@apache.org>
Authored: Mon Aug 31 08:31:09 2015 +0800
Committer: Colin Ma <co...@apache.org>
Committed: Mon Aug 31 08:31:09 2015 +0800

----------------------------------------------------------------------
 .../e2e/hive/TestPrivilegesAtFunctionScope.java | 26 +++++++++++++++++---
 1 file changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d4e6bbf7/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
index 7bb199b..228a2de 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
@@ -18,11 +18,13 @@ printf_test_3 * Licensed to the Apache Software Foundation (ASF) under one or mo
 package org.apache.sentry.tests.e2e.hive;
 
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.security.CodeSource;
 import java.sql.Connection;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
@@ -32,7 +34,13 @@ import org.junit.Test;
 
 import com.google.common.io.Resources;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticConfiguration {
+  private static final Logger LOGGER = LoggerFactory
+          .getLogger(TestPrivilegesAtFunctionScope.class);
+
   private final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat";
   private File dataDir;
   private File dataFile;
@@ -92,10 +100,20 @@ public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticConfigu
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
     statement.execute("USE " + DB1);
-    statement.execute(
-        "CREATE TEMPORARY FUNCTION printf_test AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFPrintf'");
-    statement.execute("SELECT printf_test(value) FROM " + tableName1);
-    statement.execute("DROP TEMPORARY FUNCTION printf_test");
+
+    try {
+      statement.execute("CREATE TEMPORARY FUNCTION printf_test AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFPrintf'");
+      LOGGER.info("Testing select from temp func printf_test");
+      ResultSet res = statement.executeQuery("SELECT printf_test('%d', under_col) FROM " + tableName1);
+      while (res.next()) {
+        LOGGER.info(res.getString(1));
+      }
+      res.close();
+      statement.execute("DROP TEMPORARY FUNCTION printf_test");
+    } catch (Exception ex) {
+      LOGGER.error("test temp func printf_test failed with reason: " + ex.getStackTrace() + " " + ex.getMessage());
+      fail("fail to test temp func printf_test");
+    }
 
     statement.execute(
         "CREATE FUNCTION printf_test_perm AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFPrintf' ");