Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions hadoop-ozone/dist/src/main/smoketest/s3/s3_getsecret.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

*** Settings ***
Documentation Test ozone s3 getsecret command
Resource ../commonlib.robot
Test Timeout 2 minutes

*** Keywords ***
Verify output
[arguments] ${output}
Should contain ${output} awsAccessKey
Should contain ${output} awsSecret

*** Test Cases ***
Without OM service ID
Pass Execution If '${SECURITY_ENABLED}' == 'false' N/A
${output} = Execute ozone s3 getsecret -u testuser2
Verify output ${output}

With OM service ID
Pass Execution If '${OM_HA_PARAM}' == '${EMPTY}' duplicate test in non-HA env.
Pass Execution If '${SECURITY_ENABLED}' == 'false' N/A
${output} = Execute ozone s3 getsecret -u testuser2 ${OM_HA_PARAM}
Verify output ${output}
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ public OzoneClient createClientForS3Commands(
String omServiceID
)
throws IOException, OzoneClientException {
Collection<String> serviceIds = conf.
getTrimmedStringCollection(OZONE_OM_SERVICE_IDS_KEY);
if (omServiceID != null) {
// OM HA cluster
if (OmUtils.isOmHAServiceId(conf, omServiceID)) {
Expand All @@ -195,20 +197,19 @@ public OzoneClient createClientForS3Commands(
throw new OzoneClientException("Service ID specified does not match" +
" with " + OZONE_OM_SERVICE_IDS_KEY + " defined in the " +
"configuration. Configured " + OZONE_OM_SERVICE_IDS_KEY + " are" +
conf.getTrimmedStringCollection(OZONE_OM_SERVICE_IDS_KEY));
serviceIds);
}
} else {
// If om service id is not specified, consider it as a non-HA cluster.
// But before that check if serviceId is defined. If it is defined
// throw an error om service ID needs to be specified.
if (OmUtils.isServiceIdsDefined(conf)) {
throw new OzoneClientException("Service ID must not"
+ " be omitted when " + OZONE_OM_SERVICE_IDS_KEY + " is defined. " +
"Configured " + OZONE_OM_SERVICE_IDS_KEY + " are " +
conf.getTrimmedStringCollection(OZONE_OM_SERVICE_IDS_KEY));
}
return OzoneClientFactory.getRpcClient(conf);
} else if (serviceIds.size() > 1) {
// If multiple om service ids are there,
// throw an error "om service ID must not be omitted"
throw new OzoneClientException("Service ID must not"
+ " be omitted when cluster has multiple OM Services." +
" Configured " + OZONE_OM_SERVICE_IDS_KEY + " are "
+ serviceIds);
}
// for non-HA cluster and HA cluster with only 1 service ID
// get service ID from configurations
return OzoneClientFactory.getRpcClient(conf);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public abstract class S3Handler extends Handler {

@CommandLine.Option(names = {"--om-service-id"},
required = false,
description = "OM Service ID is required to be specified for OM HA" +
" cluster")
description = "OM Service ID for OM HA, " +
"required when cluster has multiple OM services")
private String omServiceID;

public String getOmServiceID() {
Expand Down