This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 0026c6f557 HDDS-9305. Make OM service ID optional for `ozone admin om 
roles` if only one is defined in config (#5312)
0026c6f557 is described below

commit 0026c6f5579b8006db2e546249ba6e84313afafd
Author: Pratyush Bhatt <[email protected]>
AuthorDate: Thu Sep 21 17:16:10 2023 +0530

    HDDS-9305. Make OM service ID optional for `ozone admin om roles` if only 
one is defined in config (#5312)
---
 .../dist/src/main/smoketest/omha/om-roles.robot    | 39 ++++++++++++++++++----
 .../ozone/admin/om/GetServiceRolesSubcommand.java  |  2 +-
 .../org/apache/hadoop/ozone/admin/om/OMAdmin.java  |  4 +--
 3 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/hadoop-ozone/dist/src/main/smoketest/omha/om-roles.robot 
b/hadoop-ozone/dist/src/main/smoketest/omha/om-roles.robot
index 9c022a5846..efc4377998 100644
--- a/hadoop-ozone/dist/src/main/smoketest/omha/om-roles.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/omha/om-roles.robot
@@ -19,12 +19,37 @@ Resource            ../commonlib.robot
 Test Timeout        5 minutes
 Test Setup          Run Keyword if    '${SECURITY_ENABLED}' == 'true'    Kinit 
test user     testuser     testuser.keytab
 
+*** Keywords ***
+Assert Leader Present
+     [Arguments]                     ${output}
+     Should Match Regexp             ${output}                      [om (: 
LEADER|)]
+
+Assert Leader Present in JSON
+     [Arguments]                     ${output}
+     ${leader} =                     Execute                        echo 
'${output}' | jq '.[] | select(.[] | .serverRole == "LEADER")'
+                                     Should Not Be Equal            ${leader}  
     ${EMPTY}
+
 *** Test Cases ***
-List om roles
-    ${output} =         Execute          ozone admin om roles 
--service-id=omservice
-                        Should Match Regexp   ${output}  [om (: LEADER|)]
+List om roles with OM service ID passed
+    ${output_with_id_passed} =      Execute                         ozone 
admin om roles --service-id=omservice
+                                    Assert Leader Present           
${output_with_id_passed}
+    ${output_with_id_passed} =      Execute                         ozone 
admin --set=ozone.om.service.ids=omservice,omservice2 om roles 
--service-id=omservice
+                                    Assert Leader Present           
${output_with_id_passed}
+
+List om roles without OM service ID passed
+    ${output_without_id_passed} =   Execute                         ozone 
admin om roles
+                                    Assert Leader Present           
${output_without_id_passed}
+    ${output_without_id_passed} =   Execute And Ignore Error        ozone 
admin --set=ozone.om.service.ids=omservice,omservice2 om roles
+                                    Should Contain                  
${output_without_id_passed}      no Ozone Manager service ID specified
+
+List om roles as JSON with OM service ID passed
+    ${output_with_id_passed} =      Execute                         ozone 
admin om roles --service-id=omservice --json
+                                    Assert Leader Present in JSON   
${output_with_id_passed}
+    ${output_with_id_passed} =      Execute                         ozone 
admin --set=ozone.om.service.ids=omservice,omservice2 om roles 
--service-id=omservice --json
+                                    Parse json output               
${output_with_id_passed}
 
-List om roles as JSON
-    ${output} =         Execute          ozone admin om roles 
--service-id=omservice --json
-    ${leader} =         Execute          echo '${output}' | jq -r '.[] | 
select(.serverRole == "LEADER")'
-                        Should Not Be Equal       ${leader}       ${EMPTY}
+List om roles as JSON without OM service ID passed
+    ${output_without_id_passed} =   Execute                         ozone 
admin om roles --json
+                                    Assert Leader Present in JSON   
${output_without_id_passed}
+    ${output_without_id_passed} =   Execute And Ignore Error        ozone 
admin --set=ozone.om.service.ids=omservice,omservice2 om roles --json
+                                    Should Contain                  
${output_without_id_passed}      no Ozone Manager service ID specified
diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/GetServiceRolesSubcommand.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/GetServiceRolesSubcommand.java
index 67b20a51b2..2a25dfbd10 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/GetServiceRolesSubcommand.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/GetServiceRolesSubcommand.java
@@ -49,7 +49,7 @@ public class GetServiceRolesSubcommand implements 
Callable<Void> {
 
   @CommandLine.Option(names = {"-id", "--service-id"},
       description = "OM Service ID",
-      required = true)
+      required = false)
   private String omServiceId;
 
   @CommandLine.Option(names = { "--json" },
diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/OMAdmin.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/OMAdmin.java
index d3b36db6d8..ce7d4ed7a7 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/OMAdmin.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/OMAdmin.java
@@ -133,8 +133,8 @@ public class OMAdmin extends GenericCli implements 
SubcommandWithParent {
   private String getTheOnlyConfiguredOmServiceIdOrThrow() {
     if (getConfiguredServiceIds().size() != 1) {
       throw new IllegalArgumentException("There is no Ozone Manager service ID 
"
-          + "specified, but there are either zero, or more than one service "
-          + "configured. Please specify the service ID to be finalized.");
+          + "specified, but there are either zero, or more than one service ID"
+          + "configured.");
     }
     return getConfiguredServiceIds().iterator().next();
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to