mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-30 01:26:38 +00:00
192 lines
6.8 KiB
Plaintext
192 lines
6.8 KiB
Plaintext
start:xcat_inventory_option_h
|
|
description:This case is used to test xcat-inventory usage information
|
|
label:others,xcat_inventory
|
|
cmd:xcat-inventory -h
|
|
check:ouptut=~usage: xcat-inventory
|
|
check:ouptut!~usage: xcat-inventory export
|
|
check:ouptut!~usage: xcat-inventory import
|
|
check:rc==0
|
|
cmd:xcat-inventory help
|
|
check:ouptut=~usage: xcat-inventory
|
|
check:ouptut!~usage: xcat-inventory export
|
|
check:ouptut!~usage: xcat-inventory import
|
|
check:rc==0
|
|
cmd:xcat-inventory help export
|
|
check:ouptut=~usage: xcat-inventory export
|
|
check:rc==0
|
|
cmd:xcat-inventory help import
|
|
check:output=~usage: xcat-inventory import
|
|
check:rc==0
|
|
cmd:xcat-inventory help help
|
|
check:output=~usage: xcat-inventory help
|
|
check:rc==0
|
|
end
|
|
|
|
|
|
start:xcat_inventory_option_V
|
|
description:This case is used to test xcat-inventory option V which used to get version information
|
|
label:others,xcat_inventory
|
|
cmd:xcat-inventory -V
|
|
check:ouptut=~\d\.\d
|
|
check:rc==0
|
|
end
|
|
|
|
start:xcat_inventory_invalid_subcmd
|
|
description:This case is used to test xcat-inventory export subcommand to handle invalid subcommand. The vaild subcommand are export and import.
|
|
label:others,xcat_inventory
|
|
cmd:xcat-inventory aaa
|
|
check:output=~ Error: not a valid subcommand to run
|
|
check:output=~ usage:
|
|
check:rc!=0
|
|
end
|
|
|
|
start:xcat_inventory_export_option_t_invalid_type
|
|
description:This case is used to test xcat-inventory export subcommand to handle invalid type for option t
|
|
label:others,xcat_inventory
|
|
cmd:xcat-inventory export -t aaa
|
|
check:output=~Invalid object type
|
|
check:output!~Traceback (most recent call last):
|
|
check:rc!=0
|
|
end
|
|
|
|
start:xcat_inventory_export_option_format_invalid_type
|
|
description:This case is used to test xcat-inventory export subcommand to handle invalid type for option format
|
|
label:others,xcat_inventory
|
|
cmd:xcat-inventory export --format aaa
|
|
check:output=~Invalid exporting format: aaa
|
|
check:output!~Traceback (most recent call last):
|
|
check:rc!=0
|
|
end
|
|
|
|
start:xcat_inventory_export_option_f
|
|
description:This case is used to test xcat-inventory export subcommand to handle option f
|
|
label:others,xcat_inventory
|
|
cmd:dir="/tmp/xcat_inventory_export_option_f";echo ${dir}".old";if [ -d "${dir}" ];then mv ${dir} ${dir}".old"; fi; mkdir -p $dir
|
|
check:rc==0
|
|
cmd:lsdef bogusnode > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef bogusnode -z >/tmp/xcat_inventory_export_option_f/bogusnode.stanza ;rmdef bogusnode;fi
|
|
check:rc==0
|
|
cmd:mkdef -t node -o bogusnode groups=bogusgroup
|
|
check:rc==0
|
|
cmd:xcat-inventory export --format=yaml -t node -o bogusnode | tee /tmp/xcat_inventory_export_option_f/export_yaml_without_f
|
|
check:rc==0
|
|
cmd:xcat-inventory export --format=yaml -t node -o bogusnode -f /tmp/xcat_inventory_export_option_f/export_yaml_with_f
|
|
check:rc==0
|
|
check:output !~Traceback
|
|
cmd:#!/bin/bash
|
|
diff -y --ignore-blank-lines --ignore-matching-lines="^#" /tmp/xcat_inventory_export_option_f/export_yaml_without_f /tmp/xcat_inventory_export_option_f/export_yaml_with_f
|
|
check:rc==0
|
|
cmd:xcat-inventory export -t node -o bogusnode | tee /tmp/xcat_inventory_export_option_f/export_json_without_f
|
|
check:rc==0
|
|
cmd:xcat-inventory export -t node -o bogusnode --path /tmp/xcat_inventory_export_option_f/export_json_with_f
|
|
check:rc==0
|
|
cmd:#!/bin/bash
|
|
diff -y --ignore-blank-lines --ignore-matching-lines="^#" /tmp/xcat_inventory_export_option_f/export_json_without_f /tmp/xcat_inventory_export_option_f/export_json_with_f
|
|
check:rc==0
|
|
cmd:xcat-inventory export -t node -o bogusnode -f
|
|
check:rc!=0
|
|
check:output ~=usage
|
|
check:output ~= error: argument -f/--path: expected one argument
|
|
cmd:xcat-inventory export -t node -o bogusnode --path
|
|
check:rc!=0
|
|
eck:output ~=usage
|
|
check:output ~= error: argument -f/--path: expected one argument
|
|
cmd:mkdir /tmp/xcat_inventory_export_option_f/testdir
|
|
check:rc==0
|
|
cmd:xcat-inventory export -t node -o bogusnode -f /tmp/xcat_inventory_export_option_f/testdir
|
|
check:rc!=0
|
|
check:output ~= Error: the specified file /tmp/xcat_inventory_export_option_f/testdir already exists, is not a file!
|
|
cmd:rmdef bogusnode
|
|
check:rc==0
|
|
cmd:if [[ -e /tmp/xcat_inventory_export_option_f/bogusnode.stanza ]]; then cat /tmp/xcat_inventory_export_option_f/bogusnode.stanza | mkdef -z;fi
|
|
check:rc==0
|
|
cmd:dir="/tmp/xcat_inventory_export_option_f"; rm -rf $dir; if [ -d ${dir}".old" ];then mv ${dir}".old" $dir; fi
|
|
check:rc==0
|
|
end
|
|
|
|
start:xcat_inventory_import_option_f_invalid_file
|
|
description:This case is used to test xcat-inventory import subcommand to handle invalid file for option f
|
|
label:others,xcat_inventory
|
|
cmd:mkdir -p /tmp/xcat_inventory_import_option_f_invalid_file
|
|
check:rc==0
|
|
#to handle a non-existed file
|
|
cmd:xcat-inventory import -f aaa
|
|
check:output=~the directory does not exist or is not a directory
|
|
check:output !~Traceback
|
|
check:rc!=0
|
|
#To handle a invalid json file
|
|
cmd:#!/usr/bin/bash
|
|
echo "{
|
|
"node": {
|
|
"bogusnode": {
|
|
"device_type": "server",
|
|
"obj_info": {
|
|
"groups": "test"
|
|
},
|
|
"obj_type": "node",
|
|
"role": "compute"
|
|
}
|
|
}
|
|
" > /tmp/xcat_inventory_import_option_f_invalid_file/invaild_json
|
|
check:rc==0
|
|
cmd:cat /tmp/xcat_inventory_import_option_f_invalid_file/invaild_json
|
|
check:rc==0
|
|
cmd:xcat-inventory import -f /tmp/xcat_inventory_import_option_f_invalid_file/invaild_json
|
|
check:output =~ Error: failed to load file
|
|
check:output !~Traceback
|
|
check:rc!=0
|
|
#To handle a invalid yaml file
|
|
cmd:#!/usr/bin/bash
|
|
echo "node:
|
|
device_type: server
|
|
obj_info:
|
|
groups: test
|
|
obj_type: node
|
|
role: compute
|
|
" > /tmp/xcat_inventory_import_option_f_invalid_file/invaild_yaml
|
|
check:rc==0
|
|
cmd:cat /tmp/xcat_inventory_import_option_f_invalid_file/invaild_yaml
|
|
check:rc==0
|
|
cmd:xcat-inventory import -f /tmp/xcat_inventory_import_option_f_invalid_file/invaild_yaml
|
|
check:output =~ Error:
|
|
check:output !~Traceback
|
|
check:rc!=0
|
|
cmd:rm -rf /tmp/xcat_inventory_import_option_f_invalid_file
|
|
check:rc==0
|
|
end
|
|
|
|
|
|
start:xcat_inventory_import_option_t_invalid_type
|
|
description:This case is used to test xcat-inventory import subcommand to handle invalid type for option t
|
|
label:others,xcat_inventory
|
|
cmd:xcat-inventory import -t aaa
|
|
check:output=~Invalid object type
|
|
check:output!~Traceback (most recent call last):
|
|
check:rc!=0
|
|
end
|
|
|
|
|
|
start:xcat_inventory_import_miss_option
|
|
description:This case is used to test xcat-inventory import subcommand to handle missing -t or -o option
|
|
label:others,xcat_inventory
|
|
cmd:mkdir -p /tmp/export_import_nodes_delimited_with_comma_by_json
|
|
check:rc==0
|
|
cmd:#!/usr/bin/bash
|
|
echo "{
|
|
"node": {
|
|
"test": {
|
|
"device_type": "server",
|
|
"obj_info": {
|
|
"groups": "testgroup"
|
|
},
|
|
"obj_type": "node",
|
|
"role": "compute"
|
|
}
|
|
}
|
|
}" > /tmp/export_import_nodes_delimited_with_comma_by_json/aaa
|
|
cmd:xcat-inventory import -f /tmp/export_import_nodes_delimited_with_comma_by_json/aaa -o aaa
|
|
check:output=~Missing object type for object
|
|
check:rc!=0
|
|
cmd:rm -rf /tmp/export_import_nodes_delimited_with_comma_by_json
|
|
check:rc==0
|
|
end
|