smengcl commented on code in PR #10831:
URL: https://github.com/apache/ozone/pull/10831#discussion_r3753376283
##########
hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/ozone/scm/TestGetScmRatisRolesSubcommand.java:
##########
@@ -61,4 +61,48 @@ public void testGetScmHARatisRoles() throws Exception {
}
}
+ @Test
+ public void testGetScmRolesNonRatisShortString() throws Exception {
+ GetScmRatisRolesSubcommand cmd = new GetScmRatisRolesSubcommand();
+ ScmClient client = mock(ScmClient.class);
+ CommandLine c = new CommandLine(cmd);
+ c.parseArgs("--table");
Review Comment:
```diff
diff --git
a/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/ozone/scm/TestGetScmRatisRolesSubcommand.java
b/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/ozone/scm/TestGetScmRatisRolesSubcommand.java
index 8d8ace7e76c..xxxxxxxxxxx 100644
---
a/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/ozone/scm/TestGetScmRatisRolesSubcommand.java
+++
b/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/ozone/scm/TestGetScmRatisRolesSubcommand.java
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.apache.hadoop.hdds.server.JsonUtils;
import org.apache.hadoop.ozone.admin.scm.GetScmRatisRolesSubcommand;
import org.apache.ozone.test.GenericTestUtils;
import org.junit.jupiter.api.Test;
@@ -62,7 +63,7 @@ public class TestGetScmRatisRolesSubcommand {
}
@Test
- public void testGetScmRolesNonRatisShortString() throws Exception {
+ public void testGetScmRolesNonRatisShortStringTable() throws Exception {
GetScmRatisRolesSubcommand cmd = new GetScmRatisRolesSubcommand();
ScmClient client = mock(ScmClient.class);
CommandLine c = new CommandLine(cmd);
@@ -76,8 +77,29 @@ public class TestGetScmRatisRolesSubcommand {
try (GenericTestUtils.SystemOutCapturer capture =
new GenericTestUtils.SystemOutCapturer()) {
cmd.execute(client);
- assertThat(capture.getOutput()).contains("host");
- assertThat(capture.getOutput()).contains("9894");
+ assertThat(capture.getOutput())
+ .containsPattern("\\|\\s+host\\s+\\|\\s+9894\\s+\\|");
+ }
+ }
+
+ @Test
+ public void testGetScmRolesNonRatisShortStringJson() throws Exception {
+ GetScmRatisRolesSubcommand cmd = new GetScmRatisRolesSubcommand();
+ ScmClient client = mock(ScmClient.class);
+ CommandLine c = new CommandLine(cmd);
+ c.parseArgs("--json");
+
+ List<String> result = new ArrayList<>();
+ result.add("host:9894");
+
+ when(client.getScmRoles()).thenAnswer(invocation -> result);
+
+ try (GenericTestUtils.SystemOutCapturer capture =
+ new GenericTestUtils.SystemOutCapturer()) {
+ cmd.execute(client);
+ assertThat(JsonUtils.readTree(capture.getOutput())).isEqualTo(
+ JsonUtils.readTree("{\"host\":{\"address\":\"host:9894\"}}"));
}
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]