You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by "bhaveshamre (via GitHub)" <gi...@apache.org> on 2025/09/29 12:57:38 UTC
[PR] RANGER-5344:Test Cases for hdfs-agent [ranger-hdfs-plugin] Module [ranger]
bhaveshamre opened a new pull request, #690:
URL: https://github.com/apache/ranger/pull/690
### AI Disclosure
Added AI-generated Test methods/Test classes using Cursor AI for module hdfs-agent [ranger-hdfs-plugin] and manually reviewed.
## What changes were proposed in this pull request?
RANGER-5344: Test Cases for hdfs-agent [ranger-hdfs-plugin] Module
## How was this patch tested?
Build successful along with test cases.
As per Jacoco
Apache -> hdfs-agent [ranger-hdfs-plugin] Module
Improved Jacoco coverage across multiple packages:
hdfs-agent [ranger-hdfs-plugin] module: 39% → 72%
--
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: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-5344:Test Cases for hdfs-agent [ranger-hdfs-plugin] Module [ranger]
Posted by "bhaveshamre (via GitHub)" <gi...@apache.org>.
bhaveshamre commented on code in PR #690:
URL: https://github.com/apache/ranger/pull/690#discussion_r2498304700
##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/client/HdfsClientTest.java:
##########
@@ -178,4 +208,326 @@ public void testValidHaConfig() throws IllegalArgumentException {
HdfsClient.validateConnectionConfigs(configs);
}
+
+ // ===== JUnit 5 additional tests appended (preserving existing code above) =====
+
+ @Test
+ public void test_validate_valid_multi_nn_transforms_config() {
+ Map<String, String> configs = new HashMap<>();
+ configs.put("username", "hdfsuser");
+ configs.put("password", "hdfsuser");
+ configs.put("hadoop.security.authentication", "simple");
+ configs.put("fs.default.name", "node-1.example.com:8020,node-2.example.com:8020");
+ HdfsClient.validateConnectionConfigs(configs);
+ Assertions.assertEquals("hdfscluster", configs.get("dfs.nameservices"));
+ Assertions.assertEquals("hdfs://hdfscluster", configs.get("fs.default.name"));
+ Assertions.assertEquals("org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider", configs.get("dfs.client.failover.proxy.provider.hdfscluster"));
+ Assertions.assertEquals("namenode1,namenode2", configs.get("dfs.ha.namenodes.hdfscluster"));
+ Assertions.assertEquals("node-1.example.com:8020", configs.get("dfs.namenode.rpc-address.hdfscluster.namenode1"));
+ Assertions.assertEquals("node-2.example.com:8020", configs.get("dfs.namenode.rpc-address.hdfscluster.namenode2"));
+ }
Review Comment:
code changes done.
--
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: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-5344:Test Cases for hdfs-agent [ranger-hdfs-plugin] Module [ranger]
Posted by "dhavalshah9131 (via GitHub)" <gi...@apache.org>.
dhavalshah9131 merged PR #690:
URL: https://github.com/apache/ranger/pull/690
--
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: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-5344:Test Cases for hdfs-agent [ranger-hdfs-plugin] Module [ranger]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #690:
URL: https://github.com/apache/ranger/pull/690#discussion_r2481852571
##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/client/HdfsClientTest.java:
##########
@@ -178,4 +208,326 @@ public void testValidHaConfig() throws IllegalArgumentException {
HdfsClient.validateConnectionConfigs(configs);
}
+
+ // ===== JUnit 5 additional tests appended (preserving existing code above) =====
+
+ @Test
+ public void test_validate_valid_multi_nn_transforms_config() {
+ Map<String, String> configs = new HashMap<>();
+ configs.put("username", "hdfsuser");
+ configs.put("password", "hdfsuser");
+ configs.put("hadoop.security.authentication", "simple");
+ configs.put("fs.default.name", "node-1.example.com:8020,node-2.example.com:8020");
+ HdfsClient.validateConnectionConfigs(configs);
+ Assertions.assertEquals("hdfscluster", configs.get("dfs.nameservices"));
+ Assertions.assertEquals("hdfs://hdfscluster", configs.get("fs.default.name"));
+ Assertions.assertEquals("org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider", configs.get("dfs.client.failover.proxy.provider.hdfscluster"));
+ Assertions.assertEquals("namenode1,namenode2", configs.get("dfs.ha.namenodes.hdfscluster"));
+ Assertions.assertEquals("node-1.example.com:8020", configs.get("dfs.namenode.rpc-address.hdfscluster.namenode1"));
+ Assertions.assertEquals("node-2.example.com:8020", configs.get("dfs.namenode.rpc-address.hdfscluster.namenode2"));
+ }
Review Comment:
This test method is duplicated with test10_validate_valid_multi_nn_transforms_config() at line 330. Consider removing this duplicate to avoid redundant test logic.
```suggestion
```
##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/HDFSRangerTest.java:
##########
@@ -259,9 +269,9 @@ public void readTestUsingTagPolicy() throws Exception {
IOUtils.copy(in, output);
- String content = new String(output.toByteArray());
+ String content = output.toString();
Review Comment:
Using ByteArrayOutputStream.toString() without specifying charset is deprecated and may cause encoding issues. Consider using output.toString(StandardCharsets.UTF_8) for explicit charset handling.
##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/HDFSRangerTest.java:
##########
@@ -386,9 +396,9 @@ void hdfsReadTest(String fileName) throws Exception {
IOUtils.copy(in, output);
- String content = new String(output.toByteArray());
+ String content = output.toString();
Review Comment:
Using ByteArrayOutputStream.toString() without specifying charset is deprecated and may cause encoding issues. Consider using output.toString(StandardCharsets.UTF_8) for explicit charset handling.
##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/HDFSRangerTest.java:
##########
@@ -282,9 +292,9 @@ public void readTestUsingTagPolicy() throws Exception {
IOUtils.copy(in, output);
- String content = new String(output.toByteArray());
+ String content = output.toString();
Review Comment:
Using ByteArrayOutputStream.toString() without specifying charset is deprecated and may cause encoding issues. Consider using output.toString(StandardCharsets.UTF_8) for explicit charset handling.
##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/HDFSRangerTest.java:
##########
@@ -409,9 +419,9 @@ void hdfsReadTest(String fileName) throws Exception {
IOUtils.copy(in, output);
- String content = new String(output.toByteArray());
+ String content = output.toString();
Review Comment:
Using ByteArrayOutputStream.toString() without specifying charset is deprecated and may cause encoding issues. Consider using output.toString(StandardCharsets.UTF_8) for explicit charset handling.
--
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: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-5344:Test Cases for hdfs-agent [ranger-hdfs-plugin] Module [ranger]
Posted by "bhaveshamre (via GitHub)" <gi...@apache.org>.
bhaveshamre commented on PR #690:
URL: https://github.com/apache/ranger/pull/690#issuecomment-3441106497
Hello @kumaab ,
Requesting review for RANGER-5344 (#690). This PR adds AI-assisted (Cursor AI) test cases for the hdfs-agent [ranger-hdfs-plugin] module, manually reviewed, and improves Jacoco coverage from 39% to 72%. Build and tests are passing. Feedback is appreciated.
--
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: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-5344:Test Cases for hdfs-agent [ranger-hdfs-plugin] Module [ranger]
Posted by "bhaveshamre (via GitHub)" <gi...@apache.org>.
bhaveshamre commented on code in PR #690:
URL: https://github.com/apache/ranger/pull/690#discussion_r2568487581
##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/HDFSRangerTest.java:
##########
@@ -259,9 +269,9 @@ public void readTestUsingTagPolicy() throws Exception {
IOUtils.copy(in, output);
- String content = new String(output.toByteArray());
+ String content = output.toString();
Review Comment:
resolved
##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/HDFSRangerTest.java:
##########
@@ -282,9 +292,9 @@ public void readTestUsingTagPolicy() throws Exception {
IOUtils.copy(in, output);
- String content = new String(output.toByteArray());
+ String content = output.toString();
Review Comment:
resolved
--
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: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-5344:Test Cases for hdfs-agent [ranger-hdfs-plugin] Module [ranger]
Posted by "bhaveshamre (via GitHub)" <gi...@apache.org>.
bhaveshamre commented on code in PR #690:
URL: https://github.com/apache/ranger/pull/690#discussion_r2568488541
##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/HDFSRangerTest.java:
##########
@@ -409,9 +419,9 @@ void hdfsReadTest(String fileName) throws Exception {
IOUtils.copy(in, output);
- String content = new String(output.toByteArray());
+ String content = output.toString();
Review Comment:
resolved
##########
hdfs-agent/src/test/java/org/apache/ranger/services/hdfs/HDFSRangerTest.java:
##########
@@ -386,9 +396,9 @@ void hdfsReadTest(String fileName) throws Exception {
IOUtils.copy(in, output);
- String content = new String(output.toByteArray());
+ String content = output.toString();
Review Comment:
resolved
--
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: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org