Skip to content

Commit bb2cabf

Browse files
Ming Leiaxboe
authored andcommitted
selftests: ublk: run stress tests in parallel
Run stress tests in parallel, meantime add shell local function to simplify the two stress tests. Signed-off-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 573840a commit bb2cabf

File tree

3 files changed

+63
-49
lines changed

3 files changed

+63
-49
lines changed

tools/testing/selftests/ublk/test_common.sh

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ __run_io_and_remove()
230230
local kill_server=$3
231231

232232
fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio \
233-
--rw=readwrite --iodepth=64 --size="${size}" --numjobs=4 \
233+
--rw=readwrite --iodepth=256 --size="${size}" --numjobs=4 \
234234
--runtime=20 --time_based > /dev/null 2>&1 &
235235
sleep 2
236236
if [ "${kill_server}" = "yes" ]; then
@@ -248,6 +248,38 @@ __run_io_and_remove()
248248
wait
249249
}
250250

251+
run_io_and_remove()
252+
{
253+
local size=$1
254+
local dev_id
255+
shift 1
256+
257+
dev_id=$(_add_ublk_dev "$@")
258+
_check_add_dev "$TID" $?
259+
260+
[ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs. remove device(ublk add $*)"
261+
if ! __run_io_and_remove "$dev_id" "${size}" "no"; then
262+
echo "/dev/ublkc$dev_id isn't removed"
263+
exit 255
264+
fi
265+
}
266+
267+
run_io_and_kill_daemon()
268+
{
269+
local size=$1
270+
local dev_id
271+
shift 1
272+
273+
dev_id=$(_add_ublk_dev "$@")
274+
_check_add_dev "$TID" $?
275+
276+
[ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs kill ublk server(ublk add $*)"
277+
if ! __run_io_and_remove "$dev_id" "${size}" "yes"; then
278+
echo "/dev/ublkc$dev_id isn't removed res ${res}"
279+
exit 255
280+
fi
281+
}
282+
251283
_ublk_test_top_dir()
252284
{
253285
cd "$(dirname "$0")" && pwd

tools/testing/selftests/ublk/test_stress_01.sh

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,28 @@ ERR_CODE=0
77

88
ublk_io_and_remove()
99
{
10-
local size=$1
11-
local dev_id
12-
shift 1
13-
14-
dev_id=$(_add_ublk_dev "$@")
15-
_check_add_dev $TID $?
16-
17-
[ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs. remove device(ublk add $*)"
18-
if ! __run_io_and_remove "$dev_id" "${size}" "no"; then
19-
echo "/dev/ublkc$dev_id isn't removed"
20-
exit 255
10+
run_io_and_remove "$@"
11+
ERR_CODE=$?
12+
if [ ${ERR_CODE} -ne 0 ]; then
13+
echo "$TID failure: $*"
14+
_show_result $TID $ERR_CODE
2115
fi
2216
}
2317

24-
_prep_test "stress" "run IO and remove device"
25-
26-
ublk_io_and_remove 8G -t null -q 4
27-
ERR_CODE=$?
28-
if [ ${ERR_CODE} -ne 0 ]; then
29-
_show_result $TID $ERR_CODE
18+
if ! _have_program fio; then
19+
exit "$UBLK_SKIP_CODE"
3020
fi
3121

22+
_prep_test "stress" "run IO and remove device"
23+
3224
_create_backfile 0 256M
25+
_create_backfile 1 128M
26+
_create_backfile 2 128M
3327

34-
ublk_io_and_remove 256M -t loop -q 4 "${UBLK_BACKFILES[0]}"
35-
ERR_CODE=$?
36-
if [ ${ERR_CODE} -ne 0 ]; then
37-
_show_result $TID $ERR_CODE
38-
fi
28+
ublk_io_and_remove 8G -t null -q 4 &
29+
ublk_io_and_remove 256M -t loop -q 4 "${UBLK_BACKFILES[0]}" &
30+
ublk_io_and_remove 256M -t stripe -q 4 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
31+
wait
3932

40-
ublk_io_and_remove 256M -t loop -q 4 -z "${UBLK_BACKFILES[0]}"
41-
ERR_CODE=$?
4233
_cleanup_test "stress"
4334
_show_result $TID $ERR_CODE

tools/testing/selftests/ublk/test_stress_02.sh

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,30 @@
55
TID="stress_02"
66
ERR_CODE=0
77

8+
if ! _have_program fio; then
9+
exit "$UBLK_SKIP_CODE"
10+
fi
11+
812
ublk_io_and_kill_daemon()
913
{
10-
local size=$1
11-
local dev_id
12-
shift 1
13-
14-
dev_id=$(_add_ublk_dev "$@")
15-
_check_add_dev $TID $?
16-
17-
[ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs kill ublk server(ublk add $*)"
18-
if ! __run_io_and_remove "$dev_id" "${size}" "yes"; then
19-
echo "/dev/ublkc$dev_id isn't removed res ${res}"
20-
exit 255
14+
run_io_and_kill_daemon "$@"
15+
ERR_CODE=$?
16+
if [ ${ERR_CODE} -ne 0 ]; then
17+
echo "$TID failure: $*"
18+
_show_result $TID $ERR_CODE
2119
fi
2220
}
2321

2422
_prep_test "stress" "run IO and kill ublk server"
2523

26-
ublk_io_and_kill_daemon 8G -t null -q 4
27-
ERR_CODE=$?
28-
if [ ${ERR_CODE} -ne 0 ]; then
29-
_show_result $TID $ERR_CODE
30-
fi
31-
3224
_create_backfile 0 256M
25+
_create_backfile 1 128M
26+
_create_backfile 2 128M
3327

34-
ublk_io_and_kill_daemon 256M -t loop -q 4 "${UBLK_BACKFILES[0]}"
35-
ERR_CODE=$?
36-
if [ ${ERR_CODE} -ne 0 ]; then
37-
_show_result $TID $ERR_CODE
38-
fi
28+
ublk_io_and_kill_daemon 8G -t null -q 4 &
29+
ublk_io_and_kill_daemon 256M -t loop -q 4 "${UBLK_BACKFILES[0]}" &
30+
ublk_io_and_kill_daemon 256M -t stripe -q 4 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
31+
wait
3932

40-
ublk_io_and_kill_daemon 256M -t loop -q 4 -z "${UBLK_BACKFILES[0]}"
41-
ERR_CODE=$?
4233
_cleanup_test "stress"
4334
_show_result $TID $ERR_CODE

0 commit comments

Comments
 (0)