monthonk commented on code in PR #3877: URL: https://github.com/apache/hadoop/pull/3877#discussion_r865045738
########## hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AStorageClass.java: ########## @@ -0,0 +1,163 @@ +/* + * 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. + */ + +package org.apache.hadoop.fs.s3a; + +import java.nio.file.AccessDeniedException; +import java.util.Map; + +import com.amazonaws.services.s3.model.StorageClass; +import org.assertj.core.api.Assertions; +import org.junit.Test; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.contract.ContractTestUtils; +import org.apache.hadoop.fs.contract.s3a.S3AContract; +import org.apache.hadoop.test.GenericTestUtils; + +import static org.apache.hadoop.fs.s3a.Constants.STORAGE_CLASS; +import static org.apache.hadoop.fs.s3a.S3ATestUtils.disableFilesystemCaching; +import static org.apache.hadoop.fs.s3a.S3ATestUtils.removeBaseAndBucketOverrides; +import static org.apache.hadoop.fs.s3a.impl.HeaderProcessing.XA_STORAGE_CLASS; +import static org.apache.hadoop.fs.s3a.impl.HeaderProcessing.decodeBytes; + +/** + * Tests of storage class. + */ +public class ITestS3AStorageClass extends AbstractS3ATestBase { + + @Override + protected Configuration createConfiguration() { + Configuration conf = super.createConfiguration(); + disableFilesystemCaching(conf); + removeBaseAndBucketOverrides(conf, STORAGE_CLASS); + + return conf; + } + + /* + * This test ensures the default storage class configuration (no config or null) + * works well with create and copy operations + */ + @Test + public void testCreateAndCopyObjectWithStorageClassDefault() throws Throwable { + Configuration conf = this.createConfiguration(); + S3AContract contract = (S3AContract) createContract(conf); + contract.init(); + + FileSystem fs = contract.getTestFileSystem(); + Path dir = methodPath(); + fs.mkdirs(dir); + assertObjectHasNoStorageClass(dir); + Path path = new Path(dir, "file1"); + ContractTestUtils.touch(fs, path); + assertObjectHasNoStorageClass(path); + Path path2 = new Path(dir, "file1"); + fs.rename(path, path2); + assertObjectHasNoStorageClass(path2); + } + + /* + * Verify object can be created and copied correctly + * with specified storage class + */ + @Test + public void testCreateAndCopyObjectWithStorageClassReducedRedundancy() throws Throwable { + Configuration conf = this.createConfiguration(); + conf.set(STORAGE_CLASS, StorageClass.ReducedRedundancy.toString()); Review Comment: i don't mind adding them in Constants file, but we will have to keep it up to date with aws-sdk. i wonder if it's ok? -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org