2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2024-11-23 18:10:14 +00:00
2 Test Design of xcat inventory regular expression
tingtli edited this page 2018-09-21 09:57:18 +08:00

Introduction

This document provides an overview of test xcat-inventory export and import could process regex in database. This test plan is intended for the use of xCAT FVT team.

The test is against xCAT version 2.14.4. The build of xCAT will be picked up from the xcat.org

The xcat inventory regex design is under https://github.com/xcat2/xcat-inventory/pull/74

Affected tables

The following table will be used in the test

#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",,,,,,

Test steps

  1. create a new nics table with regex in it.
#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",,,,,,

2.execute xcat-inventory export with correct options

[root@c910f03c01p13 ~]# xcat-inventory export  -t node -o testnodes -f /tmp/export/nics.yaml --format yaml
The inventory data has been dumped to /tmp/export/nics.yaml
  1. check if inventory data is correct in /tmp/export/nics.yaml
[root@c910f03c01p13 ~]# cat /tmp/export/nics.yaml
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'

#Version 2.14.3 (git commit 7b7d9ab67589afec1ba58cd5138154290c529c0e, built Tue 
  1. execute xcat-inventory with correct options
[root@c910f03c01p13 ~]# xcat-inventory export  -t node -o testnodes -f /tmp/export/nics.json --format json
The inventory data has been dumped to /tmp/export/nics.json

  1. check /tmp/export/nics.json is correct
[root@c910f03c01p13 ~]# cat /tmp/export/nics.json
{
    "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"
}
#Version 2.14.3 (git commit 7b7d9ab67589afec1ba58cd5138154290c529c0e, built Tue Aug 21 07:16:00 EDT 2018)
  1. remove nics table and to run import options
[root@c910f03c01p13 ~]# tabdump nics
#node,nicips,nichostnamesuffixes,nichostnameprefixes,nictypes,niccustomscripts,nicnetworks,nicaliases,nicextraparams,nicdevices,nicsadapter,comments,disable

  1. run xcat-inventory import with correct options
[root@c910f03c01p13 ~]# xcat-inventory import  -t node -o testnodes -f /tmp/export/nics.json
loading inventory date in "/tmp/export/nics.json"
start to import "node" type objects
 preprocessing "node" type objects
 writting "node" type objects
Inventory import successfully!
  1. Check nics table is correctly imported
[root@c910f03c01p13 ~]# tabdump nics
#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",,,,,,

  1. Remove nics table
[root@c910f03c01p13 ~]# xcat-inventory import  -t node -o testnodes -f /tmp/export/nics.yaml
loading inventory date in "/tmp/export/nics.yaml"
start to import "node" type objects
 preprocessing "node" type objects
 writting "node" type objects
Inventory import successfully!
  1. run xcat-inventory import with correct options
[root@c910f03c01p13 ~]# xcat-inventory import  -t node -o testnodes -f /tmp/export/nics.json
loading inventory date in "/tmp/export/nics.json"
start to import "node" type objects
 preprocessing "node" type objects
 writting "node" type objects
Inventory import successfully!
  1. Check nics table is correctly imported
[root@c910f03c01p13 ~]# tabdump nics
#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",,,,,,