You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by si...@apache.org on 2026/10/21 22:10:02 UTC

(ozone) branch master updated: HDDS-17192. Add snapshot coverage to upgrade acceptance test (#11645)

This is an automated email from the ASF dual-hosted git repository.

smengcl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 26388a80b37 HDDS-17192. Add snapshot coverage to upgrade acceptance test (#11645)
26388a80b37 is described below

commit 26388a80b37f1a330d10ea6f094405ee9893cf77
Author: Siyao Meng <50...@users.noreply.github.com>
AuthorDate: Wed Oct 21 15:09:56 2026 -0700

    HDDS-17192. Add snapshot coverage to upgrade acceptance test (#11645)
    
    Co-authored-by: Claude Opus 5.5 <no...@anthropic.com>
---
 .../dist/src/main/compose/upgrade/testlib.sh       | 24 ++++++++++
 .../callbacks/common/callback.sh                   |  9 ++++
 .../upgrade/upgrades/non-rolling-upgrade/driver.sh |  4 ++
 .../rolling-upgrade/callbacks/common/callback.sh   | 10 +++++
 .../upgrade/upgrades/rolling-upgrade/driver.sh     |  2 +
 .../dist/src/main/smoketest/upgrade/snapshot.robot | 52 ++++++++++++++++++++++
 6 files changed, 101 insertions(+)

diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh b/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh
index 8f2e043d710..1b5cb1c3b45 100755
--- a/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh
+++ b/hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh
@@ -135,3 +135,27 @@ generate() {
 validate() {
   execute_robot_test "${2}" -N "${OUTPUT_NAME}-validate-${1}" -v PREFIX:"$1" ${@:3} upgrade/validate.robot
 }
+
+## @description Creates a snapshot of the bucket generated with the given prefix,
+##   reads earlier snapshots and diffs against the previous one.
+## @param The prefix of the data to be snapshotted.
+## @param The name of the snapshot to create.
+## @param The container to run the robot test in.
+## @param All remaining parameters are passed directly to the robot command.
+snapshot() {
+  # Snapshots were added in 1.4.0.
+  if [[ "$OZONE_UPGRADE_FROM" == 1.[0-3].* ]]; then
+    return
+  fi
+  execute_robot_test "${3}" -N "${OUTPUT_NAME}-snapshot-${2}" -v PREFIX:"$1" -v SNAPSHOT:"$2" ${@:4} upgrade/snapshot.robot
+}
+
+## @description Waits until the RPC port of every OM is open.
+##   wait_for_om_leader returns as soon as one OM is leader, and OM roles lists
+##   peers from config, so neither notices an OM that failed to start.
+wait_for_all_oms() {
+  local om
+  for om in $(docker-compose config --services | grep '^om'); do
+    wait_for_port "$om" 9862 120
+  done
+}
diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/callbacks/common/callback.sh b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/callbacks/common/callback.sh
index 6256c0bde8d..a05e3e74f13 100755
--- a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/callbacks/common/callback.sh
+++ b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/callbacks/common/callback.sh
@@ -23,6 +23,9 @@ with_old_version() {
   execute_robot_test "$SCM" -N "${OUTPUT_NAME}-check-finalization" --include finalized upgrade/non-rolling/check-finalization.robot
   generate old1 "$SCM"
   validate old1 "$SCM"
+  snapshot old1 original "$SCM" --include create-snapshot
+  # The new version replays the WAL of this diff into db.snapdiff SST files, which must stay readable after downgrade
+  snapshot old1 original2 "$SCM" -v FROM_SNAPSHOT:original -v EARLIER_SNAPSHOTS:original
 }
 
 with_this_version_pre_finalized() {
@@ -34,6 +37,8 @@ with_this_version_pre_finalized() {
 
   generate new1 "$SCM"
   validate new1 "$SCM"
+
+  snapshot old1 pre-finalized "$SCM" -v FROM_SNAPSHOT:original2 -v EARLIER_SNAPSHOTS:original,original2
 }
 
 with_old_version_downgraded() {
@@ -47,6 +52,8 @@ with_old_version_downgraded() {
   # HDDS-6261: overwrite the same keys again to trigger the precondition check
   # that exists <= 1.1.0 OM
   generate old1 "$SCM" --exclude create-volume-and-bucket
+
+  snapshot old1 downgraded "$SCM" -v FROM_SNAPSHOT:pre-finalized -v EARLIER_SNAPSHOTS:original,original2,pre-finalized
 }
 
 with_this_version_finalized() {
@@ -57,4 +64,6 @@ with_this_version_finalized() {
 
   generate new2 "$SCM"
   validate new2 "$SCM"
+
+  snapshot old1 finalized "$SCM" -v FROM_SNAPSHOT:downgraded -v EARLIER_SNAPSHOTS:original,original2,pre-finalized,downgraded
 }
diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/driver.sh b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/driver.sh
index 4018f5903cd..27b4b455525 100755
--- a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/driver.sh
+++ b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/non-rolling-upgrade/driver.sh
@@ -51,6 +51,7 @@ prepare_for_image "$OZONE_UPGRADE_FROM"
 
 echo "--- RUNNING WITH OLD VERSION $OZONE_UPGRADE_FROM ---"
 start_docker_env
+wait_for_all_oms
 callback with_old_version
 
 execute_robot_test "$SCM" -N "${OUTPUT_NAME}-prepare" upgrade/non-rolling/prepare.robot
@@ -61,6 +62,7 @@ export OM_HA_ARGS='--upgrade'
 echo "--- RUNNING WITH NEW VERSION $OZONE_UPGRADE_TO PRE-FINALIZED ---"
 OUTPUT_NAME="${OZONE_UPGRADE_FROM}-${OZONE_UPGRADE_TO}-2-pre-finalized"
 OZONE_KEEP_RESULTS=true start_docker_env
+wait_for_all_oms
 callback with_this_version_pre_finalized
 execute_robot_test "$SCM" -N "${OUTPUT_NAME}-prepare" upgrade/non-rolling/prepare.robot
 stop_docker_env
@@ -70,6 +72,7 @@ set_downgrade_om_args
 echo "--- RUNNING WITH OLD VERSION $OZONE_UPGRADE_FROM AFTER DOWNGRADE ---"
 OUTPUT_NAME="${OZONE_UPGRADE_FROM}-${OZONE_UPGRADE_TO}-3-downgraded"
 OZONE_KEEP_RESULTS=true start_docker_env
+wait_for_all_oms
 callback with_old_version_downgraded
 
 execute_robot_test "$SCM" -N "${OUTPUT_NAME}-prepare" upgrade/non-rolling/prepare.robot
@@ -80,6 +83,7 @@ export OM_HA_ARGS='--upgrade'
 echo "--- RUNNING WITH NEW VERSION $OZONE_UPGRADE_TO FINALIZED ---"
 OUTPUT_NAME="${OZONE_UPGRADE_FROM}-${OZONE_UPGRADE_TO}-4-finalized"
 OZONE_KEEP_RESULTS=true start_docker_env
+wait_for_all_oms
 
 # Sends commands to finalize OM and SCM.
 execute_robot_test "$SCM" -N "${OUTPUT_NAME}-finalize" upgrade/non-rolling/finalize.robot
diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/rolling-upgrade/callbacks/common/callback.sh b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/rolling-upgrade/callbacks/common/callback.sh
index 78dd5d80561..97bcd0ad92d 100644
--- a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/rolling-upgrade/callbacks/common/callback.sh
+++ b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/rolling-upgrade/callbacks/common/callback.sh
@@ -37,6 +37,10 @@ with_old_version() {
   validate old1 "$CLIENT"
 
   generate overwrite "$CLIENT"
+
+  snapshot overwrite original "$CLIENT" --include create-snapshot
+  # The new version replays the WAL of this diff into db.snapdiff SST files, which must stay readable after downgrade
+  snapshot overwrite original2 "$CLIENT" -v FROM_SNAPSHOT:original -v EARLIER_SNAPSHOTS:original
 }
 
 with_this_version_pre_finalized() {
@@ -49,6 +53,8 @@ with_this_version_pre_finalized() {
 
   validate overwrite "$CLIENT"
   generate overwrite "$CLIENT" --exclude create-volume-and-bucket
+
+  snapshot overwrite pre-finalized "$CLIENT" -v FROM_SNAPSHOT:original2 -v EARLIER_SNAPSHOTS:original,original2
 }
 
 with_old_version_downgraded() {
@@ -61,6 +67,8 @@ with_old_version_downgraded() {
 
   validate overwrite "$CLIENT"
   generate overwrite "$CLIENT" --exclude create-volume-and-bucket
+
+  snapshot overwrite downgraded "$CLIENT" -v FROM_SNAPSHOT:pre-finalized -v EARLIER_SNAPSHOTS:original,original2,pre-finalized
 }
 
 with_this_version_finalized() {
@@ -73,4 +81,6 @@ with_this_version_finalized() {
   validate new2 "$CLIENT"
 
   validate overwrite "$CLIENT"
+
+  snapshot overwrite finalized "$CLIENT" -v FROM_SNAPSHOT:downgraded -v EARLIER_SNAPSHOTS:original,original2,pre-finalized,downgraded
 }
diff --git a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/rolling-upgrade/driver.sh b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/rolling-upgrade/driver.sh
index 7f3827ba948..40c222da95f 100755
--- a/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/rolling-upgrade/driver.sh
+++ b/hadoop-ozone/dist/src/main/compose/upgrade/upgrades/rolling-upgrade/driver.sh
@@ -132,6 +132,7 @@ non_rolling_restart_all_services() {
 
   wait_for_safemode_exit
   wait_for_om_leader
+  wait_for_all_oms
 }
 
 echo "--- SETTING UP OLD VERSION $OZONE_UPGRADE_FROM ---"
@@ -140,6 +141,7 @@ prepare_for_image "$OZONE_UPGRADE_FROM"
 
 echo "--- RUNNING WITH OLD VERSION $OZONE_UPGRADE_FROM ---"
 start_docker_env
+wait_for_all_oms
 
 callback with_old_version
 
diff --git a/hadoop-ozone/dist/src/main/smoketest/upgrade/snapshot.robot b/hadoop-ozone/dist/src/main/smoketest/upgrade/snapshot.robot
new file mode 100644
index 00000000000..9efadf3126e
--- /dev/null
+++ b/hadoop-ozone/dist/src/main/smoketest/upgrade/snapshot.robot
@@ -0,0 +1,52 @@
+# 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       Create a snapshot, read earlier snapshots and diff against the previous one
+Library             OperatingSystem
+Library             String
+Library             BuiltIn
+Resource            ../commonlib.robot
+Suite Setup         Kinit test user     testuser     testuser.keytab
+Test Timeout        5 minutes
+
+*** Variables ***
+${PREFIX}
+${SNAPSHOT}
+${FROM_SNAPSHOT}
+${EARLIER_SNAPSHOTS}
+
+*** Keywords ***
+Snapshot diff should be done
+    ${output} =         Execute          ozone sh snapshot diff --get-report --json /${PREFIX}-volume/${PREFIX}-bucket ${FROM_SNAPSHOT} ${SNAPSHOT} | jq -r '.jobStatus'
+                        Should contain   ${output}    DONE
+
+*** Test Cases ***
+Create snapshot
+    [Tags]    create-snapshot
+    ${output} =         Execute          ozone sh snapshot create /${PREFIX}-volume/${PREFIX}-bucket ${SNAPSHOT}
+                        Should not contain  ${output}       Failed
+
+Read key from earlier snapshots
+    @{snapshots} =      Split String     ${EARLIER_SNAPSHOTS}    ,
+    FOR    ${snapshot}    IN    @{snapshots}
+        ${output} =     Execute          ozone sh key cat /${PREFIX}-volume/${PREFIX}-bucket/.snapshot/${snapshot}/${PREFIX}-key
+                        Should contain   ${output}    ${PREFIX}: key created using Ozone Shell
+    END
+
+Diff with previous snapshot
+    ${output} =         Execute          ozone sh snapshot diff /${PREFIX}-volume/${PREFIX}-bucket ${FROM_SNAPSHOT} ${SNAPSHOT}
+                        Should not contain  ${output}       Failed
+    Wait Until Keyword Succeeds    2min    5sec    Snapshot diff should be done


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org