Commit 6d53d0fe authored by Stavros Sachtouris's avatar Stavros Sachtouris

Cover contextualization with curl functional tests

parent ef9c1b4f
......@@ -37,6 +37,12 @@ What is in the container
You will find all the tools from egifedcloud/fedcloud-userinterface:latest plus
two shell script to test the snf-occi application.
To run the tests in debug mode (verbose) set the environment variable
export SNF_OCCI_DEBUG=true
Unset the variable for a less verbose execution
To run the "run_functional_tests.sh" script, you must set some variables,
either when you RUN the container or while you are inside the container.
......
......@@ -31,7 +31,14 @@ echo "RESOURCE_TPL = ${RESOURCE_TPL}";
echo "Vars OK, run tests"
echo
BASE_CMD="curl -v -H 'X-Auth-Token: ${TOKEN}'"
if [ -z "$SNF_OCCI_DEBUG" ]; then
XARGS="-s";
else
XARGS="-v";
fi
BASE_CMD="curl ${XARGS} -H'X-Auth-Token: ${TOKEN}'"
VM_INFO="/tmp/vm.info"
echo "List everything"
echo "Meaning: kamaki image list || kamaki flavor list || kamaki volume list" \
......@@ -42,6 +49,7 @@ eval $CMD
echo
echo
echo "Create a server"
echo "Meaning: kamaki server create --name \"My Test VM\" \\"
echo " --flavor-id ${RESOURCE_TPL} --image-id ${OS_TPL}"
......@@ -50,7 +58,7 @@ CMD="${BASE_CMD} -X'POST' $OCCI_ENDPOINT/compute \
-H'Content-Type: text/occi' \
-H'Category: ${RESOURCE_TPL}; scheme=\"http://schemas.openstack.org/template/resource#\"; class=\"mixin\"' \
-H'Category: ${OS_TPL}; scheme=\"http://schemas.openstack.org/template/os#\"; class=\"mixin\"' \
-H'X-OCCI-Attribute: occi.core.title=\"My test VM\"'"
-H'X-OCCI-Attribute: occi.core.title=\"OCCI test VM\"'"
echo $CMD
VM_URL=$(eval $CMD)
VM_URL=(`echo $VM_URL|awk '{print $2;}'`)
......@@ -67,25 +75,23 @@ echo
echo "Details on server"
echo "Meaning: kamaki server info ${VM_URL}"
CMD="${BASE_CMD} ${VM_URL} > vm.info"
CMD="${BASE_CMD} ${VM_URL} > ${VM_INFO}"
echo $CMD
eval $CMD
echo
echo
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' vm.info`)
WAIT=1;
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
WAIT=1
while [ $STATE != 'active' ]
do
echo "Server state is ${STATE}"
echo "wait ${WAIT}\" and check again"
sleep $WAIT;
let "WAIT++";
echo "$CMD";
eval $CMD;
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' vm.info`)
done;
cat vm.info;
echo "Server state is ${STATE}, wait ${WAIT}\" and check again"
sleep $WAIT
let "WAIT++"
eval $CMD
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
done
cat $VM_INFO
echo
echo
......@@ -99,19 +105,16 @@ eval $ACT
echo "Check server state"
echo $CMD
eval $CMD
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' vm.info`)
WAIT=1;
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
WAIT=1
while [ $STATE != 'inactive' ]
do
echo "Server state is ${STATE}"
echo "wait ${WAIT}\" and check again"
sleep $WAIT;
let "WAIT++";
echo "$CMD";
eval $CMD;
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' vm.info`)
done;
cat vm.info;
echo "Server state is ${STATE}, wait ${WAIT}\" and check again"
sleep $WAIT
let "WAIT++"
eval $CMD
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
done
echo
echo
......@@ -125,19 +128,17 @@ eval $ACT
echo "Check server state"
echo $CMD
eval $CMD
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' vm.info`)
WAIT=1;
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
WAIT=1
while [ $STATE != 'active' ]
do
echo "Server state is ${STATE}"
echo "wait ${WAIT}\" and check again"
sleep $WAIT;
let "WAIT++";
echo "$CMD";
eval $CMD;
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' vm.info`)
done;
cat vm.info;
sleep $WAIT
let "WAIT++"
eval $CMD
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
done
echo
echo
......@@ -152,32 +153,26 @@ eval $ACT
echo "Check server state"
echo $CMD
eval $CMD
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' vm.info`)
WAIT=1;
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
WAIT=1
while [ $STATE != 'inactive' ]
do
echo "Server state is ${STATE}"
echo "wait ${WAIT}\" and check again"
sleep $WAIT;
let "WAIT++";
echo "$CMD";
eval $CMD;
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' vm.info`)
echo "Server state is ${STATE}, wait ${WAIT}\" and check again"
sleep $WAIT
let "WAIT++"
eval $CMD
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
done
cat vm.info
echo
WAIT=1;
WAIT=1
while [ $STATE != 'active' ]
do
echo "Server state is ${STATE}"
echo "wait ${WAIT}\" and check again"
sleep $WAIT;
let "WAIT++";
echo "$CMD";
eval $CMD;
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' vm.info`)
done;
cat vm.info;
echo "Server state is ${STATE}, wait ${WAIT}\" and check again"
sleep $WAIT
let "WAIT++"
eval $CMD
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
done
echo
echo
......@@ -189,3 +184,92 @@ echo $CMD
eval $CMD
echo
echo
echo "Test create with context (PPK auth)"
echo "Meaning: kamaki server create --name \"My Test VM\" \\"
echo " --flavor-id ${RESOURCE_TPL} --image-id ${OS_TPL}"
echo " -p (`pwd`)/id_rsa.pub,/root/.ssh/authorized_keys,root,root,0600"
echo "Create a PPK pair:"
PPK_DIR="/tmp"
TIMESTAMP=`date +"%Y%m%d%H%M%s"`
PPK="ppk${TIMESTAMP}"
PPK_GEN_CMD="ssh-keygen -f ${PPK_DIR}/${PPK} -t rsa -N ''"
echo $PPK_GEN_CMD
eval $PPK_GEN_CMD
PUBLIC_KEY=`cat ${PPK_DIR}/${PPK}.pub`
echo "Public Key:"
echo $PUBLIC_KEY
echo
echo
CMD="${BASE_CMD} -X'POST' $OCCI_ENDPOINT/compute \
-H'Category: compute; scheme=\"http://schemas.ogf.org/occi/infrastructure#\"; class=\"kind\"' \
-H'Content-Type: text/occi' \
-H'Category: ${RESOURCE_TPL}; scheme=\"http://schemas.openstack.org/template/resource#\"; class=\"mixin\"' \
-H'Category: ${OS_TPL}; scheme=\"http://schemas.openstack.org/template/os#\"; class=\"mixin\"' \
-H'X-OCCI-Attribute: occi.core.title=\"OCCI test VM\"' \
-H 'Category: public_key; scheme=\"http://schemas.openstack.org/instance/credentials#\";class=\"mixin\"' \
-H'X-OCCI-Attribute: org.openstack.credentials.publickey.name=\"${PPK}\"' \
-H'X-OCCI-Attribute: org.openstack.credentials.publickey.data=\"${PUBLIC_KEY}\"'"
echo $CMD
VM_URL=$(eval $CMD)
VM_URL=(`echo $VM_URL|awk '{print $2;}'`)
echo
echo
echo "Wait for server to get up"
CMD="${BASE_CMD} ${VM_URL} > ${VM_INFO}"
echo $CMD
eval $CMD
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
WAIT=1
while [ $STATE != 'active' ]
do
echo "Server state is ${STATE}, wait ${WAIT}\" and check again"
sleep $WAIT
let "WAIT++"
eval $CMD
STATE=(`awk '/occi.compute.state/{n=split($0,a,"\""); print a[2];}' ${VM_INFO}`)
done
echo
printf "Wait 12 seconds for the network |"
for i in `seq 1 3`; do
sleep 1
printf "\b/"
sleep 1
printf "\b-"
sleep 1
printf "\b\\"
sleep 1
printf "\b|"
done
echo "\b\b. Fingers crossed..."
echo
echo "Check PPK authentication"
VM_ID=(`echo ${VM_URL}|awk '/\//{n=split($0,a,"/"); print a[n]; }'`)
CMD="scp -o \"StrictHostKeyChecking no\" -i ${PPK_DIR}/${PPK} root@snf-${VM_ID}.vm.okeanos.grnet.gr:/root/.ssh/authorized_keys ${PPK_DIR}/${PPK}.downloaded"
echo $CMD
eval $CMD
if [ -f ${PPK_DIR}/${PPK}.downloaded ]; then
echo "PPK authentication is OK"
else
echo "PPK authentication FAILED"
fi
echo
echo
echo "Clean up"
CMD="${BASE_CMD} -X DELETE ${VM_URL}"
echo $CMD
eval $CMD
CMD="rm -f ${PPK_DIR}/${PPK}* ${VM_INFO}"
echo $CMD
eval $CMD
echo
echo
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment