294e8a2fb6
Starting with this patch it is possible to issue "perform_tests" RPC to bdevperf application. It will allow to configure the bdevs after startup, but before starting the tests. bdevperf in addition to usual cmd line params for tests, need to be started with '-z' argument. After that it is possible to start test using './bdevperf.py perform_tests'. Tests can be issued multiple times in the same app run. At this time the RPC does not take any arguments for the tests. All are assumed to be set in the command line. This is series for adding RPC to bdevperf app. Change-Id: If71853b1aa742f9cbf3d65c8d694a0437aad4500 Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458598 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
87 lines
2.8 KiB
Python
Executable File
87 lines
2.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import logging
|
|
import argparse
|
|
import sys
|
|
import shlex
|
|
|
|
try:
|
|
from rpc.client import print_dict, JSONRPCException
|
|
import rpc
|
|
except ImportError:
|
|
print("SPDK RPC library missing. Please add spdk/scripts/ directory to PYTHONPATH:")
|
|
print("'export PYTHONPATH=$PYTHONPATH:./spdk/scripts/'")
|
|
exit(1)
|
|
|
|
try:
|
|
from shlex import quote
|
|
except ImportError:
|
|
from pipes import quote
|
|
|
|
|
|
def print_array(a):
|
|
print(" ".join((quote(v) for v in a)))
|
|
|
|
|
|
def perform_tests_func(client):
|
|
"""Perform bdevperf tests according to command line arguments when application was started.
|
|
|
|
Args:
|
|
none
|
|
|
|
Returns:
|
|
On success, 0 is returned. On error, -1 is returned.
|
|
"""
|
|
params = {}
|
|
return client.call('perform_tests', params)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(
|
|
description='SPDK RPC command line interface. NOTE: spdk/scripts/ is expected in PYTHONPATH')
|
|
parser.add_argument('-s', dest='server_addr',
|
|
help='RPC domain socket path or IP address', default='/var/tmp/spdk.sock')
|
|
parser.add_argument('-p', dest='port',
|
|
help='RPC port number (if server_addr is IP address)',
|
|
default=5260, type=int)
|
|
parser.add_argument('-t', dest='timeout',
|
|
help='Timeout as a floating point number expressed in seconds waiting for response. Default: 60.0',
|
|
default=60.0, type=float)
|
|
parser.add_argument('-v', dest='verbose', action='store_const', const="INFO",
|
|
help='Set verbose mode to INFO', default="ERROR")
|
|
parser.add_argument('--verbose', dest='verbose', choices=['DEBUG', 'INFO', 'ERROR'],
|
|
help="""Set verbose level. """)
|
|
subparsers = parser.add_subparsers(help='RPC methods')
|
|
|
|
def perform_tests(args):
|
|
print_dict(perform_tests_func(args.client))
|
|
|
|
p = subparsers.add_parser('perform_tests', help='Perform bdevperf tests')
|
|
p.set_defaults(func=perform_tests)
|
|
|
|
def call_rpc_func(args):
|
|
try:
|
|
args.func(args)
|
|
except JSONRPCException as ex:
|
|
print(ex.message)
|
|
exit(1)
|
|
|
|
def execute_script(parser, client, fd):
|
|
for rpc_call in map(str.rstrip, fd):
|
|
if not rpc_call.strip():
|
|
continue
|
|
args = parser.parse_args(shlex.split(rpc_call))
|
|
args.client = client
|
|
call_rpc_func(args)
|
|
|
|
args = parser.parse_args()
|
|
args.client = rpc.client.JSONRPCClient(args.server_addr, args.port, args.timeout, log_level=getattr(logging, args.verbose.upper()))
|
|
if hasattr(args, 'func'):
|
|
call_rpc_func(args)
|
|
elif sys.stdin.isatty():
|
|
# No arguments and no data piped through stdin
|
|
parser.print_help()
|
|
exit(1)
|
|
else:
|
|
execute_script(parser, args.client, sys.stdin)
|