finished test driver for node resource

This commit is contained in:
Bruce Potter 2014-02-26 19:34:16 -05:00
parent c58f440db1
commit 681ec3c968
2 changed files with 637 additions and 769 deletions

View File

@ -1,35 +1,132 @@
#!/bin/bash
# IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html
# Test driver for xcatws.cgi, pass two arguments to it, user and password.
# Usage example: ./xcatws-test.sh wsuer cluster
# Test driver for xcatws.cgi, pass 3 arguments to it: user, password, noderange
# This test driver will create to dummy nodes, wstest1 and wstest2, so make sure those
# names don't conflict with your nodes on this MN.
# You also have to pass in a noderange of 2 real system x nodes that can be used
# to test some of the r cmds, xdsh, xdcp, nodestat.
user=$1
pw=$2
nr=$3
if [ -z "$3" ]; then
echo "Usage: chkrc <user> <pw> <noderange>"
exit
fi
format='format=json&pretty=1'
ctype='-H Content-Type:application/json'
function chkrc
{
rc=$?
{ set +x; } 2>/dev/null
if [[ $1 == "not" ]]; then
if [[ $rc -eq 0 ]]; then
echo "Test failed!"
exit
fi
else
if [[ $rc -gt 0 ]]; then
echo "Test failed!"
exit
fi
fi
echo ''
set -x
}
# pcregrep -M 'abc.*(\n|.)*efg' test.txt
#todo: add a test case for every api call that is documented
#curl [options] [URL...]:
# -X/--request <command> : commands include PUT,POST,GET and DELETE.
# -k/--insecure : This option explicitly allows curl to perform "insecure" SSL connections and transfers.
set -x
# clean up from last time
curl -# -X DELETE -k "https://127.0.0.1/xcatws/nodes/wstest?userName=$user&password=$pw" >/dev/null; echo ''
curl -X GET -k "https://127.0.0.1/xcatws/nodes?userName=$user&password=$pw&$format"
curl -X GET -k "https://127.0.0.1/xcatws/nodes?userName=$user&password=$pw&$format&field=mac"
curl -X GET -k "https://127.0.0.1/xcatws/nodes/test001-test006?userName=$user&password=$pw&$format"
curl -X GET -k "https://127.0.0.1/xcatws/nodes/test001-test006?userName=$user&password=$pw&$format&field=mac"
curl -X DELETE -k "http://127.0.0.1/xcatws/nodes/test001?userName=$user&password=$pw"
curl -X PUT -k "https://127.0.0.1/xcatws/nodes/test001?userName=$user&password=$pw&$format" -H Content-Type:application/json --data '{"room":"hi","unit":"7"}'
curl -X POST -k "https://127.0.0.1/xcatws/nodes/ws1?userName=$user&password=$pw&$format" -H Content-Type:application/json --data '{"groups":"wstest"}'
curl -X POST -k "https://127.0.0.1/xcatws/nodes/bruce/dsh?userName=$user&password=$pw&$format" -H Content-Type:application/json --data '["command=date"]'
# create test nodes
curl -# -X POST -k "https://127.0.0.1/xcatws/nodes/wstest1-wstest2?userName=$user&password=$pw&$format" $ctype --data '{"groups":"wstest","netboot":"xnba"}' \
| grep -q '2 object definitions have been created'; chkrc
curl -X GET -k "https://127.0.0.1/xcatws/groups?userName=$user&password=$pw&$format"
# list all nodes and make sure they are in the list
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes?userName=$user&password=$pw&$format" \
| pcregrep -qM '"wstest1",\n\s*"wstest2"'; chkrc
curl -X GET -k "https://127.0.0.1/xcatws/images?userName=$user&password=$pw&$format"
curl -X GET -k "https://127.0.0.1/xcatws/images?userName=$user&password=$pw&$format&field=osvers"
curl -X GET -k "https://127.0.0.1/xcatws/images/bp-netboot?userName=$user&password=$pw&$format"
curl -X GET -k "https://127.0.0.1/xcatws/images/bp-netboot?userName=$user&password=$pw&$format&field=osvers"
# list all node's group and netboot attributes
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes?userName=$user&password=$pw&field=groups&field=netboot" \
| grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc
# list all attributes of all nodes
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes?userName=$user&password=$pw&field=ALL" \
| grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc
# list the noderange and make sure they are in the list
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes/wstest?userName=$user&password=$pw&$format" \
| pcregrep -qM '"wstest1",\n\s*"wstest2"'; chkrc
# list all node's group and netboot attributes
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes/wstest?userName=$user&password=$pw&field=groups&field=netboot" \
| grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc
# list all attributes of all nodes
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes/wstest?userName=$user&password=$pw&field=ALL" \
| grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc
# change some attributes
curl -# -X PUT -k "https://127.0.0.1/xcatws/nodes/wstest?userName=$user&password=$pw&$format" $ctype --data '{"room":"222","netboot":"pxe"}' \
| grep -q '2 object definitions have been created or modified'; chkrc
# verify they got the new values
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes/wstest?userName=$user&password=$pw&field=room&field=netboot" \
| grep -qE '"nodename":"wstest1".*"room":"222"'; chkrc
# delete the nodes
curl -# -X DELETE -k "https://127.0.0.1/xcatws/nodes/wstest?userName=$user&password=$pw&$format" \
| grep -q '2 object definitions have been removed'; chkrc
# list all nodes and make sure they are not in the list
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes?userName=$user&password=$pw&$format" \
| pcregrep -qM '"wstest1",\n\s*"wstest2"'; chkrc not
# list the power state of the noderange
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes/$nr/power?userName=$user&password=$pw&$format" \
| grep -q '"power":"on"'; chkrc
# list the nodestat state of the noderange
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes/$nr/status?userName=$user&password=$pw&$format" \
| grep -q '":"sshd"'; chkrc
# list the node inventory of the noderange
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes/$nr/inventory?userName=$user&password=$pw&$format" \
| grep -q '"Board manufacturer":"IBM"'; chkrc
# list the node vitals of the noderange
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes/$nr/vitals?userName=$user&password=$pw&$format" \
| grep -q '"Cooling Fault":"false"'; chkrc
# list the node energy settings of the noderange
curl -# -X GET -k "https://127.0.0.1/xcatws/nodes/$nr/energy?userName=$user&password=$pw&$format&field=cappingstatus&field=cappingmaxmin" \
| grep -q '"cappingstatus":"off"'; chkrc
# run a cmd on the noderange
curl -# -X POST -k "https://127.0.0.1/xcatws/nodes/$nr/dsh?userName=$user&password=$pw&$format" $ctype --data '{"command":"pwd"}' \
| grep -q '"/root"'; chkrc
# copy a file to the noderange
curl -# -X POST -k "https://127.0.0.1/xcatws/nodes/$nr/dcp?userName=$user&password=$pw&$format" $ctype --data '{"source":"/root/.bashrc","target":"/tmp/"}' \
| grep -q '"errorcode":"0"'; chkrc
exit
#curl -X GET -k "https://127.0.0.1/xcatws/groups?userName=$user&password=$pw&$format"
#curl -X GET -k "https://127.0.0.1/xcatws/images?userName=$user&password=$pw&$format"
#curl -X GET -k "https://127.0.0.1/xcatws/images?userName=$user&password=$pw&$format&field=osvers"
#curl -X GET -k "https://127.0.0.1/xcatws/images/bp-netboot?userName=$user&password=$pw&$format"
#curl -X GET -k "https://127.0.0.1/xcatws/images/bp-netboot?userName=$user&password=$pw&$format&field=osvers"
#todo: remove when these test cases are in xcatws-test.pl
./xcatws-test.pl -u "https://127.0.0.1/xcatws/nodes/test001?userName=$user&password=$pw" -m GET
./xcatws-test.pl -u "https://127.0.0.1/xcatws/nodes/test001?userName=$user&password=$pw" -m PUT "nodepos.room=foo"
#./xcatws-test.pl -u "https://127.0.0.1/xcatws/nodes/test001?userName=$user&password=$pw" -m GET
#./xcatws-test.pl -u "https://127.0.0.1/xcatws/nodes/test001?userName=$user&password=$pw" -m PUT "nodepos.room=foo"

File diff suppressed because it is too large Load Diff