From 7f24ea2c994a96e18f50d5a334a91b573742afc6 Mon Sep 17 00:00:00 2001
From: Ankur Srivastava <88029242+ankurs-delphix@users.noreply.github.com>
Date: Wed, 8 Dec 2021 14:12:23 +0530
Subject: [PATCH] DOSE-434 Zpool_scrub (#30)

---
 tests/runfiles/object_store.run                        |  6 ++++++
 tests/test-runner/bin/zts-report.py.in                 | 10 ++++++++++
 .../tests/functional/cli_root/zpool_scrub/setup.ksh    |  8 ++++++--
 .../cli_root/zpool_scrub/zpool_scrub_004_pos.ksh       |  4 ++++
 .../cli_root/zpool_scrub/zpool_scrub_005_pos.ksh       |  4 ++++
 .../zpool_scrub/zpool_scrub_multiple_copies.ksh        |  4 ++++
 .../zpool_scrub/zpool_scrub_offline_device.ksh         |  4 ++++
 .../zpool_scrub/zpool_scrub_print_repairing.ksh        |  4 ++++
 8 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/tests/runfiles/object_store.run b/tests/runfiles/object_store.run
index ea964c4534d6..feae434f0aec 100644
--- a/tests/runfiles/object_store.run
+++ b/tests/runfiles/object_store.run
@@ -394,3 +394,9 @@ tests = ['import_cachefile_device_added', 'import_cachefile_device_removed',
 	'zpool_import_missing_002_pos', 'zpool_import_missing_003_pos',
 	'zpool_import_rename_001_pos']
 tags = ['functional', 'cli_root', 'zpool_import']
+
+[tests/functional/cli_root/zpool_scrub]
+tests = ['zpool_scrub_001_neg', 'zpool_scrub_002_pos', 'zpool_scrub_003_pos',
+	'zpool_scrub_004_pos', 'zpool_scrub_005_pos', 'zpool_scrub_multiple_copies',
+	'zpool_scrub_offline_device','zpool_scrub_print_repairing']
+tags = ['functional', 'cli_root', 'zpool_scrub']
diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in
index 5d761bd93541..faaec78d24f6 100755
--- a/tests/test-runner/bin/zts-report.py.in
+++ b/tests/test-runner/bin/zts-report.py.in
@@ -309,6 +309,16 @@ if os.environ.get('ZTS_OBJECT_STORE') == 'true':
             ['SKIP', object_store_skip],
         'cli_root/zpool_import/zpool_import_missing_002_pos':
             ['SKIP', object_store_skip],
+        'cli_root/zpool_scrub/zpool_scrub_004_pos':
+            ['SKIP', object_store_skip],
+        'cli_root/zpool_scrub/zpool_scrub_005_pos':
+            ['SKIP', object_store_skip],
+        'cli_root/zpool_scrub/zpool_scrub_print_repairing':
+            ['SKIP', object_store_skip],
+        'cli_root/zpool_scrub/zpool_scrub_offline_device':
+            ['SKIP', object_store_skip],
+        'cli_root/zpool_scrub/zpool_scrub_multiple_copies':
+            ['SKIP', object_store_skip],
     })
 
 #
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/setup.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/setup.ksh
index 936fd798e9dd..f6ef081640bc 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/setup.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/setup.ksh
@@ -33,9 +33,13 @@
 . $STF_SUITE/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg
 
 verify_runnable "global"
-verify_disk_count "$DISKS" 2
 
-default_mirror_setup_noexit $DISK1 $DISK2
+if use_object_store; then
+    default_setup_noexit
+else
+    verify_disk_count "$DISKS" 2
+    default_mirror_setup_noexit $DISK1 $DISK2
+fi
 
 mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
 
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_004_pos.ksh
index a7ae7f16b1af..293ef0b05f94 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_004_pos.ksh
@@ -44,6 +44,10 @@
 #	5. Verify scrub failed until the resilver completed
 #
 
+if use_object_store; then
+	log_unsupported "Not supported for object store run"
+fi
+
 function cleanup
 {
 	log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_005_pos.ksh
index 69a33983d379..e303f1f2c828 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_005_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_005_pos.ksh
@@ -42,6 +42,10 @@
 #	3. Try it twice, verify both of them work fine.
 #
 
+if use_object_store; then
+    log_unsupported "Not supported for object store run"
+fi
+
 verify_runnable "global"
 
 log_assert "When scrubbing, detach device should not break system."
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_multiple_copies.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_multiple_copies.ksh
index 2dd33c99c554..25f9f8b75433 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_multiple_copies.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_multiple_copies.ksh
@@ -38,6 +38,10 @@
 
 verify_runnable "global"
 
+if use_object_store; then
+	log_unsupported "Not supported for object store with multiple copies"
+fi
+
 function cleanup
 {
 	destroy_dataset $TESTPOOL/$TESTFS2
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_offline_device.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_offline_device.ksh
index 7a07e643343d..d8763fc37785 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_offline_device.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_offline_device.ksh
@@ -45,6 +45,10 @@
 # Ported from script used to reproduce issue #5806
 #
 
+if use_object_store; then
+	log_unsupported "Not supported for object store run"
+fi
+
 verify_runnable "global"
 
 function cleanup
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_print_repairing.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_print_repairing.ksh
index 4b51cd9625ec..44ffe5e25933 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_print_repairing.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_print_repairing.ksh
@@ -36,6 +36,10 @@
 #	4. Verify we see "(repairing)" on the bad vdev
 #
 
+if use_object_store; then
+	log_unsupported "Not supported for object store run"
+fi
+
 verify_runnable "global"
 
 log_assert "Verify we see '(repairing)' while scrubbing a bad vdev."