test/json_config: check if config is cleared properly

Change-Id: I4699d07fb09311d6ad048278e350dd9727caecfd
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/434887
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Pawel Wodkowski 2018-11-26 15:59:36 +01:00 committed by Darek Stojaczyk
parent 4afffa7369
commit 6ad297aa17
2 changed files with 20 additions and 1 deletions

View File

@ -52,10 +52,23 @@ def filter_methods(do_remove_global_rpcs):
print(json.dumps(out, indent=2))
def check_empty():
data = json.loads(sys.stdin.read())
if not data:
raise EOFError("Cant read config!")
for s in data['subsystems']:
if s['config']:
print("Config not empty")
sys.exit(1)
if __name__ == "__main__":
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-method', dest='method', default=None,
help="""One of the methods:
check_empty
check if provided configuration is logically empty
delete_global_parameters
remove pre-init configuration (pre start_subsystem_init RPC methods)
delete_configs
@ -69,6 +82,8 @@ sort
filter_methods(True)
elif args.method == "delete_configs":
filter_methods(False)
elif args.method == "check_empty":
check_empty()
elif args.method == "sort":
""" Wrap input into JSON object so any input is possible here
like output from get_bdevs RPC method"""

View File

@ -327,7 +327,11 @@ function json_config_clear() {
[[ ! -z "${#app_socket[$1]}" ]] # Check app type
$rootdir/test/json_config/clear_config.py -s ${app_socket[$1]} clear_config
#TODO check if config is cleared
# Check if config is clean.
# Global params can't be cleared so need to filter them out.
local config_filter="$rootdir/test/json_config/config_filter.py"
$rootdir/scripts/rpc.py -s "${app_socket[$1]}" save_config | \
$config_filter -method delete_global_parameters | $config_filter -method check_empty
}
on_error_exit() {