diff mbox series

[16/28] check-parallel: run sections directly

Message ID 20250417031208.1852171-17-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>

Currently we pass the section through to check for it to apply and
run. However, we do not reconfigure the test or external devices in
check-parallel after the initial setup, so thie results in devices
that may be incorrectly configured for the given section config we
want to run.

To fix this, we need to iterate the sections directly in
check-parallel and reconfigure the runner device setup between each
section that is run. This allows the test device and external
devices to be set up correctly for each section config.

As the test list is consumed as we walk it, we need to reset the
test list for each section that we run.

We still pass the config section through to check so that it can
also source the correct config from the section we are running.

We also add section exclusion support so that we skip sections the
same way that check currently does.

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

Patch

diff --git a/check-parallel b/check-parallel
index e2cf2c8d0..23d29c7a8 100755
--- a/check-parallel
+++ b/check-parallel
@@ -15,6 +15,7 @@  runner_list=()
 runtimes=()
 show_test_list=
 run_section=""
+exclude_section=""
 iam="check-parallel"
 
 tmp=/tmp/check-parallel.$$
@@ -119,7 +120,8 @@  while [ $# -gt 0 ]; do
 
 	-f)	is_supported_fstype $2 ; export FSTYP=$2; shift ;;
 
-	-s)	run_section="$run_section -s $2"; shift ;;
+	-s)	run_section="$run_section $2"; shift ;;
+	-S)	exclude_section="$exclude_section $2"; shift ;;
 
 	-*)	usage ;;
 	*)	# not an argument, we've got tests now.
@@ -202,11 +204,12 @@  fi
 # each other.
 get_next_test()
 {
+	local test_file="$test_list.$1"
 	local test=
 
 	flock 99
-	test=$(tail -1 $test_list)
-	sed -i "\,$test,d" $test_list
+	test=$(tail -1 $test_file)
+	sed -i "\,$test,d" $test_file
 	flock -u 99
 	echo $test
 }
@@ -236,10 +239,34 @@  _destroy_loop_device()
         losetup -d $dev || _fail "Cannot destroy loop device $dev"
 }
 
-runner_go()
+run_tests()
 {
+	local section="$1"
+
 	exec 99<>$tmp.test_list_lock
 
+	local test_to_run=$(get_next_test $section)
+
+	# Run the tests in it's own mount namespace, as per the comment below
+	# that precedes making the basedir a private mount.
+	#
+	# Similarly, we need to run check in it's own PID namespace so that
+	# operations like pkill only affect the runner instance, not globally
+	# kill processes from other check instances.
+	while [ -n "$test_to_run" ]; do
+		echo -n " $test_to_run "
+		unset FSTESTS_ISOL
+		if ! _tl_expunge_test $test_to_run; then
+			tools/run_privatens ./check -s $section $test_to_run >> $me/log 2>&1
+		fi
+
+		test_to_run=$(get_next_test $section)
+	done
+}
+
+runner_go()
+{
+
 	local id=$1
 	local me=$basedir/runner-$id
 	local _test=$me/test.img
@@ -250,7 +277,7 @@  runner_go()
 	local _scratch_log=$me/scratch-log.img
 	local _logwrites=$me/logwrites.img
 	local _results=$me/results-$2
-	local test_to_run=$(get_next_test)
+	local section=$3
 
 	mkdir -p $me
 
@@ -286,21 +313,7 @@  runner_go()
 
 #	export DUMP_CORRUPT_FS=1
 
-	# Run the tests in it's own mount namespace, as per the comment below
-	# that precedes making the basedir a private mount.
-	#
-	# Similarly, we need to run check in it's own PID namespace so that
-	# operations like pkill only affect the runner instance, not globally
-	# kill processes from other check instances.
-	while [ -n "$test_to_run" ]; do
-		echo "Runner $id: running test $test_to_run"
-		unset FSTESTS_ISOL
-		if ! _tl_expunge_test $test_to_run; then
-			tools/run_privatens ./check $run_section $test_to_run >> $me/log 2>&1
-		fi
-
-		test_to_run=$(get_next_test)
-	done
+	run_tests $section
 
 	wait
 	sleep 1
@@ -322,6 +335,44 @@  runner_go()
 
 }
 
+run_section()
+{
+	local section="$1"
+	local now="$2"
+	local i
+
+	echo $run_section |grep -qw $section || return
+	echo $exclude_section |grep -qw $section && return
+
+	echo
+	echo Running section: $section
+	echo
+
+	parse_config_section $section
+
+	# set up consumable test list first
+	cp $test_list $test_list.$section
+	for ((i = 0; i < $runners; i++)); do
+		runner_go $i $now $section &
+	done
+	wait
+
+	echo
+	echo Section: $section
+	echo -n "Tests run: "
+	grep Ran $basedir/*/log | sed -e 's,^.*:,,' -e 's, ,\n,g' | sort | uniq | wc -l
+
+	echo -n "Tests _notrun: "
+	grep "^Not run" $basedir/*/log | uniq | sed -e 's,^.*:,,' -e 's, ,\n,g' -e 's,^\n,,' | wc -l
+
+	echo -n "Failure count: "
+	grep Failures: $basedir/*/log | uniq | sed -e "s/^.*Failures://" -e "s,\([0-9]\) \([gx]\),\1\n \2,g" |wc -l
+	echo
+
+	echo Ten slowest tests - runtime in seconds:
+	cat $basedir/*/results-$now/check.time | sort -k 2 -nr | head -10
+}
+
 cleanup()
 {
 	killall -INT -q check
@@ -336,6 +387,8 @@  trap "cleanup; exit" HUP INT QUIT TERM
 
 _config_setup_parallel
 
+run_section=${run_section:="$HOST_OPTIONS_SECTIONS"}
+
 _tl_setup_exclude_group "unreliable_in_parallel"
 _tl_prepare_test_list
 _tl_strip_test_list
@@ -369,23 +422,14 @@  fi
 mount --make-private $basedir
 
 now=`date +%Y-%m-%d-%H:%M:%S`
-for ((i = 0; i < $runners; i++)); do
-	runner_go $i $now &
-done;
-wait
-
-echo -n "Tests run: "
-grep Ran $basedir/*/log | sed -e 's,^.*:,,' -e 's, ,\n,g' | sort | uniq | wc -l
-
-echo -n "Tests _notrun: "
-grep "^Not run" $basedir/*/log | uniq | sed -e 's,^.*:,,' -e 's, ,\n,g' -e 's,^\n,,' | wc -l
-
-echo -n "Failure count: "
-grep Failures: $basedir/*/log | uniq | sed -e "s/^.*Failures://" -e "s,\([0-9]\) \([gx]\),\1\n \2,g" |wc -l
-echo
-
-echo Ten slowest tests - runtime in seconds:
-cat $basedir/*/results-$now/check.time | sort -k 2 -nr | head -10
+for section in $HOST_OPTIONS_SECTIONS; do
+	run_section $section $now
+	if [ "$sum_bad" != 0 ] && [ "$istop" = true ]; then
+		interrupt=false
+		status=`expr $sum_bad != 0`
+		exit
+	fi
+done
 
 echo
 echo Cleanup on Aisle 5?
diff --git a/common/config-sections b/common/config-sections
index 28bd11bab..c0ea097e8 100644
--- a/common/config-sections
+++ b/common/config-sections
@@ -436,6 +436,9 @@  _config_setup_parallel()
 		exit 1
 	fi
 
+	# strip check-parallel from the sections to run
+	export HOST_OPTIONS_SECTIONS=`echo $HOST_OPTIONS_SECTIONS | sed -e "s/$iam//"`
+
 	grep DEV $HOST_OPTIONS |grep -qv SIZE
 	if [ $? -ne 1 ]; then
 		echo "$iam config file has devices defined"