test: remove '-filename' from config_filter.py
Change-Id: I30c49c28d46651b0f490f397919f3ddd68d1e24f Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/425493 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
8220121f44
commit
0b802bd307
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user