maheshbandal15 commented on code in PR #1310:
URL: https://github.com/apache/ranger/pull/1310#discussion_r4272762784


##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/RangerHdfsAuthorizerTest.java:
##########
@@ -240,6 +299,79 @@ private static INode createNode(String[] pathSegments, int 
i, String owner, Stri
         return mock;
     }
 
+    private static INode[] createPath(String path, boolean file, boolean 
exists) {
+        String[] segments = path.split("/");
+        INode[]  ret      = new INode[segments.length];
+
+        for (int i = 0; i < segments.length; i++) {
+            boolean isLast = i == segments.length - 1;
+
+            ret[i] = isLast && !exists ? null : createNode(segments, i, 
FILE_OWNER, FILE_GROUP, isLast && file);
+        }
+
+        return ret;
+    }
+
+    private static void runWithAuthzOptimizationEnabled(boolean enabled, 
ThrowingRunnable runnable) throws Exception {
+        boolean previous = setAuthzOptimizationEnabled(enabled);
+
+        try {
+            runnable.run();
+        } finally {
+            setAuthzOptimizationEnabled(previous);
+        }
+    }
+
+    private static boolean setAuthzOptimizationEnabled(boolean enabled) throws 
ReflectiveOperationException {
+        Field   pluginField = 
RangerHdfsAuthorizer.class.getDeclaredField("rangerPlugin");
+        Object  plugin;
+        Field   flagField;
+        boolean previous;
+
+        pluginField.setAccessible(true);
+        plugin    = pluginField.get(authorizer);
+        flagField = 
plugin.getClass().getDeclaredField("authzOptimizationEnabled");
+        flagField.setAccessible(true);
+        previous = flagField.getBoolean(plugin);
+        flagField.setBoolean(plugin, enabled);
+
+        return previous;
+    }

Review Comment:
   Build is successful with "mvn clean install". Also, in pom.xml Surefire 
config does not enable JUnit parallel execution.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to