rakeshadr commented on code in PR #3528: URL: https://github.com/apache/ozone/pull/3528#discussion_r902118253
########## hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSBucketLayout.java: ########## @@ -0,0 +1,224 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.ozone; + +import org.apache.commons.io.IOUtils; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.hdds.scm.OzoneClientConfig; +import org.apache.hadoop.ozone.OzoneConfigKeys; +import org.apache.hadoop.ozone.client.ObjectStore; +import org.apache.hadoop.ozone.client.OzoneBucket; +import org.apache.hadoop.ozone.om.TrashPolicyOzone; +import org.apache.hadoop.ozone.om.exceptions.OMException; +import org.apache.hadoop.ozone.om.helpers.BucketLayout; +import org.junit.Assert; +import org.junit.Before; +import org.junit.After; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.io.IOException; +import java.util.concurrent.TimeoutException; + +import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_ITERATE_BATCH_SIZE; +import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER; +import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY; +import static org.junit.Assert.fail; + +import org.apache.hadoop.fs.CommonConfigurationKeysPublic; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.TrashPolicy; +import org.apache.hadoop.ozone.MiniOzoneCluster; +import org.apache.hadoop.ozone.OzoneConsts; +import org.apache.hadoop.ozone.TestDataUtil; + +import java.util.Arrays; +import java.util.Collection; + +/** + * Ozone file system tests to validate default bucket layout configuration + * and behaviour. + * TODO: Refactor this and TestOzoneFileSystem to reduce duplication. + */ +@RunWith(Parameterized.class) +public class TestOzoneFSBucketLayout { + + private static BucketLayout defaultBucketLayout; + + private static MiniOzoneCluster cluster = null; + private static FileSystem fs; + private static ObjectStore objectStore; + private static BasicRootedOzoneClientAdapterImpl adapter; + + private String volumeName; + private Path volumePath; + + @Parameterized.Parameters + public static Collection<BucketLayout> data() { + return Arrays.asList( + null, + BucketLayout.FILE_SYSTEM_OPTIMIZED, + BucketLayout.LEGACY, + BucketLayout.OBJECT_STORE + ); + } + + public TestOzoneFSBucketLayout(BucketLayout bucketLayout) { + // Ignored. Actual init done in initParam(). + // This empty constructor is still required to avoid argument exception. + } + + @Parameterized.BeforeParam + public static void initParam(BucketLayout bucketLayout) + throws IOException, InterruptedException, TimeoutException { + // Initialize the cluster before EACH set of parameters + defaultBucketLayout = bucketLayout; + + initClusterAndEnv(); + } + + @Parameterized.AfterParam + public static void teardownParam() { + // Tear down the cluster after EACH set of parameters + if (cluster != null) { + cluster.shutdown(); + } + IOUtils.closeQuietly(fs); + } + + @Before + public void createVolumeAndBucket() throws IOException { + // create a volume and a bucket to be used by RootedOzoneFileSystem (OFS) + volumeName = + TestDataUtil.createVolumeAndBucket(cluster) + .getVolumeName(); + volumePath = new Path(OZONE_URI_DELIMITER, volumeName); + } + + @After + public void cleanup() throws IOException { + if (defaultBucketLayout != null && + defaultBucketLayout.equals(BucketLayout.OBJECT_STORE)) { + return; + } + fs.delete(volumePath, true); + } + + public static FileSystem getFs() { Review Comment: remove this un used method. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
