2014-02-03 20:58:15 +00:00
|
|
|
#!/bin/bash
|
2014-02-23 09:13:15 +00:00
|
|
|
# IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html
|
2014-01-31 13:26:55 +00:00
|
|
|
|
2014-02-27 00:34:16 +00:00
|
|
|
# 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.
|
2014-02-24 09:14:18 +00:00
|
|
|
|
|
|
|
user=$1
|
|
|
|
pw=$2
|
2014-02-27 00:34:16 +00:00
|
|
|
nr=$3
|
|
|
|
if [ -z "$3" ]; then
|
|
|
|
echo "Usage: chkrc <user> <pw> <noderange>"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2014-02-24 09:14:18 +00:00
|
|
|
format='format=json&pretty=1'
|
2014-02-27 00:34:16 +00:00
|
|
|
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
|
2014-02-03 20:58:15 +00:00
|
|
|
|
2014-02-23 09:13:15 +00:00
|
|
|
#todo: add a test case for every api call that is documented
|
2014-02-27 00:34:16 +00:00
|
|
|
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 ''
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# 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"
|
2014-02-23 09:13:15 +00:00
|
|
|
|
|
|
|
#todo: remove when these test cases are in xcatws-test.pl
|
2014-02-27 00:34:16 +00:00
|
|
|
#./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"
|