arunsarin85 commented on code in PR #10200:
URL: https://github.com/apache/ozone/pull/10200#discussion_r3204111023


##########
hadoop-ozone/dist/src/main/smoketest/snapshot/snapshot-defrag.robot:
##########
@@ -0,0 +1,106 @@
+# 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       Basic checks that snapshots still look correct while the 
OM runs periodic
+...                 snapshot defrag in the background (Jira HDDS-15181 / 
parent HDDS-13003).
+...                 Cluster setup: filesystem snapshots on; defrag interval on 
the OM only
+...                 (compose/ozone docker-compose).
+Library             OperatingSystem
+Resource            ../ozone-lib/shell.robot
+Resource            snapshot-setup.robot
+Suite Setup         Prepare Suite With Bucket And First Snapshot
+Test Timeout        20 minutes
+
+*** Variables ***
+# Wait long enough for at least two defrag runs (OM uses a 30s interval in 
compose).
+${DEFRAG_WAIT_SECONDS}     65
+
+*** Test Cases ***
+Read Snapshot Data Right After Create
+    [Documentation]     You can read the snapshotted key from the .snapshot 
path as soon as the snapshot exists.
+    Key Should Match Local File         ${SNAP_KEY_PATH_ONE}       /etc/hosts
+
+After Waiting Keys Still Match Through Snapshot And On Live Bucket
+    [Documentation]     Add a new key on the live bucket, wait so defrag may 
run, then confirm the snapshot
+    ...                 still has the old file and the live bucket has the new 
one.
+    ${key_two} =            snapshot-setup.Create key           ${VOLUME}      
 ${BUCKET}       /etc/passwd
+    Set Suite Variable      ${KEY_TWO}          ${key_two}
+    Set Suite Variable      ${LIVE_KEY_TWO_PATH}                   
/${VOLUME}/${BUCKET}/${key_two}
+    Sleep                   ${DEFRAG_WAIT_SECONDS}
+    Key Should Match Local File         ${SNAP_KEY_PATH_ONE}       /etc/hosts
+    Key Should Match Local File         ${LIVE_KEY_TWO_PATH}       /etc/passwd
+
+Snapshot List Still Shows Active
+    [Documentation]     ozone sh snapshot ls still lists this snapshot as 
SNAPSHOT_ACTIVE.
+    ${result} =     Execute             ozone sh snapshot ls 
/${VOLUME}/${BUCKET}
+                    Should contain      ${result}       ${SNAPSHOT_ONE}
+                    Should contain      ${result}       SNAPSHOT_ACTIVE
+
+Second Snapshot Sees All Keys So Far
+    [Documentation]     Take another snapshot after adding a third key; older 
snapshot still only has the first key;
+    ...                 newer snapshot can read all three keys.
+    ${key_three} =            snapshot-setup.Create key           ${VOLUME}    
   ${BUCKET}       /etc/group
+    Set Suite Variable      ${KEY_THREE}        ${key_three}
+    ${snapshot_two} =       Create snapshot                     ${VOLUME}      
 ${BUCKET}
+    Set Suite Variable      ${SNAPSHOT_TWO}     ${snapshot_two}
+    Key Should Match Local File         
/${VOLUME}/${BUCKET}/${SNAPSHOT_INDICATOR}/${SNAPSHOT_ONE}/${KEY_ONE}       
/etc/hosts
+    Key Should Match Local File         
/${VOLUME}/${BUCKET}/${SNAPSHOT_INDICATOR}/${SNAPSHOT_TWO}/${KEY_ONE}       
/etc/hosts
+    Key Should Match Local File         
/${VOLUME}/${BUCKET}/${SNAPSHOT_INDICATOR}/${SNAPSHOT_TWO}/${KEY_TWO}       
/etc/passwd
+    Key Should Match Local File         
/${VOLUME}/${BUCKET}/${SNAPSHOT_INDICATOR}/${SNAPSHOT_TWO}/${KEY_THREE}     
/etc/group
+
+Snapshot Diff Starts A New Job
+    [Documentation]     Comparing the two snapshots prints the usual “new job” 
and --get-report hint (like snapshot-sh.robot).
+    ${result} =     Execute             ozone sh snapshot diff 
/${VOLUME}/${BUCKET} ${SNAPSHOT_ONE} ${SNAPSHOT_TWO}
+                    Should contain      ${result}       Submitting a new job
+                    Should contain      ${result}       --get-report option
+
+Snapshot Diff Json Report Lists Added Keys
+    [Documentation]     Full JSON report finishes with DONE and lists the keys 
that appeared after the first snapshot.
+    ${result} =     Execute             ozone sh snapshot diff --get-report 
--json /${VOLUME}/${BUCKET} ${SNAPSHOT_ONE} ${SNAPSHOT_TWO}
+                    Should contain      echo '${result}' | jq '.jobStatus'   
DONE
+                    Should contain      echo '${result}' | jq 
'.snapshotDiffReport.volumeName'    ${VOLUME}
+                    Should contain      echo '${result}' | jq 
'.snapshotDiffReport.bucketName'    ${BUCKET}
+                    Should contain      echo '${result}' | jq 
'.snapshotDiffReport.fromSnapshot'  ${SNAPSHOT_ONE}
+                    Should contain      echo '${result}' | jq 
'.snapshotDiffReport.toSnapshot'    ${SNAPSHOT_TWO}
+                    Should contain      echo '${result}' | jq 
'.snapshotDiffReport.diffList | .[].sourcePath'    ${KEY_TWO}
+                    Should contain      echo '${result}' | jq 
'.snapshotDiffReport.diffList | .[].sourcePath'    ${KEY_THREE}
+
+Snapshot Diff Json Unchanged After Another Defrag Wait

Review Comment:
   @smengcl Thanks for pointing .
   Agreed ! (Running --get-report again wouldn’t really run the diff again; it 
would mostly show the same saved report for a while.)
   
   I removed that second JSON diff. We still do one full JSON report after 
submitting the diff (to check it finishes and lists the right keys). After the 
extra wait we now rely on snapshot info plus reading the keys again, so we’re 
not implying we recomputed the diff.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to