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
|
full_config=$JSON_DIR/full_config.json
|
||||||
base_bdevs=$JSON_DIR/bdevs_base.txt
|
base_bdevs=$JSON_DIR/bdevs_base.txt
|
||||||
last_bdevs=$JSON_DIR/bdevs_last.txt
|
last_bdevs=$JSON_DIR/bdevs_last.txt
|
||||||
tmp_config=$JSON_DIR/tmp_config.json
|
|
||||||
null_json_config=$JSON_DIR/null_json_config.json
|
null_json_config=$JSON_DIR/null_json_config.json
|
||||||
|
|
||||||
function run_spdk_tgt() {
|
function run_spdk_tgt() {
|
||||||
@ -79,18 +78,16 @@ function kill_targets() {
|
|||||||
function test_json_config() {
|
function test_json_config() {
|
||||||
$rpc_py get_bdevs | jq '.|sort_by(.name)' > $base_bdevs
|
$rpc_py get_bdevs | jq '.|sort_by(.name)' > $base_bdevs
|
||||||
$rpc_py save_config > $full_config
|
$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
|
$clear_config_py clear_config
|
||||||
$rpc_py save_config > $tmp_config
|
$rpc_py save_config | $JSON_DIR/config_filter.py -method "delete_global_parameters" > $null_json_config
|
||||||
$JSON_DIR/config_filter.py -method "delete_global_parameters" -filename $tmp_config > $null_json_config
|
|
||||||
if [ "[]" != "$(jq '.subsystems | map(select(.config != null)) | map(select(.config != []))' $null_json_config)" ]; then
|
if [ "[]" != "$(jq '.subsystems | map(select(.config != null)) | map(select(.config != []))' $null_json_config)" ]; then
|
||||||
echo "Config has not been cleared"
|
echo "Config has not been cleared"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
$rpc_py load_config < $base_json_config
|
$rpc_py load_config < $base_json_config
|
||||||
$rpc_py get_bdevs | jq '.|sort_by(.name)' > $last_bdevs
|
$rpc_py get_bdevs | jq '.|sort_by(.name)' > $last_bdevs
|
||||||
$rpc_py save_config > $tmp_config
|
$rpc_py save_config | $JSON_DIR/config_filter.py -method "delete_global_parameters" > $last_json_config
|
||||||
$JSON_DIR/config_filter.py -method "delete_global_parameters" -filename $tmp_config > $last_json_config
|
|
||||||
diff $base_json_config $last_json_config
|
diff $base_json_config $last_json_config
|
||||||
diff $base_bdevs $last_bdevs
|
diff $base_bdevs $last_bdevs
|
||||||
remove_config_files_after_test_json_config
|
remove_config_files_after_test_json_config
|
||||||
@ -99,7 +96,7 @@ function test_json_config() {
|
|||||||
function remove_config_files_after_test_json_config() {
|
function remove_config_files_after_test_json_config() {
|
||||||
rm -f $last_bdevs $base_bdevs
|
rm -f $last_bdevs $base_bdevs
|
||||||
rm -f $last_json_config $base_json_config
|
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() {
|
function create_pmem_bdev_subsytem_config() {
|
||||||
@ -185,7 +182,7 @@ function clear_bdev_subsystem_config() {
|
|||||||
function test_global_params() {
|
function test_global_params() {
|
||||||
target=$1
|
target=$1
|
||||||
$rpc_py save_config > $full_config
|
$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
|
if [ $target == "spdk_tgt" ]; then
|
||||||
killprocess $spdk_tgt_pid
|
killprocess $spdk_tgt_pid
|
||||||
run_spdk_tgt
|
run_spdk_tgt
|
||||||
@ -198,7 +195,7 @@ function test_global_params() {
|
|||||||
fi
|
fi
|
||||||
$rpc_py load_config < $full_config
|
$rpc_py load_config < $full_config
|
||||||
$rpc_py save_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
|
diff $base_json_config $last_json_config
|
||||||
rm $base_json_config $last_json_config
|
rm $base_json_config $last_json_config
|
||||||
rm $full_config
|
rm $full_config
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
import sys
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
def filter_methods(filename, do_remove_global_rpcs):
|
def filter_methods(do_remove_global_rpcs):
|
||||||
global_rpcs = [
|
global_rpcs = [
|
||||||
'set_iscsi_options',
|
'set_iscsi_options',
|
||||||
'set_nvmf_target_config',
|
'set_nvmf_target_config',
|
||||||
@ -13,8 +14,7 @@ def filter_methods(filename, do_remove_global_rpcs):
|
|||||||
'set_bdev_nvme_hotplug',
|
'set_bdev_nvme_hotplug',
|
||||||
]
|
]
|
||||||
|
|
||||||
with open(filename) as json_file:
|
data = json.loads(sys.stdin.read())
|
||||||
data = json.loads(json_file.read())
|
|
||||||
out = {'subsystems': []}
|
out = {'subsystems': []}
|
||||||
for s in data['subsystems']:
|
for s in data['subsystems']:
|
||||||
if s['config']:
|
if s['config']:
|
||||||
@ -31,16 +31,15 @@ def filter_methods(filename, do_remove_global_rpcs):
|
|||||||
'config': s_config,
|
'config': s_config,
|
||||||
})
|
})
|
||||||
|
|
||||||
print json.dumps(out, indent=2)
|
print(json.dumps(out, indent=2))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-method', dest='method')
|
parser.add_argument('-method', dest='method')
|
||||||
parser.add_argument('-filename', dest='filename')
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.method == "delete_global_parameters":
|
if args.method == "delete_global_parameters":
|
||||||
filter_methods(args.filename, True)
|
filter_methods(True)
|
||||||
if args.method == "delete_configs":
|
if args.method == "delete_configs":
|
||||||
filter_methods(args.filename, False)
|
filter_methods(False)
|
||||||
|
Loading…
Reference in New Issue
Block a user