From 7347f60bbc0e00f0ad2084c67ef2d4b610980ee0 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Tue, 30 Mar 2021 12:14:26 +0200 Subject: [PATCH] autotest: Use rpc_cmd() for rpc plugin-based tests Also, create a common dir which will hold symlinks to all existing plugins used in the tests. Location of the actual lib is not changed so the relation to the given test suite is clearly preserved. Signed-off-by: Michal Berger Change-Id: Icb70bbc61fbfa3325a357d5dd93f554ff132a3b9 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7146 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- test/common/autotest_common.sh | 4 +++- test/event/scheduler/scheduler.sh | 3 +-- test/rpc/rpc.sh | 2 +- test/rpc_plugins/rpc_plugin.py | 1 + test/rpc_plugins/scheduler_plugin.py | 1 + test/scheduler/common.sh | 8 +++----- 6 files changed, 10 insertions(+), 9 deletions(-) create mode 120000 test/rpc_plugins/rpc_plugin.py create mode 120000 test/rpc_plugins/scheduler_plugin.py diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 265a40c54..a0e312849 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -244,7 +244,9 @@ done # start rpc.py coprocess if it's not started yet if [[ -z $RPC_PIPE_PID ]] || ! kill -0 "$RPC_PIPE_PID" &> /dev/null; then - coproc RPC_PIPE { "$rootdir/scripts/rpc.py" --server; } + # Include list to all known plugins we use in the tests + PYTHONPATH+=":$rootdir/test/rpc_plugins" + coproc RPC_PIPE { PYTHONPATH="$PYTHONPATH" "$rootdir/scripts/rpc.py" --server; } exec {RPC_PIPE_OUTPUT}<&${RPC_PIPE[0]} {RPC_PIPE_INPUT}>&${RPC_PIPE[1]} # all descriptors will automatically close together with this bash # process, this will make rpc.py stop reading and exit gracefully diff --git a/test/event/scheduler/scheduler.sh b/test/event/scheduler/scheduler.sh index 00a36125b..ca8186d16 100755 --- a/test/event/scheduler/scheduler.sh +++ b/test/event/scheduler/scheduler.sh @@ -22,8 +22,7 @@ function scheduler_create_thread() { $rpc --plugin scheduler_plugin scheduler_thread_delete $thread_id } -export PYTHONPATH=$testdir -rpc="$rootdir/scripts/rpc.py" +rpc=rpc_cmd $testdir/scheduler -m 0xF -p 0x2 --wait-for-rpc & scheduler_pid=$! diff --git a/test/rpc/rpc.sh b/test/rpc/rpc.sh index 56da28cf5..8f02afe28 100755 --- a/test/rpc/rpc.sh +++ b/test/rpc/rpc.sh @@ -45,7 +45,7 @@ waitforlisten $spdk_pid export PYTHONPATH=$testdir # basic integrity test -rpc="$rootdir/scripts/rpc.py" +rpc=rpc_cmd run_test "rpc_integrity" rpc_integrity run_test "rpc_plugins" rpc_plugins # same integrity test, but with rpc_cmd() instead diff --git a/test/rpc_plugins/rpc_plugin.py b/test/rpc_plugins/rpc_plugin.py new file mode 120000 index 000000000..0a7424ec1 --- /dev/null +++ b/test/rpc_plugins/rpc_plugin.py @@ -0,0 +1 @@ +../rpc/rpc_plugin.py \ No newline at end of file diff --git a/test/rpc_plugins/scheduler_plugin.py b/test/rpc_plugins/scheduler_plugin.py new file mode 120000 index 000000000..827ea8dd3 --- /dev/null +++ b/test/rpc_plugins/scheduler_plugin.py @@ -0,0 +1 @@ +../event/scheduler/scheduler_plugin.py \ No newline at end of file diff --git a/test/scheduler/common.sh b/test/scheduler/common.sh index bd712f415..62ff348c7 100644 --- a/test/scheduler/common.sh +++ b/test/scheduler/common.sh @@ -4,8 +4,6 @@ declare -r sysfs_system=/sys/devices/system declare -r sysfs_cpu=$sysfs_system/cpu declare -r sysfs_node=$sysfs_system/node -export PYTHONPATH=$rootdir/test/event/scheduler - declare -r scheduler=$rootdir/test/event/scheduler/scheduler declare -r plugin=scheduler_plugin @@ -385,13 +383,13 @@ get_cpu_stat() { } create_thread() { - "$rootdir/scripts/rpc.py" --plugin "$plugin" scheduler_thread_create "$@" + rpc_cmd --plugin "$plugin" scheduler_thread_create "$@" } destroy_thread() { - "$rootdir/scripts/rpc.py" --plugin "$plugin" scheduler_thread_delete "$@" + rpc_cmd --plugin "$plugin" scheduler_thread_delete "$@" } active_thread() { - "$rootdir/scripts/rpc.py" --plugin "$plugin" scheduler_thread_set_active "$@" + rpc_cmd --plugin "$plugin" scheduler_thread_set_active "$@" }