rakeshadr commented on code in PR #3377: URL: https://github.com/apache/ozone/pull/3377#discussion_r870028326
########## hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java: ########## @@ -0,0 +1,263 @@ +/** + * 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.ozone.om; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.ozone.MiniOzoneCluster; +import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl; +import org.apache.hadoop.ozone.client.ObjectStore; +import org.apache.hadoop.ozone.client.OzoneClientFactory; +import org.apache.hadoop.ozone.client.protocol.ClientProtocol; +import org.apache.hadoop.ozone.om.exceptions.OMException; +import org.apache.hadoop.ozone.om.helpers.BucketLayout; +import org.apache.hadoop.ozone.om.helpers.OmBucketInfo; +import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; +import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol; +import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature; +import org.apache.hadoop.ozone.upgrade.UpgradeFinalizer; +import org.apache.ozone.test.LambdaTestUtils; +import org.junit.Test; +import org.junit.Before; +import org.junit.After; +import org.junit.Rule; +import org.junit.rules.Timeout; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.Collection; +import java.util.UUID; + +import static org.apache.hadoop.ozone.OzoneConsts.LAYOUT_VERSION_KEY; +import static org.apache.hadoop.ozone.om.OMUpgradeTestUtils.waitForFinalization; +import static org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature.ERASURE_CODED_STORAGE_SUPPORT; +import static org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature.INITIAL_VERSION; +import static org.apache.hadoop.ozone.om.upgrade.OMLayoutVersionManager.maxLayoutVersion; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Upgrade testing for Bucket Layout Feature. + * <p> + * Expected behavior: + * 1. Pre-Finalize: OM should not allow creation of buckets with new bucket + * layouts. Only LEGACY buckets are allowed. + * <p> + * 2. Post-Finalize: OM should allow creation of buckets with new bucket + * layouts. + */ +@RunWith(Parameterized.class) +public class TestOMBucketLayoutUpgrade { + /** + * Set a timeout for each test. + */ + @Rule + public Timeout timeout = new Timeout(300000); + private MiniOzoneHAClusterImpl cluster; + private OzoneManager ozoneManager; + private ClientProtocol clientProtocol; + private static final BucketLayout[] BUCKET_LAYOUTS = + new BucketLayout[]{ + BucketLayout.FILE_SYSTEM_OPTIMIZED, + BucketLayout.OBJECT_STORE, + BucketLayout.LEGACY + }; + private static final String VOLUME_NAME = "vol-" + UUID.randomUUID(); + private int fromLayoutVersion; + private OzoneManagerProtocol omClient; + + private static final Logger LOG = + LoggerFactory.getLogger(TestOMBucketLayoutUpgrade.class); + + /** + * Defines a "from" layout version to finalize from. + * + * @return + */ + @Parameterized.Parameters + public static Collection<Object[]> data() { + return Arrays.asList(new Object[][]{ + {INITIAL_VERSION}, + {ERASURE_CODED_STORAGE_SUPPORT}, Review Comment: Should we add `BUCKET_LAYOUT_SUPPORT` here? ########## hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java: ########## @@ -0,0 +1,263 @@ +/** + * 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.ozone.om; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.ozone.MiniOzoneCluster; +import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl; +import org.apache.hadoop.ozone.client.ObjectStore; +import org.apache.hadoop.ozone.client.OzoneClientFactory; +import org.apache.hadoop.ozone.client.protocol.ClientProtocol; +import org.apache.hadoop.ozone.om.exceptions.OMException; +import org.apache.hadoop.ozone.om.helpers.BucketLayout; +import org.apache.hadoop.ozone.om.helpers.OmBucketInfo; +import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; +import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol; +import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature; +import org.apache.hadoop.ozone.upgrade.UpgradeFinalizer; +import org.apache.ozone.test.LambdaTestUtils; +import org.junit.Test; +import org.junit.Before; +import org.junit.After; +import org.junit.Rule; +import org.junit.rules.Timeout; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.Collection; +import java.util.UUID; + +import static org.apache.hadoop.ozone.OzoneConsts.LAYOUT_VERSION_KEY; +import static org.apache.hadoop.ozone.om.OMUpgradeTestUtils.waitForFinalization; +import static org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature.ERASURE_CODED_STORAGE_SUPPORT; +import static org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature.INITIAL_VERSION; +import static org.apache.hadoop.ozone.om.upgrade.OMLayoutVersionManager.maxLayoutVersion; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Upgrade testing for Bucket Layout Feature. + * <p> + * Expected behavior: + * 1. Pre-Finalize: OM should not allow creation of buckets with new bucket + * layouts. Only LEGACY buckets are allowed. + * <p> + * 2. Post-Finalize: OM should allow creation of buckets with new bucket + * layouts. + */ +@RunWith(Parameterized.class) +public class TestOMBucketLayoutUpgrade { + /** + * Set a timeout for each test. + */ + @Rule + public Timeout timeout = new Timeout(300000); + private MiniOzoneHAClusterImpl cluster; + private OzoneManager ozoneManager; + private ClientProtocol clientProtocol; + private static final BucketLayout[] BUCKET_LAYOUTS = + new BucketLayout[]{ + BucketLayout.FILE_SYSTEM_OPTIMIZED, + BucketLayout.OBJECT_STORE, + BucketLayout.LEGACY + }; + private static final String VOLUME_NAME = "vol-" + UUID.randomUUID(); + private int fromLayoutVersion; + private OzoneManagerProtocol omClient; + + private static final Logger LOG = + LoggerFactory.getLogger(TestOMBucketLayoutUpgrade.class); + + /** + * Defines a "from" layout version to finalize from. + * + * @return + */ + @Parameterized.Parameters + public static Collection<Object[]> data() { + return Arrays.asList(new Object[][]{ + {INITIAL_VERSION}, + {ERASURE_CODED_STORAGE_SUPPORT}, + }); + } + + + public TestOMBucketLayoutUpgrade(OMLayoutFeature fromVersion) { + this.fromLayoutVersion = fromVersion.layoutVersion(); + } + + /** + * Create a MiniDFSCluster for testing. + */ + @Before + public void setup() throws Exception { + org.junit.Assume.assumeTrue("Check if there is need to finalize.", + maxLayoutVersion() > fromLayoutVersion); + + OzoneConfiguration conf = new OzoneConfiguration(); + String omServiceId = UUID.randomUUID().toString(); + cluster = (MiniOzoneHAClusterImpl) MiniOzoneCluster.newOMHABuilder(conf) + .setClusterId(UUID.randomUUID().toString()) + .setScmId(UUID.randomUUID().toString()) + .setOMServiceId(omServiceId) + .setNumOfOzoneManagers(3) + .setNumDatanodes(1) + .setOmLayoutVersion(fromLayoutVersion) + .build(); + + cluster.waitForClusterToBeReady(); + ozoneManager = cluster.getOzoneManager(); + ObjectStore objectStore = OzoneClientFactory.getRpcClient(omServiceId, conf) + .getObjectStore(); + clientProtocol = objectStore.getClientProxy(); + omClient = clientProtocol.getOzoneManagerClient(); + + // create sample volume. + omClient.createVolume( + new OmVolumeArgs.Builder() + .setVolume(VOLUME_NAME) + .setOwnerName("user1") + .setAdminName("user1") + .build()); + } + + /** + * Shutdown MiniDFSCluster. + */ + @After + public void shutdown() { + if (cluster != null) { + cluster.shutdown(); + } + } + + /** + * Tests that OM blocks all requests to create any buckets with a new bucket + * layout. + * + * @throws Exception + */ + @Test + public void testCreateBucketWithNewLayoutsPreFinalize() throws Exception { + // Assert OM layout version is 'fromLayoutVersion' on deploy. + assertEquals(fromLayoutVersion, + ozoneManager.getVersionManager().getMetadataLayoutVersion()); + assertNull(ozoneManager.getMetadataManager().getMetaTable() + .get(LAYOUT_VERSION_KEY)); + + for (BucketLayout layout : BUCKET_LAYOUTS) { + if (layout.isLegacy()) { + // We only want to test out the newly introduced layouts in this test. Review Comment: Instead of skipping LEGACY, how about adding a test by sending LEGACY layout explicitly to CreateBucket Req? Probably you can rename the `testCreateBucketWithNewLayoutsPreFinalize` test to `testCreateBucketWithBucketLayoutsPreFinalize`. After that we can remove `testCreateLegacyBucketPreFinalize` test, isn't it? ########## hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java: ########## @@ -0,0 +1,263 @@ +/** + * 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.ozone.om; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.ozone.MiniOzoneCluster; +import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl; +import org.apache.hadoop.ozone.client.ObjectStore; +import org.apache.hadoop.ozone.client.OzoneClientFactory; +import org.apache.hadoop.ozone.client.protocol.ClientProtocol; +import org.apache.hadoop.ozone.om.exceptions.OMException; +import org.apache.hadoop.ozone.om.helpers.BucketLayout; +import org.apache.hadoop.ozone.om.helpers.OmBucketInfo; +import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; +import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol; +import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature; +import org.apache.hadoop.ozone.upgrade.UpgradeFinalizer; +import org.apache.ozone.test.LambdaTestUtils; +import org.junit.Test; +import org.junit.Before; +import org.junit.After; +import org.junit.Rule; +import org.junit.rules.Timeout; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.Collection; +import java.util.UUID; + +import static org.apache.hadoop.ozone.OzoneConsts.LAYOUT_VERSION_KEY; +import static org.apache.hadoop.ozone.om.OMUpgradeTestUtils.waitForFinalization; +import static org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature.ERASURE_CODED_STORAGE_SUPPORT; +import static org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature.INITIAL_VERSION; +import static org.apache.hadoop.ozone.om.upgrade.OMLayoutVersionManager.maxLayoutVersion; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Upgrade testing for Bucket Layout Feature. + * <p> + * Expected behavior: + * 1. Pre-Finalize: OM should not allow creation of buckets with new bucket + * layouts. Only LEGACY buckets are allowed. + * <p> + * 2. Post-Finalize: OM should allow creation of buckets with new bucket + * layouts. + */ +@RunWith(Parameterized.class) +public class TestOMBucketLayoutUpgrade { + /** + * Set a timeout for each test. + */ + @Rule + public Timeout timeout = new Timeout(300000); + private MiniOzoneHAClusterImpl cluster; + private OzoneManager ozoneManager; + private ClientProtocol clientProtocol; + private static final BucketLayout[] BUCKET_LAYOUTS = + new BucketLayout[]{ + BucketLayout.FILE_SYSTEM_OPTIMIZED, + BucketLayout.OBJECT_STORE, + BucketLayout.LEGACY + }; + private static final String VOLUME_NAME = "vol-" + UUID.randomUUID(); + private int fromLayoutVersion; + private OzoneManagerProtocol omClient; + + private static final Logger LOG = + LoggerFactory.getLogger(TestOMBucketLayoutUpgrade.class); + + /** + * Defines a "from" layout version to finalize from. + * + * @return + */ + @Parameterized.Parameters + public static Collection<Object[]> data() { + return Arrays.asList(new Object[][]{ + {INITIAL_VERSION}, + {ERASURE_CODED_STORAGE_SUPPORT}, + }); + } + + + public TestOMBucketLayoutUpgrade(OMLayoutFeature fromVersion) { + this.fromLayoutVersion = fromVersion.layoutVersion(); + } + + /** + * Create a MiniDFSCluster for testing. + */ + @Before + public void setup() throws Exception { + org.junit.Assume.assumeTrue("Check if there is need to finalize.", + maxLayoutVersion() > fromLayoutVersion); Review Comment: `maxLayoutVersion() > fromLayoutVersion` , is this` >=` ? ########## hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java: ########## @@ -32,7 +32,10 @@ public enum OMLayoutFeature implements LayoutFeature { INITIAL_VERSION(0, "Initial Layout Version"), ERASURE_CODED_STORAGE_SUPPORT(1, "Ozone version with built in support for" - + " Erasure Coded block data storage."); + + " Erasure Coded block data storage."), + + BUCKET_LAYOUT_SUPPORT(2, "Ozone version supporting bucket " + + "layouts and introducing the FSO and OBS bucket layout types."); Review Comment: I think, its good to use full name instead of abbreviation. ``` BUCKET_LAYOUT_SUPPORT(2, "Ozone version supporting bucket " + "layouts - introducing FILE_SYSTEM_OPTIMIZED and OBJECT_STORE bucket layout types."); ``` -- 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]
