Skip to content

Commit f78eae6

Browse files
author
Paul Dagnelie
committed
add test for database updates
Signed-off-by: Paul Dagnelie <paul.dagnelie@klarasystems.com>
1 parent 02d82d9 commit f78eae6

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed

tests/runfiles/common.run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ tests = ['zpool_scrub_001_neg', 'zpool_scrub_002_pos', 'zpool_scrub_003_pos',
550550
'zpool_scrub_multiple_pools',
551551
'zpool_error_scrub_001_pos', 'zpool_error_scrub_002_pos',
552552
'zpool_error_scrub_003_pos', 'zpool_error_scrub_004_pos',
553-
'zpool_scrub_date_range_001']
553+
'zpool_scrub_date_range_001', 'zpool_scrub_date_range_002']
554554
tags = ['functional', 'cli_root', 'zpool_scrub']
555555

556556
[tests/functional/cli_root/zpool_set]

tests/zfs-tests/include/tunables.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ SPA_DISCARD_MEMORY_LIMIT spa.discard_memory_limit zfs_spa_discard_memory_limit
9191
SPA_LOAD_VERIFY_DATA spa.load_verify_data spa_load_verify_data
9292
SPA_LOAD_VERIFY_METADATA spa.load_verify_metadata spa_load_verify_metadata
9393
SPA_NOTE_TXG_TIME spa.note_txg_time spa_note_txg_time
94+
SPA_FLUSH_TXG_TIME spa.flush_txg_time spa_flush_txg_time
9495
TRIM_EXTENT_BYTES_MIN trim.extent_bytes_min zfs_trim_extent_bytes_min
9596
TRIM_METASLAB_SKIP trim.metaslab_skip zfs_trim_metaslab_skip
9697
TRIM_TXG_BATCH trim.txg_batch zfs_trim_txg_batch

tests/zfs-tests/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
12511251
functional/cli_root/zpool_scrub/zpool_scrub_print_repairing.ksh \
12521252
functional/cli_root/zpool_scrub/zpool_scrub_txg_continue_from_last.ksh \
12531253
functional/cli_root/zpool_scrub/zpool_scrub_date_range_001.ksh \
1254+
functional/cli_root/zpool_scrub/zpool_scrub_date_range_002.ksh \
12541255
functional/cli_root/zpool_scrub/zpool_error_scrub_001_pos.ksh \
12551256
functional/cli_root/zpool_scrub/zpool_error_scrub_002_pos.ksh \
12561257
functional/cli_root/zpool_scrub/zpool_error_scrub_003_pos.ksh \
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/ksh -p
2+
# SPDX-License-Identifier: CDDL-1.0
3+
#
4+
# CDDL HEADER START
5+
#
6+
# The contents of this file are subject to the terms of the
7+
# Common Development and Distribution License (the "License").
8+
# You may not use this file except in compliance with the License.
9+
#
10+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11+
# or https://opensource.org/licenses/CDDL-1.0.
12+
# See the License for the specific language governing permissions
13+
# and limitations under the License.
14+
#
15+
# When distributing Covered Code, include this CDDL HEADER in each
16+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17+
# If applicable, add the following below this CDDL HEADER, with the
18+
# fields enclosed by brackets "[]" replaced with your own identifying
19+
# information: Portions Copyright [yyyy] [name of copyright owner]
20+
#
21+
# CDDL HEADER END
22+
#
23+
# Copyright 2025 Klara, Inc.
24+
#
25+
26+
. $STF_SUITE/include/libtest.shlib
27+
. $STF_SUITE/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg
28+
29+
#
30+
# DESCRIPTION:
31+
# Verify that the timestamp database updates all the tables as expected.
32+
#
33+
# STRATEGY:
34+
# 1. Decrease the note and flush frequency of the txg database.
35+
# 2. Force the pool to sync several txgs
36+
# 3. Verify that there are entries in each of the "month", "day", and
37+
# "minute" tables.
38+
#
39+
40+
verify_runnable "global"
41+
42+
function cleanup
43+
{
44+
log_must restore_tunable SPA_NOTE_TXG_TIME
45+
log_must restore_tunable SPA_FLUSH_TXG_TIME
46+
rm /$TESTPOOL/f1
47+
}
48+
49+
log_onexit cleanup
50+
51+
log_assert "Verifiy timestamp databases all update as expected."
52+
53+
log_must save_tunable SPA_NOTE_TXG_TIME
54+
log_must set_tunable64 SPA_NOTE_TXG_TIME 1
55+
log_must save_tunable SPA_FLUSH_TXG_TIME
56+
log_must set_tunable64 SPA_FLUSH_TXG_TIME 1
57+
58+
log_must touch /$TESTPOOL/f1
59+
log_must zpool sync $TESTPOOL
60+
sleep 1
61+
log_must touch /$TESTPOOL/f1
62+
log_must zpool sync $TESTPOOL
63+
sleep 1
64+
log_must touch /$TESTPOOL/f1
65+
log_must zpool sync $TESTPOOL
66+
67+
mos_zap="$(zdb -dddd $TESTPOOL 1)"
68+
minutes_entries=$(echo "$mos_zap" | grep "txg_log_time:minutes" | awk '{print $5}')
69+
days_entries=$(echo "$mos_zap" | grep "txg_log_time:days" | awk '{print $5}')
70+
months_entries=$(echo "$mos_zap" | grep "txg_log_time:months" | awk '{print $5}')
71+
72+
[[ "$minutes_entries" -ne "0" ]] || log_fail "0 entries in the minutes table"
73+
[[ "$days_entries" -ne "0" ]] || log_fail "0 entries in the days table"
74+
[[ "$months_entries" -ne "0" ]] || log_fail "0 entries in the months table"
75+
76+
log_pass "Verified all timestamp databases had entries as expected."

0 commit comments

Comments
 (0)