From 77d9bfe6a30f783de4edd8e372770952c11f69e5 Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Mon, 2 May 2022 17:22:11 +0530 Subject: [PATCH 01/12] HDDS-6680. Pre-Finalize behaviour for Bucket Layout Feature. --- .../hadoop/ozone/om/helpers/BucketLayout.java | 4 ++ .../dist/src/main/compose/upgrade/testlib.sh | 8 +++ .../1.2.1-1.3.0/callback.sh | 2 + .../dist/src/main/compose/xcompat/test.sh | 28 ++++++++++- .../bucketlayout/backward-compat.robot | 46 +++++++++++++++++ .../main/smoketest/bucketlayout/lib.resource | 31 ++++++++++++ .../upgrade-bucket-layout-check.robot | 50 +++++++++++++++++++ .../request/bucket/OMBucketCreateRequest.java | 48 ++++++++++++++++++ .../ozone/om/upgrade/OMLayoutFeature.java | 5 +- .../OzoneManagerRequestHandler.java | 31 ++++++++++++ 10 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot create mode 100644 hadoop-ozone/dist/src/main/smoketest/bucketlayout/lib.resource create mode 100644 hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/BucketLayout.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/BucketLayout.java index 00118ccad368..a9803e03e4a9 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/BucketLayout.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/BucketLayout.java @@ -65,6 +65,10 @@ public boolean isFileSystemOptimized() { return this.equals(FILE_SYSTEM_OPTIMIZED); } + public boolean isLegacy() { + return this.equals(LEGACY); + } + public boolean shouldNormalizePaths(boolean enableFileSystemPaths) { switch (this) { case OBJECT_STORE: diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh b/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh index b3fa1df3bc7e..6234fdc91625 100755 --- a/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh +++ b/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh @@ -157,4 +157,12 @@ check_ec_is_disabled() { check_ec_is_enabled() { execute_robot_test scm --include post-finalized-ec-tests ec/upgrade-ec-check.robot +} + +check_bucket_layout_is_disabled() { + execute_robot_test scm --include pre-finalized-bucket-layout-tests ec/upgrade-bucket-layout-check.robot +} + +check_bucket_layout_is_enabled() { + execute_robot_test scm --include post-finalized-bucket-layout-tests ec/upgrade-bucket-layout-check.robot } \ No newline at end of file diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh index f414ddf43f7c..a86d7114c01b 100755 --- a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh +++ b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh @@ -55,6 +55,7 @@ with_new_version_pre_finalized() { validate new1 check_ec_is_disabled + check_bucket_layout_is_disabled } with_old_version_downgraded() { @@ -81,4 +82,5 @@ with_new_version_finalized() { validate new2 check_ec_is_enabled + check_bucket_layout_is_enabled } diff --git a/hadoop-ozone/dist/src/main/compose/xcompat/test.sh b/hadoop-ozone/dist/src/main/compose/xcompat/test.sh index f583a2b342b7..20bc16e3d9c7 100755 --- a/hadoop-ozone/dist/src/main/compose/xcompat/test.sh +++ b/hadoop-ozone/dist/src/main/compose/xcompat/test.sh @@ -112,6 +112,30 @@ test_ec_cross_compatibility() { done } +test_bucket_layout_cross_compatibility() { + echo "Running Bucket Layout backward compatibility tests." + local cluster_versions_with_bucket_layout="1.3.0" + local non_bucket_layout_client_versions="1.0.0 1.1.0 1.2.1" + + for cluster_version in ${cluster_versions_with_bucket_layout}; do + export COMPOSE_FILE=new-cluster.yaml:clients.yaml cluster_version=${cluster_version} + OZONE_KEEP_RESULTS=true start_docker_env 5 + + local prefix=$(LC_CTYPE=C tr -dc '[:alnum:]' < /dev/urandom | head -c 5 | tr '[:upper:]' '[:lower:]') + OZONE_DIR=/opt/hadoop + execute_robot_test new_client -N "xcompat-cluster-${cluster_version}-setup-data" -v prefix:"${prefix}" bucketlayout/backward-compat.robot + OZONE_DIR=/opt/ozone + + for client_version in ${non_bucket_layout_client_versions}; do + client="old_client_${client_version//./_}" + unset OUTPUT_PATH + execute_robot_test "${client}" -N "xcompat-cluster-${cluster_version}-client-${client_version}-read-${cluster_version}" -v prefix:"${prefix}" bucketlayout/backward-compat.robot + done + + KEEP_RUNNING=false stop_docker_env + done +} + create_results_dir # current cluster with various clients @@ -123,6 +147,8 @@ for cluster_version in ${old_versions}; do COMPOSE_FILE=old-cluster.yaml:clients.yaml test_cross_compatibility ${cluster_version} done -test_ec_cross_compatibility +#test_ec_cross_compatibility + +test_bucket_layout_cross_compatibility generate_report diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot new file mode 100644 index 000000000000..77d8156c2641 --- /dev/null +++ b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot @@ -0,0 +1,46 @@ +# 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 Test Bucket Layout backward compatibility +Library OperatingSystem +Resource lib.resource + +*** Test Cases *** +Setup Cluster Data + [Tags] setup-bucket-layout-data + Prepare Data For Xcompat Tests + +Test Info Compat + [Tags] test-bucket-layout-compat + ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}default_FSO + Should Contain ${result} NOT_SUPPORTED_OPERATION + + ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}default_OBS + Should Contain ${result} NOT_SUPPORTED_OPERATION + + ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}default_LEGACY | grep name + Should Contain ${result} ${prefix}default_LEGACY + +#Test Listing Compat +# [Tags] test-bucket-layout-compat +# ToDo: Need to add a test case for listing buckets. + +Test Bucket Create + [Tags] test-bucket-layout-compat + ${random} = Generate Random String 5 [NUMBERS] + ${result} = Execute and checkrc ozone sh bucket create /${prefix}vol1/${prefix}_create_${random} + ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}_create_${random} + Should Not Contain ${result} NOT_SUPPORTED_OPERATION \ No newline at end of file diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/lib.resource b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/lib.resource new file mode 100644 index 000000000000..0b150c0d3b84 --- /dev/null +++ b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/lib.resource @@ -0,0 +1,31 @@ +# 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 Keywords and other resources used by EC tests +Library OperatingSystem +Resource ../commonlib.robot +Resource ../ozone-lib/shell.robot + +*** Variables *** +${SCM} scm + +*** Keywords *** +# xcompat/test.sh creates unified test data files in /tmp for client containers + Prepare Data For Xcompat Tests + Execute ozone sh volume create /${prefix}vol1 + Execute ozone sh bucket create /${prefix}vol1/${prefix}default_FSO --layout FILE_SYSTEM_OPTIMIZED + Execute ozone sh bucket create /${prefix}vol1/${prefix}default_OBS --layout OBJECT_STORE + Execute ozone sh bucket create /${prefix}vol1/${prefix}default_LEGACY --layout LEGACY diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot new file mode 100644 index 000000000000..1b5f10f4ab04 --- /dev/null +++ b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot @@ -0,0 +1,50 @@ +# 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 Test EC during upgrade +Library OperatingSystem +Resource lib.resource + +*** Test Cases *** +Test Bucket Layout Prior To Finalization + [Tags] pre-finalized-bucket-layout-tests + Execute ozone sh volume create /bucket-layout-test + ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test/fsoBucket --layout FILE_SYSTEM_OPTIMIZED + Should contain ${result} NOT_SUPPORTED_OPERATION + ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test/obsBucket --layout OBJECT_STORE + Should contain ${result} NOT_SUPPORTED_OPERATION + ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test/legacyBucket --layout LEGACY + Should Not contain ${result} NOT_SUPPORTED_OPERATION + + + +Test Bucket Layout After Finalization + [Tags] post-finalized-bucket-layout-tests + Execute ozone sh volume create /bucket-layout-test-new + ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test-new/fsoBucket-new --layout FILE_SYSTEM_OPTIMIZED + Should Not contain ${result} NOT_SUPPORTED_OPERATION + ${result} = Execute and checkrc ozone sh bucket info bucket-layout-test-new/fsoBucket-new + Should contain ${result} FILE_SYSTEM_OPTIMIZED + + ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test-new/obsBucket-new --layout OBJECT_STORE + Should Not contain ${result} NOT_SUPPORTED_OPERATION + ${result} = Execute and checkrc ozone sh bucket info bucket-layout-test-new/obsBucket-new + Should contain ${result} OBJECT_STORE + + ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test-new/legacyBucket-new --layout LEGACY + Should Not contain ${result} NOT_SUPPORTED_OPERATION + ${result} = Execute and checkrc ozone sh bucket info bucket-layout-test-new/legacyBucket-new + Should contain ${result} LEGACY diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java index 37d3e71d6beb..8246b7552ab4 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java @@ -393,4 +393,52 @@ public static OMRequest disallowCreateBucketWithECReplicationConfig( } return req; } + + @RequestFeatureValidator( + conditions = ValidationCondition.CLUSTER_NEEDS_FINALIZATION, + processingPhase = RequestProcessingPhase.PRE_PROCESS, + requestType = Type.CreateBucket + ) + public static OMRequest disallowCreateBucketWithBucketLayoutDuringPreFinalize( + OMRequest req, ValidationContext ctx) throws OMException { + if (!ctx.versionManager() + .isAllowed(OMLayoutFeature.BUCKET_LAYOUT_SUPPORT)) { + if (req.getCreateBucketRequest() + .getBucketInfo().hasBucketLayout() + && + !BucketLayout.fromProto(req.getCreateBucketRequest().getBucketInfo() + .getBucketLayout()).isLegacy()) { + throw new OMException("Cluster does not have the Bucket Layout" + + " support feature finalized yet, but the request contains" + + " a non LEGACY bucket type. Rejecting the request," + + " please finalize the cluster upgrade and then try again.", + OMException.ResultCodes.NOT_SUPPORTED_OPERATION_PRIOR_FINALIZATION); + } + } + return req; + } + + @RequestFeatureValidator( + conditions = ValidationCondition.OLDER_CLIENT_REQUESTS, + processingPhase = RequestProcessingPhase.PRE_PROCESS, + requestType = Type.CreateBucket + ) + public static OMRequest disallowCreateBucketWithBucketLayoutFromOlderClient( + OMRequest req, ValidationContext ctx) throws OMException { + if (!ctx.versionManager() + .isAllowed(OMLayoutFeature.BUCKET_LAYOUT_SUPPORT)) { + if (req.getCreateBucketRequest() + .getBucketInfo().hasBucketLayout() + && + !BucketLayout.fromProto(req.getCreateBucketRequest().getBucketInfo() + .getBucketLayout()).isLegacy()) { + throw new OMException("Cluster does not have the Bucket Layout" + + " support feature finalized yet, but the request contains" + + " a non LEGACY bucket type. Rejecting the request," + + " please finalize the cluster upgrade and then try again.", + OMException.ResultCodes.NOT_SUPPORTED_OPERATION); + } + } + return req; + } } diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java index aa639b297645..c968e40f37c2 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java +++ b/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 with built in support for" + + " bucket layouts."); /////////////////////////////// ///////////////////////////// diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java index ecec94592d94..7cefeba4c65f 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java @@ -44,6 +44,7 @@ import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.helpers.ServiceInfo; import org.apache.hadoop.ozone.om.helpers.ServiceInfoEx; +import org.apache.hadoop.ozone.om.helpers.BucketLayout; import org.apache.hadoop.ozone.om.ratis.OzoneManagerDoubleBuffer; import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerRatisUtils; import org.apache.hadoop.ozone.om.request.OMClientRequest; @@ -386,6 +387,36 @@ private InfoBucketResponse infoBucket(InfoBucketRequest request) return resp.build(); } + @RequestFeatureValidator( + conditions = ValidationCondition.OLDER_CLIENT_REQUESTS, + processingPhase = RequestProcessingPhase.POST_PROCESS, + requestType = Type.InfoBucket + ) + public static OMResponse disallowInfoBucketResponseWithBucketLayout( + OMRequest req, OMResponse resp, ValidationContext ctx) + throws ServiceException { + if (!resp.hasInfoBucketResponse()) { + return resp; + } + if (resp.getInfoBucketResponse().getBucketInfo().hasBucketLayout() && + !BucketLayout.fromProto( + resp.getInfoBucketResponse().getBucketInfo().getBucketLayout()) + .isLegacy()) { + resp = resp.toBuilder() + .setStatus(Status.NOT_SUPPORTED_OPERATION) + .setMessage("Requested bucket uses Bucket Layout feature, which" + + " the client can not understand.\n" + + "Please upgrade the client before trying to read this bucket's" + + " information: " + + req.getInfoBucketRequest().getVolumeName() + + "/" + req.getInfoBucketRequest().getBucketName() + + ".") + .clearInfoBucketResponse() + .build(); + } + return resp; + } + private LookupKeyResponse lookupKey(LookupKeyRequest request, int clientVersion) throws IOException { LookupKeyResponse.Builder resp = From 68555b44efcd5290b5ab5f4b8e0f4fb1c369a11c Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Mon, 2 May 2022 18:30:23 +0530 Subject: [PATCH 02/12] fix acceptance test --- hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh b/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh index 6234fdc91625..6fd67f2fdcb6 100755 --- a/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh +++ b/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh @@ -160,9 +160,9 @@ check_ec_is_enabled() { } check_bucket_layout_is_disabled() { - execute_robot_test scm --include pre-finalized-bucket-layout-tests ec/upgrade-bucket-layout-check.robot + execute_robot_test scm --include pre-finalized-bucket-layout-tests bucketlayout/upgrade-bucket-layout-check.robot } check_bucket_layout_is_enabled() { - execute_robot_test scm --include post-finalized-bucket-layout-tests ec/upgrade-bucket-layout-check.robot + execute_robot_test scm --include post-finalized-bucket-layout-tests bucketlayout/upgrade-bucket-layout-check.robot } \ No newline at end of file From f08e9b46c21afa73a2dd6144d817fe7dd4527da0 Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Mon, 2 May 2022 22:50:59 +0530 Subject: [PATCH 03/12] fix acceptance test --- .../bucketlayout/backward-compat.robot | 10 +++++----- .../upgrade-bucket-layout-check.robot | 20 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot index 77d8156c2641..f824ce41d054 100644 --- a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot +++ b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot @@ -25,13 +25,13 @@ Setup Cluster Data Test Info Compat [Tags] test-bucket-layout-compat - ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}default_FSO + ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default_FSO Should Contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}default_OBS + ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default_OBS Should Contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}default_LEGACY | grep name + ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default_LEGACY | grep name Should Contain ${result} ${prefix}default_LEGACY #Test Listing Compat @@ -41,6 +41,6 @@ Test Info Compat Test Bucket Create [Tags] test-bucket-layout-compat ${random} = Generate Random String 5 [NUMBERS] - ${result} = Execute and checkrc ozone sh bucket create /${prefix}vol1/${prefix}_create_${random} - ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}_create_${random} + ${result} = Execute ozone sh bucket create /${prefix}vol1/${prefix}_create_${random} + ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}_create_${random} Should Not Contain ${result} NOT_SUPPORTED_OPERATION \ No newline at end of file diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot index 1b5f10f4ab04..53be8a93d489 100644 --- a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot +++ b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot @@ -14,7 +14,7 @@ # limitations under the License. *** Settings *** -Documentation Test EC during upgrade +Documentation Test Bucket Layout during upgrade Library OperatingSystem Resource lib.resource @@ -22,11 +22,11 @@ Resource lib.resource Test Bucket Layout Prior To Finalization [Tags] pre-finalized-bucket-layout-tests Execute ozone sh volume create /bucket-layout-test - ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test/fsoBucket --layout FILE_SYSTEM_OPTIMIZED + ${result} = Execute ozone sh bucket create bucket-layout-test/fsoBucket --layout FILE_SYSTEM_OPTIMIZED Should contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test/obsBucket --layout OBJECT_STORE + ${result} = Execute ozone sh bucket create bucket-layout-test/obsBucket --layout OBJECT_STORE Should contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test/legacyBucket --layout LEGACY + ${result} = Execute ozone sh bucket create bucket-layout-test/legacyBucket --layout LEGACY Should Not contain ${result} NOT_SUPPORTED_OPERATION @@ -34,17 +34,17 @@ Test Bucket Layout Prior To Finalization Test Bucket Layout After Finalization [Tags] post-finalized-bucket-layout-tests Execute ozone sh volume create /bucket-layout-test-new - ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test-new/fsoBucket-new --layout FILE_SYSTEM_OPTIMIZED + ${result} = Execute ozone sh bucket create bucket-layout-test-new/fsoBucket-new --layout FILE_SYSTEM_OPTIMIZED Should Not contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute and checkrc ozone sh bucket info bucket-layout-test-new/fsoBucket-new + ${result} = Execute ozone sh bucket info bucket-layout-test-new/fsoBucket-new Should contain ${result} FILE_SYSTEM_OPTIMIZED - ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test-new/obsBucket-new --layout OBJECT_STORE + ${result} = Execute ozone sh bucket create bucket-layout-test-new/obsBucket-new --layout OBJECT_STORE Should Not contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute and checkrc ozone sh bucket info bucket-layout-test-new/obsBucket-new + ${result} = Execute ozone sh bucket info bucket-layout-test-new/obsBucket-new Should contain ${result} OBJECT_STORE - ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test-new/legacyBucket-new --layout LEGACY + ${result} = Execute ozone sh bucket create bucket-layout-test-new/legacyBucket-new --layout LEGACY Should Not contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute and checkrc ozone sh bucket info bucket-layout-test-new/legacyBucket-new + ${result} = Execute ozone sh bucket info bucket-layout-test-new/legacyBucket-new Should contain ${result} LEGACY From fdd16682e8de9fc3959d57cac3eaba55e6fe24a9 Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Tue, 3 May 2022 22:42:44 +0530 Subject: [PATCH 04/12] fix tests --- .../bucketlayout/backward-compat.robot | 12 ++++++------ .../upgrade-bucket-layout-check.robot | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot index f824ce41d054..e50de50545dc 100644 --- a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot +++ b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot @@ -25,14 +25,14 @@ Setup Cluster Data Test Info Compat [Tags] test-bucket-layout-compat - ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default_FSO + ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default-fso Should Contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default_OBS + ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default-obs Should Contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default_LEGACY | grep name - Should Contain ${result} ${prefix}default_LEGACY + ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default-legacy | grep name + Should Contain ${result} ${prefix}default-legacy #Test Listing Compat # [Tags] test-bucket-layout-compat @@ -41,6 +41,6 @@ Test Info Compat Test Bucket Create [Tags] test-bucket-layout-compat ${random} = Generate Random String 5 [NUMBERS] - ${result} = Execute ozone sh bucket create /${prefix}vol1/${prefix}_create_${random} - ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}_create_${random} + ${result} = Execute ozone sh bucket create /${prefix}vol1/${prefix}-create-${random} + ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix-_create-${random} Should Not Contain ${result} NOT_SUPPORTED_OPERATION \ No newline at end of file diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot index 53be8a93d489..b46604f08296 100644 --- a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot +++ b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot @@ -22,11 +22,11 @@ Resource lib.resource Test Bucket Layout Prior To Finalization [Tags] pre-finalized-bucket-layout-tests Execute ozone sh volume create /bucket-layout-test - ${result} = Execute ozone sh bucket create bucket-layout-test/fsoBucket --layout FILE_SYSTEM_OPTIMIZED + ${result} = Execute ozone sh bucket create bucket-layout-test/fso-bucket --layout FILE_SYSTEM_OPTIMIZED Should contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket create bucket-layout-test/obsBucket --layout OBJECT_STORE + ${result} = Execute ozone sh bucket create bucket-layout-test/obs-bucket --layout OBJECT_STORE Should contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket create bucket-layout-test/legacyBucket --layout LEGACY + ${result} = Execute ozone sh bucket create bucket-layout-test/legacy-bucket --layout LEGACY Should Not contain ${result} NOT_SUPPORTED_OPERATION @@ -34,17 +34,17 @@ Test Bucket Layout Prior To Finalization Test Bucket Layout After Finalization [Tags] post-finalized-bucket-layout-tests Execute ozone sh volume create /bucket-layout-test-new - ${result} = Execute ozone sh bucket create bucket-layout-test-new/fsoBucket-new --layout FILE_SYSTEM_OPTIMIZED + ${result} = Execute ozone sh bucket create bucket-layout-test-new/fso-bucket-new --layout FILE_SYSTEM_OPTIMIZED Should Not contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket info bucket-layout-test-new/fsoBucket-new + ${result} = Execute ozone sh bucket info bucket-layout-test-new/fso-bucket-new | grep bucketLayout Should contain ${result} FILE_SYSTEM_OPTIMIZED - ${result} = Execute ozone sh bucket create bucket-layout-test-new/obsBucket-new --layout OBJECT_STORE + ${result} = Execute ozone sh bucket create bucket-layout-test-new/obs-bucket-new --layout OBJECT_STORE Should Not contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket info bucket-layout-test-new/obsBucket-new + ${result} = Execute ozone sh bucket info bucket-layout-test-new/obs-bucket-new | grep bucketLayout Should contain ${result} OBJECT_STORE - ${result} = Execute ozone sh bucket create bucket-layout-test-new/legacyBucket-new --layout LEGACY + ${result} = Execute ozone sh bucket create bucket-layout-test-new/legacy-bucket-new --layout LEGACY Should Not contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket info bucket-layout-test-new/legacyBucket-new + ${result} = Execute ozone sh bucket info bucket-layout-test-new/legacy-bucket-new | grep bucketLayout Should contain ${result} LEGACY From 1c007c42ea0713b347cc65192d11453ed5b24fec Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Wed, 4 May 2022 12:33:06 +0530 Subject: [PATCH 05/12] fix tests --- .../src/main/smoketest/bucketlayout/backward-compat.robot | 6 +++--- .../bucketlayout/upgrade-bucket-layout-check.robot | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot index e50de50545dc..f08611e535fb 100644 --- a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot +++ b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot @@ -25,10 +25,10 @@ Setup Cluster Data Test Info Compat [Tags] test-bucket-layout-compat - ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default-fso + ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}default-fso 255 Should Contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default-obs + ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}default-obs 255 Should Contain ${result} NOT_SUPPORTED_OPERATION ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default-legacy | grep name @@ -42,5 +42,5 @@ Test Bucket Create [Tags] test-bucket-layout-compat ${random} = Generate Random String 5 [NUMBERS] ${result} = Execute ozone sh bucket create /${prefix}vol1/${prefix}-create-${random} - ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix-_create-${random} + ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix-}_create-${random} Should Not Contain ${result} NOT_SUPPORTED_OPERATION \ No newline at end of file diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot index b46604f08296..dec9a951bf8d 100644 --- a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot +++ b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot @@ -22,9 +22,9 @@ Resource lib.resource Test Bucket Layout Prior To Finalization [Tags] pre-finalized-bucket-layout-tests Execute ozone sh volume create /bucket-layout-test - ${result} = Execute ozone sh bucket create bucket-layout-test/fso-bucket --layout FILE_SYSTEM_OPTIMIZED + ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test/fso-bucket --layout FILE_SYSTEM_OPTIMIZED 255 Should contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket create bucket-layout-test/obs-bucket --layout OBJECT_STORE + ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test/obs-bucket --layout OBJECT_STORE 255 Should contain ${result} NOT_SUPPORTED_OPERATION ${result} = Execute ozone sh bucket create bucket-layout-test/legacy-bucket --layout LEGACY Should Not contain ${result} NOT_SUPPORTED_OPERATION From 0624324cfe6eb314a766c15e6f0c143d615f07f0 Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Wed, 4 May 2022 18:42:35 +0530 Subject: [PATCH 06/12] Address comments: remove acceptance test + modify description. --- .../dist/src/main/compose/upgrade/testlib.sh | 8 --- .../1.2.1-1.3.0/callback.sh | 2 - .../dist/src/main/compose/xcompat/test.sh | 27 ---------- .../bucketlayout/backward-compat.robot | 46 ----------------- .../main/smoketest/bucketlayout/lib.resource | 31 ------------ .../upgrade-bucket-layout-check.robot | 50 ------------------- .../request/bucket/OMBucketCreateRequest.java | 45 +++++------------ .../ozone/om/upgrade/OMLayoutFeature.java | 4 +- .../OzoneManagerRequestHandler.java | 30 ----------- 9 files changed, 15 insertions(+), 228 deletions(-) delete mode 100644 hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot delete mode 100644 hadoop-ozone/dist/src/main/smoketest/bucketlayout/lib.resource delete mode 100644 hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh b/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh index 6fd67f2fdcb6..b3fa1df3bc7e 100755 --- a/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh +++ b/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh @@ -157,12 +157,4 @@ check_ec_is_disabled() { check_ec_is_enabled() { execute_robot_test scm --include post-finalized-ec-tests ec/upgrade-ec-check.robot -} - -check_bucket_layout_is_disabled() { - execute_robot_test scm --include pre-finalized-bucket-layout-tests bucketlayout/upgrade-bucket-layout-check.robot -} - -check_bucket_layout_is_enabled() { - execute_robot_test scm --include post-finalized-bucket-layout-tests bucketlayout/upgrade-bucket-layout-check.robot } \ No newline at end of file diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh index a86d7114c01b..f414ddf43f7c 100755 --- a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh +++ b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh @@ -55,7 +55,6 @@ with_new_version_pre_finalized() { validate new1 check_ec_is_disabled - check_bucket_layout_is_disabled } with_old_version_downgraded() { @@ -82,5 +81,4 @@ with_new_version_finalized() { validate new2 check_ec_is_enabled - check_bucket_layout_is_enabled } diff --git a/hadoop-ozone/dist/src/main/compose/xcompat/test.sh b/hadoop-ozone/dist/src/main/compose/xcompat/test.sh index 20bc16e3d9c7..ca54031cc4e7 100755 --- a/hadoop-ozone/dist/src/main/compose/xcompat/test.sh +++ b/hadoop-ozone/dist/src/main/compose/xcompat/test.sh @@ -112,30 +112,6 @@ test_ec_cross_compatibility() { done } -test_bucket_layout_cross_compatibility() { - echo "Running Bucket Layout backward compatibility tests." - local cluster_versions_with_bucket_layout="1.3.0" - local non_bucket_layout_client_versions="1.0.0 1.1.0 1.2.1" - - for cluster_version in ${cluster_versions_with_bucket_layout}; do - export COMPOSE_FILE=new-cluster.yaml:clients.yaml cluster_version=${cluster_version} - OZONE_KEEP_RESULTS=true start_docker_env 5 - - local prefix=$(LC_CTYPE=C tr -dc '[:alnum:]' < /dev/urandom | head -c 5 | tr '[:upper:]' '[:lower:]') - OZONE_DIR=/opt/hadoop - execute_robot_test new_client -N "xcompat-cluster-${cluster_version}-setup-data" -v prefix:"${prefix}" bucketlayout/backward-compat.robot - OZONE_DIR=/opt/ozone - - for client_version in ${non_bucket_layout_client_versions}; do - client="old_client_${client_version//./_}" - unset OUTPUT_PATH - execute_robot_test "${client}" -N "xcompat-cluster-${cluster_version}-client-${client_version}-read-${cluster_version}" -v prefix:"${prefix}" bucketlayout/backward-compat.robot - done - - KEEP_RUNNING=false stop_docker_env - done -} - create_results_dir # current cluster with various clients @@ -147,8 +123,5 @@ for cluster_version in ${old_versions}; do COMPOSE_FILE=old-cluster.yaml:clients.yaml test_cross_compatibility ${cluster_version} done -#test_ec_cross_compatibility - -test_bucket_layout_cross_compatibility generate_report diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot deleted file mode 100644 index f08611e535fb..000000000000 --- a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/backward-compat.robot +++ /dev/null @@ -1,46 +0,0 @@ -# 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 Test Bucket Layout backward compatibility -Library OperatingSystem -Resource lib.resource - -*** Test Cases *** -Setup Cluster Data - [Tags] setup-bucket-layout-data - Prepare Data For Xcompat Tests - -Test Info Compat - [Tags] test-bucket-layout-compat - ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}default-fso 255 - Should Contain ${result} NOT_SUPPORTED_OPERATION - - ${result} = Execute and checkrc ozone sh bucket info /${prefix}vol1/${prefix}default-obs 255 - Should Contain ${result} NOT_SUPPORTED_OPERATION - - ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix}default-legacy | grep name - Should Contain ${result} ${prefix}default-legacy - -#Test Listing Compat -# [Tags] test-bucket-layout-compat -# ToDo: Need to add a test case for listing buckets. - -Test Bucket Create - [Tags] test-bucket-layout-compat - ${random} = Generate Random String 5 [NUMBERS] - ${result} = Execute ozone sh bucket create /${prefix}vol1/${prefix}-create-${random} - ${result} = Execute ozone sh bucket info /${prefix}vol1/${prefix-}_create-${random} - Should Not Contain ${result} NOT_SUPPORTED_OPERATION \ No newline at end of file diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/lib.resource b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/lib.resource deleted file mode 100644 index 0b150c0d3b84..000000000000 --- a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/lib.resource +++ /dev/null @@ -1,31 +0,0 @@ -# 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 Keywords and other resources used by EC tests -Library OperatingSystem -Resource ../commonlib.robot -Resource ../ozone-lib/shell.robot - -*** Variables *** -${SCM} scm - -*** Keywords *** -# xcompat/test.sh creates unified test data files in /tmp for client containers - Prepare Data For Xcompat Tests - Execute ozone sh volume create /${prefix}vol1 - Execute ozone sh bucket create /${prefix}vol1/${prefix}default_FSO --layout FILE_SYSTEM_OPTIMIZED - Execute ozone sh bucket create /${prefix}vol1/${prefix}default_OBS --layout OBJECT_STORE - Execute ozone sh bucket create /${prefix}vol1/${prefix}default_LEGACY --layout LEGACY diff --git a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot b/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot deleted file mode 100644 index dec9a951bf8d..000000000000 --- a/hadoop-ozone/dist/src/main/smoketest/bucketlayout/upgrade-bucket-layout-check.robot +++ /dev/null @@ -1,50 +0,0 @@ -# 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 Test Bucket Layout during upgrade -Library OperatingSystem -Resource lib.resource - -*** Test Cases *** -Test Bucket Layout Prior To Finalization - [Tags] pre-finalized-bucket-layout-tests - Execute ozone sh volume create /bucket-layout-test - ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test/fso-bucket --layout FILE_SYSTEM_OPTIMIZED 255 - Should contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute and checkrc ozone sh bucket create bucket-layout-test/obs-bucket --layout OBJECT_STORE 255 - Should contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket create bucket-layout-test/legacy-bucket --layout LEGACY - Should Not contain ${result} NOT_SUPPORTED_OPERATION - - - -Test Bucket Layout After Finalization - [Tags] post-finalized-bucket-layout-tests - Execute ozone sh volume create /bucket-layout-test-new - ${result} = Execute ozone sh bucket create bucket-layout-test-new/fso-bucket-new --layout FILE_SYSTEM_OPTIMIZED - Should Not contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket info bucket-layout-test-new/fso-bucket-new | grep bucketLayout - Should contain ${result} FILE_SYSTEM_OPTIMIZED - - ${result} = Execute ozone sh bucket create bucket-layout-test-new/obs-bucket-new --layout OBJECT_STORE - Should Not contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket info bucket-layout-test-new/obs-bucket-new | grep bucketLayout - Should contain ${result} OBJECT_STORE - - ${result} = Execute ozone sh bucket create bucket-layout-test-new/legacy-bucket-new --layout LEGACY - Should Not contain ${result} NOT_SUPPORTED_OPERATION - ${result} = Execute ozone sh bucket info bucket-layout-test-new/legacy-bucket-new | grep bucketLayout - Should contain ${result} LEGACY diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java index 8246b7552ab4..930e701d2e9c 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java @@ -84,6 +84,7 @@ public class OMBucketCreateRequest extends OMClientRequest { public OMBucketCreateRequest(OMRequest omRequest) { super(omRequest); } + @Override public OMRequest preExecute(OzoneManager ozoneManager) throws IOException { @@ -130,13 +131,13 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException { newCreateBucketRequest.setBucketInfo(newBucketInfo.build()); return getOmRequest().toBuilder().setUserInfo(getUserInfo()) - .setCreateBucketRequest(newCreateBucketRequest.build()).build(); + .setCreateBucketRequest(newCreateBucketRequest.build()).build(); } @Override public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, - long transactionLogIndex, - OzoneManagerDoubleBufferHelper ozoneManagerDoubleBufferHelper) { + long transactionLogIndex, + OzoneManagerDoubleBufferHelper ozoneManagerDoubleBufferHelper) { OMMetrics omMetrics = ozoneManager.getMetrics(); omMetrics.incNumBucketCreates(); @@ -271,11 +272,12 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, /** * Add default acls for bucket. These acls are inherited from volume * default acl list. + * * @param omBucketInfo * @param omVolumeArgs */ private void addDefaultAcls(OmBucketInfo omBucketInfo, - OmVolumeArgs omVolumeArgs) { + OmVolumeArgs omVolumeArgs) { // Add default acls for bucket creator. List acls = new ArrayList<>(); if (omBucketInfo.getAcls() != null) { @@ -324,7 +326,8 @@ private BucketEncryptionInfoProto getBeinfo( * Check namespace quota. */ private void checkQuotaInNamespace(OmVolumeArgs omVolumeArgs, - long allocatedNamespace) throws IOException { + long allocatedNamespace) + throws IOException { if (omVolumeArgs.getQuotaInNamespace() > 0) { long usedNamespace = omVolumeArgs.getUsedNamespace(); long quotaInNamespace = omVolumeArgs.getQuotaInNamespace(); @@ -340,7 +343,9 @@ private void checkQuotaInNamespace(OmVolumeArgs omVolumeArgs, } public boolean checkQuotaBytesValid(OMMetadataManager metadataManager, - OmVolumeArgs omVolumeArgs, OmBucketInfo omBucketInfo, String volumeKey) + OmVolumeArgs omVolumeArgs, + OmBucketInfo omBucketInfo, + String volumeKey) throws IOException { long quotaInBytes = omBucketInfo.getQuotaInBytes(); long volumeQuotaInBytes = omVolumeArgs.getQuotaInBytes(); @@ -352,7 +357,7 @@ public boolean checkQuotaBytesValid(OMMetadataManager metadataManager, return false; } - List bucketList = metadataManager.listBuckets( + List bucketList = metadataManager.listBuckets( omVolumeArgs.getVolume(), null, null, Integer.MAX_VALUE); for (OmBucketInfo bucketInfo : bucketList) { long nextQuotaInBytes = bucketInfo.getQuotaInBytes(); @@ -417,28 +422,4 @@ public static OMRequest disallowCreateBucketWithBucketLayoutDuringPreFinalize( } return req; } - - @RequestFeatureValidator( - conditions = ValidationCondition.OLDER_CLIENT_REQUESTS, - processingPhase = RequestProcessingPhase.PRE_PROCESS, - requestType = Type.CreateBucket - ) - public static OMRequest disallowCreateBucketWithBucketLayoutFromOlderClient( - OMRequest req, ValidationContext ctx) throws OMException { - if (!ctx.versionManager() - .isAllowed(OMLayoutFeature.BUCKET_LAYOUT_SUPPORT)) { - if (req.getCreateBucketRequest() - .getBucketInfo().hasBucketLayout() - && - !BucketLayout.fromProto(req.getCreateBucketRequest().getBucketInfo() - .getBucketLayout()).isLegacy()) { - throw new OMException("Cluster does not have the Bucket Layout" - + " support feature finalized yet, but the request contains" - + " a non LEGACY bucket type. Rejecting the request," - + " please finalize the cluster upgrade and then try again.", - OMException.ResultCodes.NOT_SUPPORTED_OPERATION); - } - } - return req; - } -} +} \ No newline at end of file diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java index c968e40f37c2..d1092b68b3e2 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java @@ -34,8 +34,8 @@ public enum OMLayoutFeature implements LayoutFeature { ERASURE_CODED_STORAGE_SUPPORT(1, "Ozone version with built in support for" + " Erasure Coded block data storage."), - BUCKET_LAYOUT_SUPPORT(2, "Ozone version with built in support for" - + " bucket layouts."); + BUCKET_LAYOUT_SUPPORT(2, "Ozone version supporting bucket " + + "layouts and introducing the FSO and OBS bucket layout types."); /////////////////////////////// ///////////////////////////// diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java index 7cefeba4c65f..19f990b33eb7 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java @@ -387,36 +387,6 @@ private InfoBucketResponse infoBucket(InfoBucketRequest request) return resp.build(); } - @RequestFeatureValidator( - conditions = ValidationCondition.OLDER_CLIENT_REQUESTS, - processingPhase = RequestProcessingPhase.POST_PROCESS, - requestType = Type.InfoBucket - ) - public static OMResponse disallowInfoBucketResponseWithBucketLayout( - OMRequest req, OMResponse resp, ValidationContext ctx) - throws ServiceException { - if (!resp.hasInfoBucketResponse()) { - return resp; - } - if (resp.getInfoBucketResponse().getBucketInfo().hasBucketLayout() && - !BucketLayout.fromProto( - resp.getInfoBucketResponse().getBucketInfo().getBucketLayout()) - .isLegacy()) { - resp = resp.toBuilder() - .setStatus(Status.NOT_SUPPORTED_OPERATION) - .setMessage("Requested bucket uses Bucket Layout feature, which" - + " the client can not understand.\n" + - "Please upgrade the client before trying to read this bucket's" + - " information: " - + req.getInfoBucketRequest().getVolumeName() - + "/" + req.getInfoBucketRequest().getBucketName() - + ".") - .clearInfoBucketResponse() - .build(); - } - return resp; - } - private LookupKeyResponse lookupKey(LookupKeyRequest request, int clientVersion) throws IOException { LookupKeyResponse.Builder resp = From 9b5387b5ca548e06c26f1e84747f14d3658f7f02 Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Wed, 4 May 2022 18:58:57 +0530 Subject: [PATCH 07/12] checkstyle --- .../dist/src/main/compose/xcompat/test.sh | 1 + .../om/request/bucket/OMBucketCreateRequest.java | 16 ++++++---------- .../protocolPB/OzoneManagerRequestHandler.java | 1 - 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/hadoop-ozone/dist/src/main/compose/xcompat/test.sh b/hadoop-ozone/dist/src/main/compose/xcompat/test.sh index ca54031cc4e7..f583a2b342b7 100755 --- a/hadoop-ozone/dist/src/main/compose/xcompat/test.sh +++ b/hadoop-ozone/dist/src/main/compose/xcompat/test.sh @@ -123,5 +123,6 @@ for cluster_version in ${old_versions}; do COMPOSE_FILE=old-cluster.yaml:clients.yaml test_cross_compatibility ${cluster_version} done +test_ec_cross_compatibility generate_report diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java index 930e701d2e9c..8d31ca9794c9 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java @@ -84,7 +84,6 @@ public class OMBucketCreateRequest extends OMClientRequest { public OMBucketCreateRequest(OMRequest omRequest) { super(omRequest); } - @Override public OMRequest preExecute(OzoneManager ozoneManager) throws IOException { @@ -136,8 +135,8 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException { @Override public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, - long transactionLogIndex, - OzoneManagerDoubleBufferHelper ozoneManagerDoubleBufferHelper) { + long transactionLogIndex, + OzoneManagerDoubleBufferHelper ozoneManagerDoubleBufferHelper) { OMMetrics omMetrics = ozoneManager.getMetrics(); omMetrics.incNumBucketCreates(); @@ -277,7 +276,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, * @param omVolumeArgs */ private void addDefaultAcls(OmBucketInfo omBucketInfo, - OmVolumeArgs omVolumeArgs) { + OmVolumeArgs omVolumeArgs) { // Add default acls for bucket creator. List acls = new ArrayList<>(); if (omBucketInfo.getAcls() != null) { @@ -326,8 +325,7 @@ private BucketEncryptionInfoProto getBeinfo( * Check namespace quota. */ private void checkQuotaInNamespace(OmVolumeArgs omVolumeArgs, - long allocatedNamespace) - throws IOException { + long allocatedNamespace) throws IOException { if (omVolumeArgs.getQuotaInNamespace() > 0) { long usedNamespace = omVolumeArgs.getUsedNamespace(); long quotaInNamespace = omVolumeArgs.getQuotaInNamespace(); @@ -343,9 +341,7 @@ private void checkQuotaInNamespace(OmVolumeArgs omVolumeArgs, } public boolean checkQuotaBytesValid(OMMetadataManager metadataManager, - OmVolumeArgs omVolumeArgs, - OmBucketInfo omBucketInfo, - String volumeKey) + OmVolumeArgs omVolumeArgs, OmBucketInfo omBucketInfo, String volumeKey) throws IOException { long quotaInBytes = omBucketInfo.getQuotaInBytes(); long volumeQuotaInBytes = omVolumeArgs.getQuotaInBytes(); @@ -357,7 +353,7 @@ public boolean checkQuotaBytesValid(OMMetadataManager metadataManager, return false; } - List bucketList = metadataManager.listBuckets( + List bucketList = metadataManager.listBuckets( omVolumeArgs.getVolume(), null, null, Integer.MAX_VALUE); for (OmBucketInfo bucketInfo : bucketList) { long nextQuotaInBytes = bucketInfo.getQuotaInBytes(); diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java index 19f990b33eb7..ecec94592d94 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java @@ -44,7 +44,6 @@ import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.helpers.ServiceInfo; import org.apache.hadoop.ozone.om.helpers.ServiceInfoEx; -import org.apache.hadoop.ozone.om.helpers.BucketLayout; import org.apache.hadoop.ozone.om.ratis.OzoneManagerDoubleBuffer; import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerRatisUtils; import org.apache.hadoop.ozone.om.request.OMClientRequest; From 2e30029f8efb7a39811ea7bf76c71acd70ebc7dc Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Mon, 9 May 2022 12:44:24 +0530 Subject: [PATCH 08/12] update robot test case for new MLV --- .../upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh | 2 +- hadoop-ozone/dist/src/main/smoketest/upgrade/finalize.robot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh index f414ddf43f7c..d54c9bc89b46 100755 --- a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh +++ b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/1.2.1-1.3.0/callback.sh @@ -71,7 +71,7 @@ with_old_version_downgraded() { with_new_version_finalized() { _check_hdds_mlvs 3 - _check_om_mlvs 1 + _check_om_mlvs 2 validate old1 validate new1 diff --git a/hadoop-ozone/dist/src/main/smoketest/upgrade/finalize.robot b/hadoop-ozone/dist/src/main/smoketest/upgrade/finalize.robot index 288f9c01507f..b70f3ca14781 100644 --- a/hadoop-ozone/dist/src/main/smoketest/upgrade/finalize.robot +++ b/hadoop-ozone/dist/src/main/smoketest/upgrade/finalize.robot @@ -19,7 +19,7 @@ Resource ../commonlib.robot Test Timeout 5 minutes Test Setup Run Keyword if '${SECURITY_ENABLED}' == 'true' Kinit test user testuser testuser.keytab -** Test Cases *** +*** Test Cases *** Finalize SCM ${result} = Execute ozone admin scm finalizeupgrade #Wait Until Keyword Succeeds 3min 10sec Should contain ${result} OM Preparation successful! From 8cbd3f1a9123cd5ca92c34e9cc20421c72fa0c8f Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Mon, 9 May 2022 15:03:01 +0530 Subject: [PATCH 09/12] add OMBucketLayoutUpgrade integration test. --- .../hadoop/ozone/om/OMUpgradeTestUtils.java | 88 ++++++ .../ozone/om/TestOMBucketLayoutUpgrade.java | 264 ++++++++++++++++++ .../ozone/om/TestOMUpgradeFinalization.java | 52 +--- 3 files changed, 354 insertions(+), 50 deletions(-) create mode 100644 hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/OMUpgradeTestUtils.java create mode 100644 hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/OMUpgradeTestUtils.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/OMUpgradeTestUtils.java new file mode 100644 index 000000000000..093cc0943f25 --- /dev/null +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/OMUpgradeTestUtils.java @@ -0,0 +1,88 @@ +/** + * 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.ozone.om; + +import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol; +import org.apache.hadoop.ozone.upgrade.UpgradeFinalizer; +import org.apache.ozone.test.LambdaTestUtils; +import org.junit.Assert; + +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeoutException; + +import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusResponse.PrepareStatus.PREPARE_COMPLETED; +import static org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.Status.FINALIZATION_DONE; +import static org.apache.ozone.test.GenericTestUtils.waitFor; + +/** + * Utility class to help test OM upgrade scenarios. + */ +public final class OMUpgradeTestUtils { + + private OMUpgradeTestUtils() { + // Utility class. + } + + public static void assertClusterPrepared( + long preparedIndex, List ozoneManagers) throws Exception { + for (OzoneManager om : ozoneManagers) { + LambdaTestUtils.await(120000, + 1000, () -> { + if (!om.isRunning()) { + return false; + } else { + boolean preparedAtIndex = false; + OzoneManagerPrepareState.State state = + om.getPrepareState().getState(); + + if (state.getStatus() == PREPARE_COMPLETED) { + if (state.getIndex() == preparedIndex) { + preparedAtIndex = true; + } else { + // State will not change if we are prepared at the wrong + // index. Break out of wait. + throw new Exception("OM " + om.getOMNodeId() + " prepared " + + "but prepare index " + state.getIndex() + " does not " + + "match expected prepare index " + preparedIndex); + } + } + return preparedAtIndex; + } + }); + } + } + + public static void waitForFinalization(OzoneManagerProtocol omClient) + throws TimeoutException, InterruptedException { + waitFor(() -> { + try { + UpgradeFinalizer.StatusAndMessages statusAndMessages = + omClient.queryUpgradeFinalizationProgress("finalize-test", false, + false); + System.out.println("Finalization Messages : " + + statusAndMessages.msgs()); + return statusAndMessages.status().equals(FINALIZATION_DONE); + } catch (IOException e) { + Assert.fail(e.getMessage()); + } + return false; + }, 2000, 20000); + } +} diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java new file mode 100644 index 000000000000..eaed77fda216 --- /dev/null +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java @@ -0,0 +1,264 @@ +/** + * 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.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. + *

+ * Expected behavior: + * 1. Pre-Finalize: OM should not allow creation of buckets with new bucket + * layouts. Only LEGACY buckets are allowed. + *

+ * 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 static 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 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. + continue; + } + try { + LOG.info("Creating bucket with layout {} during Pre-Finalize", layout); + createBucketWithLayout(layout); + fail("Expected to fail creating bucket with layout " + layout); + } catch (OMException e) { + // Expected exception. + assertTrue(e.getMessage().contains( + "Cluster does not have the Bucket Layout support feature " + + "finalized yet")); + LOG.info("Expected exception: " + e.getMessage()); + + } + } + } + + /** + * Tests that OM blocks all requests to create any buckets with a new bucket + * layout. + * + * @throws Exception + */ + @Test + public void testCreateLegacyBucketPreFinalize() throws Exception { + // Assert OM layout version is 'fromLayoutVersion' on deploy. + assertEquals(fromLayoutVersion, + ozoneManager.getVersionManager().getMetadataLayoutVersion()); + assertNull(ozoneManager.getMetadataManager().getMetaTable() + .get(LAYOUT_VERSION_KEY)); + + LOG.info("Creating legacy bucket during Pre-Finalize"); + String bucketName = createBucketWithLayout(BucketLayout.LEGACY); + assertEquals( + omClient.getBucketInfo(VOLUME_NAME, bucketName).getBucketName(), + bucketName); + assertEquals( + omClient.getBucketInfo(VOLUME_NAME, bucketName).getBucketLayout(), + BucketLayout.LEGACY); + } + + private String createBucketWithLayout(BucketLayout bucketLayout) + throws Exception { + String bucketName = RandomStringUtils.randomAlphabetic(10).toLowerCase(); + omClient.createBucket( + new OmBucketInfo.Builder() + .setVolumeName(VOLUME_NAME) + .setBucketName(bucketName) + .setBucketLayout(bucketLayout) + .build()); + + return bucketName; + } + + /** + * Currently this is a No-Op finalization since there is only one layout + * version in OM. But this test is expected to remain consistent when a + * new version is added. + */ + @Test + public void testCreateBucketAfterOmFinalization() throws Exception { + // Assert OM Layout Version is 'fromLayoutVersion' on deploy. + assertEquals(fromLayoutVersion, + ozoneManager.getVersionManager().getMetadataLayoutVersion()); + assertNull(ozoneManager.getMetadataManager() + .getMetaTable().get(LAYOUT_VERSION_KEY)); + + UpgradeFinalizer.StatusAndMessages response = + omClient.finalizeUpgrade("finalize-test"); + System.out.println("Finalization Messages : " + response.msgs()); + + waitForFinalization(omClient); + + LambdaTestUtils.await(30000, 3000, () -> { + String lvString = ozoneManager.getMetadataManager().getMetaTable() + .get(LAYOUT_VERSION_KEY); + return maxLayoutVersion() == Integer.parseInt(lvString); + }); + + // Bucket creation should now succeed with all layouts. + for (BucketLayout layout : BUCKET_LAYOUTS) { + LOG.info("Creating bucket with layout {} after OM finalization", layout); + String bucketName = createBucketWithLayout(layout); + assertEquals( + omClient.getBucketInfo(VOLUME_NAME, bucketName).getBucketName(), + bucketName); + assertEquals( + omClient.getBucketInfo(VOLUME_NAME, bucketName).getBucketLayout(), + layout); + } + } +} diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMUpgradeFinalization.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMUpgradeFinalization.java index 5a109f7975fc..9deb9ed63c9a 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMUpgradeFinalization.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMUpgradeFinalization.java @@ -19,16 +19,15 @@ */ import static org.apache.hadoop.ozone.OzoneConsts.LAYOUT_VERSION_KEY; +import static org.apache.hadoop.ozone.om.OMUpgradeTestUtils.assertClusterPrepared; +import static org.apache.hadoop.ozone.om.OMUpgradeTestUtils.waitForFinalization; import static org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature.INITIAL_VERSION; import static org.apache.hadoop.ozone.om.upgrade.OMLayoutVersionManager.maxLayoutVersion; -import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusResponse.PrepareStatus.PREPARE_COMPLETED; -import static org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.Status.FINALIZATION_DONE; import static org.apache.ozone.test.GenericTestUtils.waitFor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -204,51 +203,4 @@ public void testOmFinalizationWithOneOmDown() throws Exception { assertEquals(maxLayoutVersion(), Integer.parseInt(lvString)); } - - private void assertClusterPrepared( - long preparedIndex, List ozoneManagers) throws Exception { - for (OzoneManager om : ozoneManagers) { - LambdaTestUtils.await(120000, - 1000, () -> { - if (!om.isRunning()) { - return false; - } else { - boolean preparedAtIndex = false; - OzoneManagerPrepareState.State state = - om.getPrepareState().getState(); - - if (state.getStatus() == PREPARE_COMPLETED) { - if (state.getIndex() == preparedIndex) { - preparedAtIndex = true; - } else { - // State will not change if we are prepared at the wrong - // index. Break out of wait. - throw new Exception("OM " + om.getOMNodeId() + " prepared " + - "but prepare index " + state.getIndex() + " does not " + - "match expected prepare index " + preparedIndex); - } - } - return preparedAtIndex; - } - }); - } - } - - private void waitForFinalization(OzoneManagerProtocol omClient) - throws TimeoutException, InterruptedException { - waitFor(() -> { - try { - StatusAndMessages statusAndMessages = - omClient.queryUpgradeFinalizationProgress("finalize-test", false, - false); - System.out.println("Finalization Messages : " + - statusAndMessages.msgs()); - return statusAndMessages.status().equals(FINALIZATION_DONE); - } catch (IOException e) { - Assert.fail(e.getMessage()); - } - return false; - }, 2000, 20000); - } - } From 65ffd0c1c5cb8fa80b2f961c22b80e991b6c657d Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Mon, 9 May 2022 15:30:11 +0530 Subject: [PATCH 10/12] fix comment. --- .../org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java index eaed77fda216..8e71f9151332 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java @@ -188,8 +188,7 @@ public void testCreateBucketWithNewLayoutsPreFinalize() throws Exception { } /** - * Tests that OM blocks all requests to create any buckets with a new bucket - * layout. + * Tests that OM allows requests to create legacy buckets. * * @throws Exception */ From e4f83e5b6754827c20eae01cb1b3960e8b01f1cd Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Mon, 9 May 2022 16:18:16 +0530 Subject: [PATCH 11/12] findbugs --- .../org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java index 8e71f9151332..16c14b8d6e39 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java @@ -85,7 +85,7 @@ public class TestOMBucketLayoutUpgrade { }; private static final String VOLUME_NAME = "vol-" + UUID.randomUUID(); private int fromLayoutVersion; - private static OzoneManagerProtocol omClient; + private OzoneManagerProtocol omClient; private static final Logger LOG = LoggerFactory.getLogger(TestOMBucketLayoutUpgrade.class); From 07d9dcc85433326842125724900ee34ff6e4a780 Mon Sep 17 00:00:00 2001 From: Jyotinder Singh Date: Thu, 12 May 2022 15:18:11 +0530 Subject: [PATCH 12/12] Address reviews. Clean up integration test. --- .../ozone/om/TestOMBucketLayoutUpgrade.java | 137 ++++++++++-------- .../ozone/om/upgrade/OMLayoutFeature.java | 3 +- 2 files changed, 75 insertions(+), 65 deletions(-) diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java index 16c14b8d6e39..a4442f2d2945 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMBucketLayoutUpgrade.java @@ -49,13 +49,11 @@ 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. @@ -77,12 +75,6 @@ public class TestOMBucketLayoutUpgrade { 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; @@ -98,8 +90,7 @@ public class TestOMBucketLayoutUpgrade { @Parameterized.Parameters public static Collection data() { return Arrays.asList(new Object[][]{ - {INITIAL_VERSION}, - {ERASURE_CODED_STORAGE_SUPPORT}, + {INITIAL_VERSION} }); } @@ -160,56 +151,93 @@ public void shutdown() { * @throws Exception */ @Test - public void testCreateBucketWithNewLayoutsPreFinalize() throws Exception { + public void testCreateBucketWithBucketLayoutsDuringUpgrade() + 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. - continue; - } + // Test bucket creation with new bucket layouts. + // FSO and OBS bucket creation should fail. + verifyBucketCreationBlockedWithNewLayouts(); + + // Bucket creation with LEGACY layout should succeed in Pre-Finalized state. + LOG.info("Creating legacy bucket during Pre-Finalize"); + verifyBucketCreationWithLayout(new BucketLayout[]{BucketLayout.LEGACY}); + + // Finalize the cluster upgrade. + finalizeUpgrade(); + + // Cluster upgrade is now complete, + // Bucket creation should now succeed with all layouts. + verifyBucketCreationWithLayout(new BucketLayout[]{ + BucketLayout.LEGACY, + BucketLayout.FILE_SYSTEM_OPTIMIZED, + BucketLayout.OBJECT_STORE + }); + } + + + /** + * Tests that OM allows bucket creation with given bucket layouts. + * + * @param bucketLayouts bucket layouts to test + * @throws Exception if any + */ + private void verifyBucketCreationWithLayout(BucketLayout[] bucketLayouts) + throws Exception { + String bucketName; + for (BucketLayout layout : bucketLayouts) { + LOG.info("Creating bucket with layout {} after OM finalization", layout); + + bucketName = createBucketWithLayout(layout); + + // Make sure the bucket exists in the bucket table with the + // expected layout. + assertEquals( + omClient.getBucketInfo(VOLUME_NAME, bucketName).getBucketName(), + bucketName); + assertEquals( + omClient.getBucketInfo(VOLUME_NAME, bucketName).getBucketLayout(), + layout); + } + } + + /** + * Tests that OM blocks all requests to create any buckets with a new bucket + * layout. + * + * @throws Exception if any + */ + private void verifyBucketCreationBlockedWithNewLayouts() throws Exception { + BucketLayout[] bucketLayouts = new BucketLayout[]{ + BucketLayout.OBJECT_STORE, + BucketLayout.FILE_SYSTEM_OPTIMIZED, + }; + + for (BucketLayout layout : bucketLayouts) { try { LOG.info("Creating bucket with layout {} during Pre-Finalize", layout); createBucketWithLayout(layout); fail("Expected to fail creating bucket with layout " + layout); } catch (OMException e) { // Expected exception. - assertTrue(e.getMessage().contains( - "Cluster does not have the Bucket Layout support feature " + - "finalized yet")); - LOG.info("Expected exception: " + e.getMessage()); - + assertEquals( + OMException.ResultCodes.NOT_SUPPORTED_OPERATION_PRIOR_FINALIZATION, + e.getResult()); } } } /** - * Tests that OM allows requests to create legacy buckets. + * Helper method to create a bucket with the given layout. * - * @throws Exception + * @param bucketLayout the layout to use for the bucket. + * @return the name of the bucket created. + * @throws Exception if there is an error creating the bucket. */ - @Test - public void testCreateLegacyBucketPreFinalize() throws Exception { - // Assert OM layout version is 'fromLayoutVersion' on deploy. - assertEquals(fromLayoutVersion, - ozoneManager.getVersionManager().getMetadataLayoutVersion()); - assertNull(ozoneManager.getMetadataManager().getMetaTable() - .get(LAYOUT_VERSION_KEY)); - - LOG.info("Creating legacy bucket during Pre-Finalize"); - String bucketName = createBucketWithLayout(BucketLayout.LEGACY); - assertEquals( - omClient.getBucketInfo(VOLUME_NAME, bucketName).getBucketName(), - bucketName); - assertEquals( - omClient.getBucketInfo(VOLUME_NAME, bucketName).getBucketLayout(), - BucketLayout.LEGACY); - } - private String createBucketWithLayout(BucketLayout bucketLayout) throws Exception { String bucketName = RandomStringUtils.randomAlphabetic(10).toLowerCase(); @@ -224,18 +252,11 @@ private String createBucketWithLayout(BucketLayout bucketLayout) } /** - * Currently this is a No-Op finalization since there is only one layout - * version in OM. But this test is expected to remain consistent when a - * new version is added. + * Complete the cluster upgrade. + * + * @throws Exception if upgrade fails. */ - @Test - public void testCreateBucketAfterOmFinalization() throws Exception { - // Assert OM Layout Version is 'fromLayoutVersion' on deploy. - assertEquals(fromLayoutVersion, - ozoneManager.getVersionManager().getMetadataLayoutVersion()); - assertNull(ozoneManager.getMetadataManager() - .getMetaTable().get(LAYOUT_VERSION_KEY)); - + private void finalizeUpgrade() throws Exception { UpgradeFinalizer.StatusAndMessages response = omClient.finalizeUpgrade("finalize-test"); System.out.println("Finalization Messages : " + response.msgs()); @@ -247,17 +268,5 @@ public void testCreateBucketAfterOmFinalization() throws Exception { .get(LAYOUT_VERSION_KEY); return maxLayoutVersion() == Integer.parseInt(lvString); }); - - // Bucket creation should now succeed with all layouts. - for (BucketLayout layout : BUCKET_LAYOUTS) { - LOG.info("Creating bucket with layout {} after OM finalization", layout); - String bucketName = createBucketWithLayout(layout); - assertEquals( - omClient.getBucketInfo(VOLUME_NAME, bucketName).getBucketName(), - bucketName); - assertEquals( - omClient.getBucketInfo(VOLUME_NAME, bucketName).getBucketLayout(), - layout); - } } } diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java index d1092b68b3e2..7b1f4185b69d 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java @@ -35,7 +35,8 @@ public enum OMLayoutFeature implements LayoutFeature { + " Erasure Coded block data storage."), BUCKET_LAYOUT_SUPPORT(2, "Ozone version supporting bucket " + - "layouts and introducing the FSO and OBS bucket layout types."); + "layouts and introducing the FILE_SYSTEM_OPTIMIZED and OBJECT_STORE " + + "bucket layout types."); /////////////////////////////// /////////////////////////////