diff mbox series

[13/28] check-parallel: introduce config file support

Message ID 20250417031208.1852171-14-david@fromorbit.com (mailing list archive)
State New
Headers show
Series check-parallel: Running tests without check | expand

Commit Message

Dave Chinner April 17, 2025, 3 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

check-parallel will use the same config file format check does,
and use the same code to auto-discover the config file.

The biggest difference is that check-parallel -requires- the use
of config sections, and the first section *must* be named
"[check-parallel]". This first section is used for defining
setup parameters for check parallel - loop device image file sizes,
etc.

The second biggest difference is that check-parallel does not allow
the config file to define devices. Any section found to contain a
device definition such as TEST_DEV or SCRATCH_DEV will result
check-parallel terminating with an error.

This config file format works for check-parallel invoking check,
too, because once a section is specified on the check command line,
it effectively ignores unknown values set in sections that it
doesn't run.  Hence it effectively skips over the [check-parallel]
setup section.

For check-parallel, each config section now defines just the
filesystem configuration to be tested; all the usual mount and mkfs
options apply, and USE_EXTERNAL must be set for testing external
devices.

This commit implements the initial [check-parallel] section support
and moves the build in default values for these parameters to the
config file setup. This means if the config file does not contain
all the necessary parameter values, a default value will be used for
it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 check-parallel         | 14 +++-----
 common/config-sections | 78 +++++++++++++++++++++++++++++++++++++++---
 2 files changed, 77 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/check-parallel b/check-parallel
index 5bb44b6a5..6fc86fb92 100755
--- a/check-parallel
+++ b/check-parallel
@@ -15,22 +15,14 @@  runner_list=()
 runtimes=()
 show_test_list=
 run_section=""
+iam="check-parallel"
 
 tmp=/tmp/check-parallel.$$
 
-TEST_DEV_SIZE=${TEST_DEV_SIZE:=10G}
-TEST_RTDEV_SIZE=${TEST_RTDEV_SIZE:=10G}
-TEST_LOGDEV_SIZE=${TEST_LOGDEV_SIZE:=128M}
-SCRATCH_DEV_SIZE=${SCRATCH_DEV_SIZE:=20G}
-SCRATCH_RTDEV_SIZE=${SCRATCH_RTDEV_SIZE:=20G}
-SCRATCH_LOGDEV_SIZE=${SCRATCH_LOGDEV_SIZE:=512M}
-LOGWRITES_DEV_SIZE=${LOGWRITES_DEV_SIZE:=2G}
-
-FSTYP=
-
 . ./common/exit
 . ./common/test_names
 . ./common/test_list
+. ./common/config-sections
 
 usage()
 {
@@ -332,6 +324,8 @@  cleanup()
 
 trap "cleanup; exit" HUP INT QUIT TERM
 
+_config_setup_parallel
+
 split_runner_list
 if [ -n "$show_test_list" ]; then
 	echo Time ordered test list:
diff --git a/common/config-sections b/common/config-sections
index 69a03375a..28bd11bab 100644
--- a/common/config-sections
+++ b/common/config-sections
@@ -329,6 +329,7 @@  get_next_config() {
 
 known_hosts()
 {
+	[ -z "$HOST" ] && export HOST=`hostname -s`
 	[ "$HOST_CONFIG_DIR" ] || HOST_CONFIG_DIR=`pwd`/configs
 
 	[ -f /etc/xfsqa.config ]             && export HOST_OPTIONS=/etc/xfsqa.config
@@ -336,7 +337,7 @@  known_hosts()
 	[ -f $HOST_CONFIG_DIR/$HOST.config ] && export HOST_OPTIONS=$HOST_CONFIG_DIR/$HOST.config
 }
 
-_config_section_setup()
+_config_file_setup()
 {
 	if [ ! -f "$HOST_OPTIONS" ]; then
 		known_hosts
@@ -346,13 +347,32 @@  _config_section_setup()
 	export OPTIONS_HAVE_SECTIONS=false
 	if [ -f "$HOST_OPTIONS" ]; then
 		export HOST_OPTIONS_SECTIONS=`get_config_sections $HOST_OPTIONS`
-		if [ -z "$HOST_OPTIONS_SECTIONS" ]; then
-			. $HOST_OPTIONS
-			export HOST_OPTIONS_SECTIONS="-no-sections-"
-		else
+		if [ -n "$HOST_OPTIONS_SECTIONS" ]; then
 			export OPTIONS_HAVE_SECTIONS=true
 		fi
 	fi
+}
+
+_config_section_setup()
+{
+	if [ "$iam" == "check-parallel" ]; then
+		echo "$iam: incorrect config file format chosen!"
+		exit 1;
+	fi
+
+	_config_file_setup
+
+	# If we don't have sections, source the options from the config file.
+	# Otherwise, strip sections that should not be run by check that may be
+	# present in the config file
+	if [ "$OPTIONS_HAVE_SECTIONS" != "true" ]; then
+		. $HOST_OPTIONS
+		export HOST_OPTIONS_SECTIONS="-no-sections-"
+	else
+		export HOST_OPTIONS_SECTIONS=$(echo $HOST_OPTIONS_SECTIONS | \
+				sed -e 's/check-parallel//')
+	fi
+
 
 	if [ -z "$CONFIG_INCLUDED" ]; then
 		get_next_config `echo $HOST_OPTIONS_SECTIONS | cut -f1 -d" "`
@@ -388,3 +408,51 @@  _config_section_setup()
 		fi
 	fi
 }
+
+# check-parallel config files must:
+# 1. have config sections defined
+# 2. use the first config section for check-parallel setup
+# 3. not define any physical device parameter in any section
+#
+# If all these are true, then we read the first section that defines
+# the check-parallel config parameters and continue onwards.
+_config_setup_parallel()
+{
+	if [ "$iam" != "check-parallel" ]; then
+		echo "$iam: incorrect config file format chosen!"
+		exit 1;
+	fi
+
+	_config_file_setup
+
+	if [ "$OPTIONS_HAVE_SECTIONS" != "true" ]; then
+		echo "$iam config file has no sections!"
+		exit 1;
+	fi
+
+	local first_section=`echo $HOST_OPTIONS_SECTIONS | cut -f1 -d" "`
+	if [ "$first_section" != "$iam" ]; then
+		echo "$iam config file has no [$iam] section"
+		exit 1
+	fi
+
+	grep DEV $HOST_OPTIONS |grep -qv SIZE
+	if [ $? -ne 1 ]; then
+		echo "$iam config file has devices defined"
+		exit 1
+	fi
+
+	# we only need to pull in the config parameters here and set defaults
+	# if they are not set after pulling in the config values.
+	parse_config_section $1
+
+	TEST_DEV_SIZE=${TEST_DEV_SIZE:=10G}
+	TEST_RTDEV_SIZE=${TEST_RTDEV_SIZE:=10G}
+	TEST_LOGDEV_SIZE=${TEST_LOGDEV_SIZE:=128M}
+	SCRATCH_DEV_SIZE=${SCRATCH_DEV_SIZE:=20G}
+	SCRATCH_RTDEV_SIZE=${SCRATCH_RTDEV_SIZE:=20G}
+	SCRATCH_LOGDEV_SIZE=${SCRATCH_LOGDEV_SIZE:=512M}
+	LOGWRITES_DEV_SIZE=${LOGWRITES_DEV_SIZE:=2G}
+
+	FSTYP=${FSTYP:=xfs}
+}