Skip to content

Commit 6758934

Browse files
authored
ZTS: snapshot_018_pos.ksh add extra margin
The date(1) command and snapshot timestamps use different clock sources which can result in a small discrepancy. This can cause the test the incorrectly fail. To avoid this, add a brief delay to the test case to allow for minor skew. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #18450
1 parent 60a7f64 commit 6758934

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tests/zfs-tests/tests/functional/snapshot/snapshot_018_pos.ksh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ log_must eval "[[ $(stat_mtime $tfs_snapdir) == 0 ]]"
9191

9292
# Create snapshots for filesystems and check snapshots_changed reports correct time
9393
curr_time=$(date '+%s')
94+
log_must sleep 1
9495
log_must zfs snapshot $snap_testpool
9596
snap_changed_testpool=$(zfs get -H -o value -p snapshots_changed $TESTPOOL)
9697
snap_changed_nsecs_testpool=$(zfs get -H -o value -p snapshots_changed_nsecs $TESTPOOL)
@@ -103,6 +104,7 @@ log_must eval "[[ $list_changed_nsecs_testpool == $snap_changed_nsecs_testpool ]
103104
log_must eval "[[ $(stat_mtime $tpool_snapdir) == $snap_changed_testpool ]]"
104105

105106
curr_time=$(date '+%s')
107+
log_must sleep 1
106108
log_must zfs snapshot $snap_testfsv1
107109
snap_changed_testfs=$(zfs get -H -o value -p snapshots_changed $TESTPOOL/$TESTFS)
108110
snap_changed_nsecs_testfs=$(zfs get -H -o value -p snapshots_changed_nsecs $TESTPOOL/$TESTFS)
@@ -121,6 +123,7 @@ log_must eval "[[ $(zfs get -H -o value -p snapshots_changed_nsecs $TESTPOOL/$TE
121123

122124
# Create snapshot while unmounted
123125
curr_time=$(date '+%s')
126+
log_must sleep 1
124127
log_must zfs snapshot $snap_testfsv2
125128
snap_changed_testfs=$(zfs get -H -o value -p snapshots_changed $TESTPOOL/$TESTFS)
126129
snap_changed_nsecs_testfs=$(zfs get -H -o value -p snapshots_changed_nsecs $TESTPOOL/$TESTFS)
@@ -144,6 +147,7 @@ log_must eval "[[ $(stat_mtime $tfs_snapdir) == $snap_changed_testfs ]]"
144147

145148
# Destroy the snapshots and check snapshots_changed shows correct time
146149
curr_time=$(date '+%s')
150+
log_must sleep 1
147151
log_must zfs destroy $snap_testfsv1
148152
snap_changed_testfs=$(zfs get -H -o value -p snapshots_changed $TESTPOOL/$TESTFS)
149153
snap_changed_nsecs_testfs=$(zfs get -H -o value -p snapshots_changed_nsecs $TESTPOOL/$TESTFS)
@@ -152,6 +156,7 @@ log_must eval "[[ $((snap_changed_nsecs_testfs / 1000000000)) == $snap_changed_t
152156
log_must eval "[[ $(stat_mtime $tfs_snapdir) == $snap_changed_testfs ]]"
153157

154158
curr_time=$(date '+%s')
159+
log_must sleep 1
155160
log_must zfs destroy $snap_testpool
156161
snap_changed_testpool=$(zfs get -H -o value -p snapshots_changed $TESTPOOL)
157162
snap_changed_nsecs_testpool=$(zfs get -H -o value -p snapshots_changed_nsecs $TESTPOOL)

0 commit comments

Comments
 (0)