From 0b802bd307d4dcd26692b32b0ab0cbb552664d5b Mon Sep 17 00:00:00 2001 From: Pawel Wodkowski Date: Thu, 13 Sep 2018 18:18:24 +0200 Subject: [PATCH] test: remove '-filename' from config_filter.py Change-Id: I30c49c28d46651b0f490f397919f3ddd68d1e24f Signed-off-by: Pawel Wodkowski Reviewed-on: https://review.gerrithub.io/425493 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- test/json_config/common.sh | 15 ++++++--------- test/json_config/config_filter.py | 13 ++++++------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/test/json_config/common.sh b/test/json_config/common.sh index 6903874237..979f4fb66f 100644 --- a/test/json_config/common.sh +++ b/test/json_config/common.sh @@ -12,7 +12,6 @@ last_json_config=$JSON_DIR/last_config.json full_config=$JSON_DIR/full_config.json base_bdevs=$JSON_DIR/bdevs_base.txt last_bdevs=$JSON_DIR/bdevs_last.txt -tmp_config=$JSON_DIR/tmp_config.json null_json_config=$JSON_DIR/null_json_config.json function run_spdk_tgt() { @@ -79,18 +78,16 @@ function kill_targets() { function test_json_config() { $rpc_py get_bdevs | jq '.|sort_by(.name)' > $base_bdevs $rpc_py save_config > $full_config - $JSON_DIR/config_filter.py -method "delete_global_parameters" -filename $full_config > $base_json_config + $JSON_DIR/config_filter.py -method "delete_global_parameters" < $full_config > $base_json_config $clear_config_py clear_config - $rpc_py save_config > $tmp_config - $JSON_DIR/config_filter.py -method "delete_global_parameters" -filename $tmp_config > $null_json_config + $rpc_py save_config | $JSON_DIR/config_filter.py -method "delete_global_parameters" > $null_json_config if [ "[]" != "$(jq '.subsystems | map(select(.config != null)) | map(select(.config != []))' $null_json_config)" ]; then echo "Config has not been cleared" return 1 fi $rpc_py load_config < $base_json_config $rpc_py get_bdevs | jq '.|sort_by(.name)' > $last_bdevs - $rpc_py save_config > $tmp_config - $JSON_DIR/config_filter.py -method "delete_global_parameters" -filename $tmp_config > $last_json_config + $rpc_py save_config | $JSON_DIR/config_filter.py -method "delete_global_parameters" > $last_json_config diff $base_json_config $last_json_config diff $base_bdevs $last_bdevs remove_config_files_after_test_json_config @@ -99,7 +96,7 @@ function test_json_config() { function remove_config_files_after_test_json_config() { rm -f $last_bdevs $base_bdevs rm -f $last_json_config $base_json_config - rm -f $tmp_config $full_config $null_json_config + rm -f $full_config $null_json_config } function create_pmem_bdev_subsytem_config() { @@ -185,7 +182,7 @@ function clear_bdev_subsystem_config() { function test_global_params() { target=$1 $rpc_py save_config > $full_config - python $JSON_DIR/config_filter.py -method "delete_configs" -filename $full_config > $base_json_config + python $JSON_DIR/config_filter.py -method "delete_configs" < $full_config > $base_json_config if [ $target == "spdk_tgt" ]; then killprocess $spdk_tgt_pid run_spdk_tgt @@ -198,7 +195,7 @@ function test_global_params() { fi $rpc_py load_config < $full_config $rpc_py save_config > $full_config - python $JSON_DIR/config_filter.py -method "delete_configs" -filename $full_config > $last_json_config + python $JSON_DIR/config_filter.py -method "delete_configs" < $full_config > $last_json_config diff $base_json_config $last_json_config rm $base_json_config $last_json_config rm $full_config diff --git a/test/json_config/config_filter.py b/test/json_config/config_filter.py index 41bef46a71..75b400f43d 100755 --- a/test/json_config/config_filter.py +++ b/test/json_config/config_filter.py @@ -1,9 +1,10 @@ #!/usr/bin/python +import sys import json import argparse -def filter_methods(filename, do_remove_global_rpcs): +def filter_methods(do_remove_global_rpcs): global_rpcs = [ 'set_iscsi_options', 'set_nvmf_target_config', @@ -13,8 +14,7 @@ def filter_methods(filename, do_remove_global_rpcs): 'set_bdev_nvme_hotplug', ] - with open(filename) as json_file: - data = json.loads(json_file.read()) + data = json.loads(sys.stdin.read()) out = {'subsystems': []} for s in data['subsystems']: if s['config']: @@ -31,16 +31,15 @@ def filter_methods(filename, do_remove_global_rpcs): 'config': s_config, }) - print json.dumps(out, indent=2) + print(json.dumps(out, indent=2)) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('-method', dest='method') - parser.add_argument('-filename', dest='filename') args = parser.parse_args() if args.method == "delete_global_parameters": - filter_methods(args.filename, True) + filter_methods(True) if args.method == "delete_configs": - filter_methods(args.filename, False) + filter_methods(False)