-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
251 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#!/bin/bash | ||
|
||
#test update project resources file | ||
|
||
DIR=$(cd `dirname $0` && pwd) | ||
source $DIR/include.sh | ||
file=$DIR/curl.out | ||
|
||
# now submit req | ||
proj="test" | ||
|
||
runurl="${APIURL}/project/${proj}/resources/refresh" | ||
|
||
echo "TEST: /api/project/${proj}/resources/refresh (no URL defined)" | ||
params="t=t" | ||
|
||
$CURL -X POST ${runurl}?${params} > ${file} || fail "ERROR: failed request" | ||
|
||
sh $DIR/api-test-error.sh ${file} "Resources were not updated because no resource model provider URL is configured for project test" || exit 2 | ||
|
||
echo "OK" | ||
|
||
echo "TEST: /api/project/${proj}/resources/refresh (invalid URL)" | ||
|
||
#backup project.properties and set invalid resources url | ||
|
||
TETC=$RDECK_BASE/projects/test/etc | ||
TPROPS=$TETC/project.properties | ||
TRES=$TETC/resources.xml | ||
|
||
if [ ! -f $TPROPS.testbackup ] ; then | ||
cp $TPROPS $TPROPS.testbackup | ||
fi | ||
if [ ! -f $TRES.testbackup ] ; then | ||
cp $TRES $TRES.testbackup | ||
fi | ||
|
||
echo "project.resources.url=http://invaliddomain:1234/resources.xml" >> $TPROPS | ||
|
||
|
||
$CURL -X POST ${runurl}?${params} > ${file} || fail "ERROR: failed request" | ||
|
||
sh $DIR/api-test-error.sh ${file} "Error updating node resources file for project test: java.net.UnknownHostException: invaliddomain" || exit 2 | ||
|
||
echo "OK" | ||
|
||
cp $TPROPS.testbackup $TPROPS | ||
|
||
echo "TEST: /api/project/${proj}/resources/refresh (valid temp URL)" | ||
|
||
cat <<END > $TETC/testUpdateResources.xml | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE project PUBLIC "-//DTO Labs Inc.//DTD Resources Document 1.0//EN" "project.dtd"> | ||
<project> | ||
<node name="test1" type="Node" description="Rundeck test node" tags="test1,testboth" hostname="testhost1" osArch="x86_64" osFamily="unix" osName="Mac OS X" osVersion="10.6.6" username="rdeck" editUrl="" remoteUrl=""/> | ||
<node name="test2" type="Node" description="Rundeck test node" tags="test2,testboth" hostname="testhost2" osArch="x86_64" osFamily="unix" osName="Mac OS X" osVersion="10.6.6" username="rdeck1" editUrl="" remoteUrl=""/> | ||
</project> | ||
END | ||
|
||
TEMPURL="file://$TETC/testUpdateResources.xml" | ||
|
||
echo "project.resources.url=$TEMPURL" >> $TPROPS | ||
|
||
|
||
$CURL -X POST ${runurl}?${params} > ${file} || fail "ERROR: failed request" | ||
|
||
sh $DIR/api-test-success.sh ${file} "Resources were successfully updated for project test" || exit 2 | ||
|
||
echo "OK" | ||
|
||
#restore backup props, no provider url | ||
if [ -f $TPROPS.testbackup ] ; then | ||
mv $TPROPS.testbackup $TPROPS | ||
fi | ||
|
||
echo "TEST: /api/project/${proj}/resources/refresh (POST) (invalid provider URL)" | ||
|
||
#backup project.properties and set invalid resources url | ||
|
||
data="providerURL=http://invaliddomain:1234/resources.xml" | ||
|
||
# post data | ||
$CURL -X POST --data-urlencode "${data}" ${runurl}?${params} > ${file} || fail "ERROR: failed request" | ||
|
||
sh $DIR/api-test-error.sh ${file} "Error updating node resources file for project test: java.net.UnknownHostException: invaliddomain" || exit 2 | ||
|
||
echo "OK" | ||
|
||
|
||
echo "TEST: /api/project/${proj}/resources/refresh (POST) (valid provider URL)" | ||
|
||
|
||
TEMPURL="file://$TETC/testUpdateResources.xml" | ||
|
||
data="providerURL=$TEMPURL" | ||
|
||
# post data | ||
$CURL -X POST --data-urlencode "${data}" ${runurl}?${params} > ${file} || fail "ERROR: failed request" | ||
|
||
sh $DIR/api-test-success.sh ${file} "Resources were successfully updated for project test" || exit 2 | ||
|
||
echo "OK" | ||
|
||
|
||
if [ -f $TRES.testbackup ] ; then | ||
mv $TRES.testbackup $TRES | ||
fi | ||
|
||
rm ${file} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
#!/bin/bash | ||
|
||
#test update project resources file | ||
|
||
DIR=$(cd `dirname $0` && pwd) | ||
source $DIR/include.sh | ||
|
||
file=$DIR/curl.out | ||
|
||
# now submit req | ||
proj="test" | ||
|
||
runurl="${APIURL}/project/${proj}/resources" | ||
|
||
echo "TEST: /api/project/${proj}/resources (GET)" | ||
params="format=xml" | ||
|
||
# get listing | ||
$CURL ${runurl}?${params} > ${file} || fail "ERROR: failed request" | ||
|
||
#test curl.out for valid xml | ||
$XMLSTARLET val -w ${file} > /dev/null 2>&1 | ||
validxml=$? | ||
if [ 0 == $validxml ] ; then | ||
#test for for possible result error message | ||
$XMLSTARLET el ${file} | grep -e '^result' -q | ||
if [ 0 == $? ] ; then | ||
#test for error message | ||
#If <result error="true"> then an error occured. | ||
waserror=$($XMLSTARLET sel -T -t -v "/result/@error" ${file}) | ||
errmsg=$($XMLSTARLET sel -T -t -v "/result/error/message" ${file}) | ||
if [ "" != "$waserror" -a "true" == $waserror ] ; then | ||
errorMsg "FAIL: expected resource.xml content but received error result: $errmsg" | ||
exit 2 | ||
fi | ||
fi | ||
fi | ||
|
||
#test curl.out for valid xml | ||
if [ 0 != $validxml ] ; then | ||
errorMsg "ERROR: Response was not valid xml" | ||
exit 2 | ||
fi | ||
|
||
#test for expected /joblist element | ||
$XMLSTARLET el ${file} | grep -e '^project' -q | ||
if [ 0 != $? ] ; then | ||
errorMsg "ERROR: Response did not contain expected result" | ||
exit 2 | ||
fi | ||
|
||
#Check results list | ||
itemcount=$($XMLSTARLET sel -T -t -v "count(/project/node)" ${file}) | ||
echo "$itemcount Nodes" | ||
if [ "0" == "$itemcount" ] ; then | ||
errorMsg "FAIL: expected multiple /project/node element" | ||
exit 2 | ||
fi | ||
|
||
echo "OK" | ||
|
||
|
||
TETC=$RDECK_BASE/projects/test/etc | ||
TRES=$TETC/resources.xml | ||
|
||
if [ ! -f $TRES.testbackup ] ; then | ||
cp $TRES $TRES.testbackup | ||
fi | ||
|
||
|
||
|
||
cat <<END > $TETC/testUpdateResources.xml | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE project PUBLIC "-//DTO Labs Inc.//DTD Resources Document 1.0//EN" "project.dtd"> | ||
<project> | ||
<node name="test1" type="Node" description="Rundeck test node" tags="test1,testboth" hostname="testhost1" osArch="x86_64" osFamily="unix" osName="Mac OS X" osVersion="10.6.6" username="rdeck" editUrl="" remoteUrl=""/> | ||
<node name="test2" type="Node" description="Rundeck test node" tags="test2,testboth" hostname="testhost2" osArch="x86_64" osFamily="unix" osName="Mac OS X" osVersion="10.6.6" username="rdeck1" editUrl="" remoteUrl=""/> | ||
</project> | ||
END | ||
|
||
echo "TEST: /api/project/${proj}/resources (POST) (xml)" | ||
|
||
|
||
# post data | ||
$CURL -X POST -H 'Content-Type: text/xml' --data-binary "@$TETC/testUpdateResources.xml" ${runurl}?${params} > ${file} || fail "ERROR: failed request" | ||
|
||
sh $DIR/api-test-success.sh ${file} "Resources were successfully updated for project test" || exit 2 | ||
|
||
echo "OK" | ||
|
||
#exit 0 | ||
|
||
cat <<END > $TETC/testUpdateResources.yaml | ||
test1: | ||
tags: test1, testboth | ||
osFamily: unix | ||
osVersion: 10.6.6 | ||
osArch: x86_64 | ||
editUrl: '' | ||
hostname: testhost1 | ||
type: Node | ||
username: rdeck | ||
description: Rundeck test node | ||
remoteUrl: '' | ||
nodename: test1 | ||
osName: Mac OS X | ||
test2: | ||
tags: test2, testboth | ||
osFamily: unix | ||
osVersion: 10.6.6 | ||
osArch: x86_64 | ||
editUrl: '' | ||
hostname: testhost2 | ||
type: Node | ||
username: rdeck1 | ||
description: Rundeck test node | ||
remoteUrl: '' | ||
nodename: test2 | ||
osName: Mac OS X | ||
END | ||
|
||
echo "TEST: /api/project/${proj}/resources (POST) (yaml)" | ||
|
||
# post data | ||
$CURL -X POST -H 'Content-Type: text/yaml' --data-binary "@$TETC/testUpdateResources.yaml" ${runurl}?${params} > ${file} || fail "ERROR: failed request" | ||
|
||
sh $DIR/api-test-success.sh ${file} "Resources were successfully updated for project test" || exit 2 | ||
|
||
echo "OK" | ||
|
||
if [ -f $TRES.testbackup ] ; then | ||
mv $TRES.testbackup $TRES | ||
fi | ||
|
||
rm $TETC/testUpdateResources.yaml | ||
rm $TETC/testUpdateResources.xml | ||
rm $DIR/curl.out | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters