From a642a04b4a4bad8e06f26d1fade4304a23250daa Mon Sep 17 00:00:00 2001 From: tingtli Date: Thu, 20 Sep 2018 15:24:53 +0800 Subject: [PATCH] update case for task 246,xcat-inventory support regular expression (#5647) --- .../testcase/xcat-inventory/cases.nics | 45 +++++++++++++++++++ .../xcat-inventory/templates/nics.csv | 2 + .../xcat-inventory/templates/nics.json | 26 +++++++++++ .../xcat-inventory/templates/nics.yaml | 16 +++++++ 4 files changed, 89 insertions(+) create mode 100644 xCAT-test/autotest/testcase/xcat-inventory/cases.nics create mode 100644 xCAT-test/autotest/testcase/xcat-inventory/templates/nics.csv create mode 100644 xCAT-test/autotest/testcase/xcat-inventory/templates/nics.json create mode 100644 xCAT-test/autotest/testcase/xcat-inventory/templates/nics.yaml diff --git a/xCAT-test/autotest/testcase/xcat-inventory/cases.nics b/xCAT-test/autotest/testcase/xcat-inventory/cases.nics new file mode 100644 index 000000000..ca205dce8 --- /dev/null +++ b/xCAT-test/autotest/testcase/xcat-inventory/cases.nics @@ -0,0 +1,45 @@ +start:export_import_nics_with_regex +description:This case is used to test xcat-inventory export and import could support regex for xcat attributes. +label:others,xcat_inventory +cmd:dir="/tmp/export";if [ -e "${dir}" ];then mv ${dir} ${dir}".bak"; fi; mkdir -p $dir +cmd:tabdump nics |tee /tmp/export/nics.cvs +check:rc==0 +cmd:tabrestore /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/templates/nics.csv +check:rc==0 +cmd:xcat-inventory export -t node -o testnodes -f /tmp/export/nics.yaml --format yaml +check:rc==0 +check:output=~The inventory data has been dumped to /tmp/export/nics.yaml +cmd:diff -y /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/templates/nics.yaml /tmp/export/nics.yaml --ignore-blank-lines -I "^#" +check:rc==0 +cmd:xcat-inventory export -t node -o testnodes -f /tmp/export/nics.json --format json +check:rc==0 +cmd:diff -y /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/templates/nics.json /tmp/export/nics.json --ignore-blank-lines -I "^#" +check:rc==0 +cmd:tabch -d node="testnodes" nics +check:rc==0 +cmd:xcat-inventory import -t node -o testnodes -f /tmp/export/nics.yaml +check:rc==0 +check:output=~loading inventory date in "/tmp/export/nics.yaml" +check:output=~start to import "node" type objects +check:output=~ preprocessing "node" type objects +check:output=~ writting "node" type objects +check:output=~Inventory import successfully! +cmd:tabdump nics |tee /tmp/export/nics.yaml.cvs;diff -y /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/templates/nics.csv /tmp/export/nics.yaml.cvs +check:rc==0 +cmd:tabch -d node="testnodes" nics +check:rc==0 +cmd:xcat-inventory import -t node -o testnodes -f /tmp/export/nics.json +check:rc==0 +check:output=~loading inventory date in "/tmp/export/nics.json" +check:output=~start to import "node" type objects +check:output=~ preprocessing "node" type objects +check:output=~ writting "node" type objects +check:output=~Inventory import successfully! +cmd:tabdump nics |tee /tmp/export/nics.json.cvs;diff -y /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/templates/nics.csv /tmp/export/nics.json.cvs +check:rc==0 +cmd:tabch -d node="testnodes" nics +check:rc==0 +cmd:tabrestore /tmp/export/nics.cvs +check:rc==0 +cmd:dir="/tmp/export"; rm -rf $dir; if [ -d ${dir}".bak" ];then mv ${dir}".bak" $dir; fi +end diff --git a/xCAT-test/autotest/testcase/xcat-inventory/templates/nics.csv b/xCAT-test/autotest/testcase/xcat-inventory/templates/nics.csv new file mode 100644 index 000000000..df4853f19 --- /dev/null +++ b/xCAT-test/autotest/testcase/xcat-inventory/templates/nics.csv @@ -0,0 +1,2 @@ +#node,nicips,nichostnamesuffixes,nichostnameprefixes,nictypes,niccustomscripts,nicnetworks,nicaliases,nicextraparams,nicdevices,nicsadapter,comments,disable +"testnodes","|(.)(..)n(..)|ib0!(ipadd(10,41,0,100,dim2idx(a2idx($1),36,$2,18,$3),2,1))|","ib0!ib",,"ib0!Infiniband",,"ib0!ipoib",,,,,, diff --git a/xCAT-test/autotest/testcase/xcat-inventory/templates/nics.json b/xCAT-test/autotest/testcase/xcat-inventory/templates/nics.json new file mode 100644 index 000000000..d7a09a71d --- /dev/null +++ b/xCAT-test/autotest/testcase/xcat-inventory/templates/nics.json @@ -0,0 +1,26 @@ +{ + "node": { + "testnodes": { + "device_type": "server", + "network_info": { + "nics": { + "ib0": { + "hostnamesuffixes": [ + "ib" + ], + "ips": "|(.)(..)n(..)|ib0!(ipadd(10,41,0,100,dim2idx(a2idx($1),36,$2,18,$3),2,1))|", + "networks": [ + "ipoib" + ], + "type": [ + "Infiniband" + ] + } + } + }, + "obj_type": "group", + "role": "compute" + } + }, + "schema_version": "1.0" +} diff --git a/xCAT-test/autotest/testcase/xcat-inventory/templates/nics.yaml b/xCAT-test/autotest/testcase/xcat-inventory/templates/nics.yaml new file mode 100644 index 000000000..86a789c06 --- /dev/null +++ b/xCAT-test/autotest/testcase/xcat-inventory/templates/nics.yaml @@ -0,0 +1,16 @@ +node: + testnodes: + device_type: server + network_info: + nics: + ib0: + hostnamesuffixes: + - ib + ips: '|(.)(..)n(..)|ib0!(ipadd(10,41,0,100,dim2idx(a2idx($1),36,$2,18,$3),2,1))|' + networks: + - ipoib + type: + - Infiniband + obj_type: group + role: compute +schema_version: '1.0'