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
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ public OzoneClient(ConfigurationSource conf, ClientProtocol proxy) {
}

@VisibleForTesting
protected OzoneClient(ObjectStore objectStore) {
protected OzoneClient(ObjectStore objectStore,
ClientProtocol clientProtocol) {
this.objectStore = objectStore;
this.proxy = null;
this.proxy = clientProtocol;
// For the unit test
this.conf = new OzoneConfiguration();
}
Expand Down Expand Up @@ -120,4 +121,12 @@ public ConfigurationSource getConfiguration() {
public void close() throws IOException {
proxy.close();
}

/**
* Return the ClientProtocol associated with the Ozone Cluster.
* @return ClientProtocol
*/
public ClientProtocol getProxy() {
return proxy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1976,8 +1976,8 @@ public Cache<URI, KeyProvider> getKeyProviderCache() {
@Override
public OzoneKey headObject(String volumeName, String bucketName,
String keyName) throws IOException {
Preconditions.checkNotNull(volumeName);
Preconditions.checkNotNull(bucketName);
verifyVolumeName(volumeName);
verifyBucketName(bucketName);
Preconditions.checkNotNull(keyName);
OmKeyArgs keyArgs = new OmKeyArgs.Builder()
.setVolumeName(volumeName)
Expand Down
47 changes: 47 additions & 0 deletions hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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

*** Variables ***
${ENDPOINT_URL} http://s3g:9878
${OZONE_TEST} true
${BUCKET} generated

*** Test Cases ***

Head existing object
Execute echo "Randomtext" > /tmp/testfile
${result} = Execute AWSS3APICli and checkrc put-object --bucket ${BUCKET} --key ${PREFIX}/headobject/key=value/f1 --body /tmp/testfile 0

${result} = Execute AWSS3APICli and checkrc head-object --bucket ${BUCKET} --key ${PREFIX}/headobject/key=value/f1 0
${result} = Execute AWSS3APICli and checkrc delete-object --bucket ${BUCKET} --key ${PREFIX}/headobject/key=value/f1 0

Head object in non existing bucket
${result} = Execute AWSS3APICli and checkrc head-object --bucket ${BUCKET}-non-existent --key ${PREFIX}/headobject/key=value/f1 255
Should contain ${result} 404
Should contain ${result} Not Found

Head non existing key
${result} = Execute AWSS3APICli and checkrc head-object --bucket ${BUCKET} --key ${PREFIX}/non-existent 255
Should contain ${result} 404
Should contain ${result} Not Found
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ run_robot_test objectputget
run_robot_test objectdelete
run_robot_test objectcopy
run_robot_test objectmultidelete
run_robot_test objecthead
run_robot_test MultipartUpload

rebot --outputdir results/ results/*.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes;
import org.apache.hadoop.ozone.om.protocol.S3Auth;
Expand Down Expand Up @@ -284,6 +285,10 @@ public OzoneClient getClient() {
return client;
}

protected ClientProtocol getClientProtocol() {
return getClient().getProxy();
}

@VisibleForTesting
public S3GatewayMetrics getMetrics() {
return S3GatewayMetrics.create();
Expand Down
Loading