Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add simple test script for fresh install verification
  • Loading branch information
gschueler committed Oct 15, 2010
1 parent 8c5451d commit 1f14549
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 0 deletions.
86 changes: 86 additions & 0 deletions test/test.jobs.xml
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>

<joblist>
<job>
<id>1</id>
<name>simple exec test</name>
<description>Exec the uptime command</description>
<additional/>
<loglevel>INFO</loglevel>
<group>test</group>
<context>
<project>test</project>
</context>
<sequence threadcount="1" keepgoing="false" strategy="node-first">
<command>
<exec>uptime</exec>
</command>
</sequence>
<dispatch>
<threadcount>1</threadcount>
<keepgoing>false</keepgoing>
</dispatch>
</job>
<job>
<id>3</id>
<name>simple file test</name>
<description>Run script file from path to exec uptime command</description>
<additional/>
<loglevel>INFO</loglevel>
<group>test</group>
<context>
<project>test</project>
</context>
<sequence threadcount="1" keepgoing="false" strategy="node-first">
<command>
<scriptfile>@DIRNAME@/uptime.sh</scriptfile>
</command>
</sequence>
<dispatch>
<threadcount>1</threadcount>
<keepgoing>false</keepgoing>
</dispatch>
</job>
<job>
<id>4</id>
<name>simple job test</name>
<description>run the simple exec test job</description>
<additional/>
<loglevel>INFO</loglevel>
<group>test</group>
<context>
<project>test</project>
</context>
<sequence threadcount="1" keepgoing="false" strategy="node-first">
<command>
<jobref name="simple exec test" group="test"/>
</command>
</sequence>
<dispatch>
<threadcount>1</threadcount>
<keepgoing>false</keepgoing>
</dispatch>
</job>
<job>
<id>2</id>
<name>simple script test</name>
<description>Bash script uptime</description>
<additional/>
<loglevel>INFO</loglevel>
<group>test</group>
<context>
<project>test</project>
</context>
<sequence threadcount="1" keepgoing="false" strategy="node-first">
<command>
<script><![CDATA[#!/bin/bash
uptime]]></script>
</command>
</sequence>
<dispatch>
<threadcount>1</threadcount>
<keepgoing>false</keepgoing>
</dispatch>
</job>
</joblist>
79 changes: 79 additions & 0 deletions test/test.sh
@@ -0,0 +1,79 @@
#!/bin/bash

DIR=$(cd `dirname $0` && pwd)

#assert RDECK_BASE
if [ -z "$RDECK_BASE" ] ; then
echo "RDECK_BASE not set"
exit 2
fi

cd $RDECK_BASE
if [ 0 != $? ] ; then
echo Failed to cd to $RDECK_BASE : $!
exit 2
fi

#create test project
$RDECK_BASE/tools/bin/run-project -p test -a create
if [ 0 != $? ] ; then
echo Failed to create test project : $!
exit 2
fi

#copy jobs file to replace template
cp $DIR/test.jobs.xml $DIR/test.jobs.expanded.xml

sed -i '' "s/@DIRNAME@/$DIR/" $DIR/test.jobs.expanded.xml

#load jobs
$RDECK_BASE/tools/bin/run-jobs load -f $DIR/test.jobs.xml > $DIR/load.out
if [ 0 != $? ] ; then
echo Failed to load jobs: $!
exit 2
fi
cat $DIR/load.out

grep Failed $DIR/load.out
if [ 0 != $? ] ; then
echo Failed to load some job : $!
exit 2
fi

rm $DIR/load.out
rm $DIR/test.jobs.expanded.xml

# try to run job id 1

$RDECK_BASE/tools/bin/run-run -i 1
if [ 0 != $? ] ; then
echo Failed to run job id 1: $!
exit 2
fi

# try run-exec

$RDECK_BASE/tools/bin/run -- uptime
if [ 0 != $? ] ; then
echo Failed to run uptime via cli : $!
exit 2
fi

$RDECK_BASE/tools/bin/run -Q -- uptime > $DIR/exec.out
if [ 0 != $? ] ; then
echo Failed: run -Q -- uptime : $!
exit 2
fi
grep 'Succeeded queueing' -q $DIR/exec.out
if [ 0 != $? ] ; then
echo Failed to queue execution: $!
exit 2
fi

rm $DIR/exec.out

sh $DIR/testweb.sh
if [ 0 != $? ] ; then
echo Failed to run testweb.sh : $!
exit 2
fi
78 changes: 78 additions & 0 deletions test/testweb.sh
@@ -0,0 +1,78 @@
#!/bin/bash

errorMsg() {
echo "$*" 1>&2
}

DIR=$(cd `dirname $0` && pwd)

#source rcfile
cd $RDECK_BASE
if [ 0 != $? ] ; then
errMsg "failed to cd to RDECK_BASE: $RDECK_BASE: $!"
exit 2
fi

# test log in

url='http://localhost:8080'
loginurl="${url}/j_security_check"

# get main page for login
echo "WEB Starting tests."
echo "WEB Trying login..."
curl -s -S -L -c $DIR/cookies ${url}/menu/index > $DIR/curl.out
if [ 0 != $? ] ; then
errMsg "failed menu request to ${url}/menu/index"
exit 2
fi

grep 'j_security_check' -q $DIR/curl.out
if [ 0 != $? ] ; then
errMsg "login page not found"
exit 2
fi


curl -s -S -L -c $DIR/cookies -b $DIR/cookies -d j_username=default -d j_password=default $loginurl > $DIR/curl.out
if [ 0 != $? ] ; then
errMsg "failed login request to ${loginurl}"
exit 2
fi


grep 'id="indexMain"' -q $DIR/curl.out
if [ 0 != $? ] ; then
errMsg "login didnt seem to return the right page"
exit 2
fi
grep 'j_security_check' -q $DIR/curl.out
if [ 0 == $? ] ; then
errMsg "login was not successful"
exit 2
fi

echo "WEB Login OK"
echo "WEB Testing Nodes..."
# get nodes page
curl -s -S -L -c $DIR/cookies -b $DIR/cookies ${url}/resources/nodes > $DIR/curl.out
if [ 0 != $? ] ; then
errMsg "failed nodes request"
exit 2
fi

grep 'Nodes (1)' -q $DIR/curl.out
if [ 0 != $? ] ; then
errMsg "nodes output didnt have right nodes count"
exit 2
fi
grep 'j_security_check' -q $DIR/curl.out
if [ 0 == $? ] ; then
errMsg "login was not successful "
exit 2
fi

rm $DIR/curl.out
rm $DIR/cookies

echo "WEB Nodes Page OK"
3 changes: 3 additions & 0 deletions test/uptime.sh
@@ -0,0 +1,3 @@
#!/bin/bash

uptime

0 comments on commit 1f14549

Please sign in to comment.