Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
36 changes: 36 additions & 0 deletions hadoop-ozone/dist/src/main/smoketest/s3/s3_serviceId.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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 S3 gateway test with aws cli
Library OperatingSystem
Library String
Resource ../commonlib.robot
Resource commonawslib.robot
Test Timeout 5 minutes
Suite Setup Setup s3 tests

*** Test Cases ***
Get-secret without om-service-id
Run Keyword Kinit test user testuser testuser.keytab
${output}= Execute ozone s3 getsecret -u testuser
Should contain ${output} awsAccessKey
Should contain ${output} awsSecret

Get-secret with om-service-id
Run Keyword Kinit test user testuser testuser.keytab
${output}= Execute ozone s3 getsecret -u testuser ${OM_HA_PARAM}
Should contain ${output} awsAccessKey
Should contain ${output} awsSecret
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,17 +197,23 @@ 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.
// and has length = 1, then take that ID as default.
// otherwise 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));
if (serviceIds.size() == 1) {
return OzoneClientFactory.getRpcClient(serviceIds.iterator().next(),
conf);
} else {
throw new OzoneClientException("Service ID must not"
+ " be omitted when cluster has multiple OM Services." +
" Configured " + OZONE_OM_SERVICE_IDS_KEY + " are "
+ serviceIds);
}
}
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