Commit 1de78308 authored by Stavros Sachtouris's avatar Stavros Sachtouris

Cover contextualization w. rOCCI functional tests

parent 6d53d0fe
......@@ -16,11 +16,11 @@
# Dockerfile for snf-occi-manual-ci
# contains functional testing scripts
#
# VERSION 0.3.1
# VERSION 0.3.2
FROM egifedcloud/fedcloud-userinterface:latest
MAINTAINER Stavros Sachtouris <saxtouri@grnet.gr>
RUN apt update && apt install ca-policy-egi-core curl -y
RUN apt update && apt install ca-policy-egi-core curl openssh-client -y
COPY run_functional_tests.sh /data/
COPY run_curl_tests.sh /data/
......
......@@ -66,11 +66,13 @@ For instance, if you have a proxy, you may want to run something like:
::
$ docker run -v my_proxy:/data/my_proxy \
$ docker run --name occi_client -v my_proxy:/tmp/x509up_u0 \
-e OCCI_ENDPOINT="https://okeanos-occi2.hellasgrid.gr:9000" \
-e TOKEN="My-Okeanos-Token"
-e USER_PROXY="/data/my_proxy" \
-e TOKEN="My-Okeanos-Token" \
-e USER_PROXY="/tmp/x509up_u0" \
-e OS_TPL="6f1f7205-cf4c-4b8c-ae77-7c419747bcbd"\
-e RESOURCE_TPL="13"\
-ti snf-occi-client:latest
TIP: To test on the same host, run the command with the "--net host" argument
......@@ -100,7 +100,7 @@ echo "Meaning: kamaki server shutdown"
ACTION="stop"
ACT="${BASE_CMD} -X POST ${VM_URL}?action=${ACTION} -H 'Category: ${ACTION} ;\
scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\"; class=\"action\"'"
echo "$CMD"
echo "$ACT"
eval $ACT
echo "Check server state"
echo $CMD
......@@ -123,7 +123,7 @@ echo "Meaning: kamaki server start"
ACTION="start"
ACT="${BASE_CMD} -X POST ${VM_URL}?action=${ACTION} -H 'Category: ${ACTION} ;\
scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\"; class=\"action\"'"
echo "$CMD"
echo "$ACT"
eval $ACT
echo "Check server state"
echo $CMD
......@@ -148,7 +148,7 @@ echo "Meaning: kamaki server restart"
ACTION="restart"
ACT="${BASE_CMD} -X POST ${VM_URL}?action=${ACTION} -H 'Category: ${ACTION} ;\
scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\"; class=\"action\"'"
echo "$CMD"
echo "$ACT"
eval $ACT
echo "Check server state"
echo $CMD
......@@ -237,8 +237,8 @@ do
done
echo
printf "Wait 12 seconds for the network |"
for i in `seq 1 3`; do
printf "Wait 16 seconds for the network |"
for i in `seq 1 4`; do
sleep 1
printf "\b/"
sleep 1
......
......@@ -28,12 +28,19 @@ echo "OS_TPL = ${OS_TPL}"
if [ -z "$RESOURCE_TPL" ]; then echo "E: RESOURCE_TPL not set"; exit 1; fi;
echo "RESOURCE_TPL = ${RESOURCE_TPL}";
if [ -z "$SNF_OCCI_DEBUG" ]; then
XARGS="";
else
XARGS="-d";
fi
echo "Vars OK, run tests"
echo
BASE_CMD="occi --endpoint ${OCCI_ENDPOINT} -n x509 -X --user-cred ${USER_PROXY}"
BASE_CMD="occi ${XARGS} --endpoint ${OCCI_ENDPOINT} -n x509 -X --user-cred ${USER_PROXY}"
VM_INFO="/tmp/vm.info"
echo "List OS templates"
echo "Meaning: kamaki image list"
......@@ -64,10 +71,10 @@ eval $CMD
echo
echo "Create a server instance"
echo "Meaning: kamaki server create --name \"My Test VM\" \\"
echo "Meaning: kamaki server create --name \"OCCI test VM\" \\"
echo " --flavor-id <ID of c2r2048d40drb> --image-id <ID of ${OS_TPL}>"
CMD="${BASE_CMD} --action create --resource compute "
CMD="${CMD} --attribute occi.core.title=\"My Test VM\""
CMD="${CMD} --attribute occi.core.title=\"OCCI test VM\""
CMD="${CMD} --mixin os_tpl#${OS_TPL} --mixin resource_tpl#${RESOURCE_TPL}"
echo "$CMD"
VM_URL=$(eval $CMD)
......@@ -88,23 +95,21 @@ else
echo "Details on server instance ${SUFFIX}";
echo "Meaning: kamaki server info ${SERVER_URL}";
CMD="${BASE_CMD} --action describe --resource ${SUFFIX} > vm.info";
CMD="${BASE_CMD} --action describe --resource ${SUFFIX} > ${VM_INFO}";
echo "$CMD";
eval $CMD;
STATE=(`awk '/occi.compute.state/{n=split($0,a," = "); print a[2];}' vm.info`)
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"
echo "Server state is ${STATE}, 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`);
STATE=(`awk '/occi.compute.state/{n=split($0,a," = "); print a[2];}' ${VM_INFO}`);
done;
cat vm.info;
cat $VM_INFO;
echo "STOP server"
echo "Meaning: kamaki server shutdown ${SERVER_URL}"
......@@ -115,13 +120,11 @@ else
WAIT=1;
while [ $STATE != 'inactive' ]
do
echo "Server state is ${STATE}"
echo "wait ${WAIT}\" and check again"
echo "Server state is ${STATE}, 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`);
STATE=(`awk '/occi.compute.state/{n=split($0,a," = "); print a[2];}' ${VM_INFO}`);
done;
echo "Server state is $STATE"
echo
......@@ -135,13 +138,11 @@ else
WAIT=1;
while [ $STATE != 'active' ]
do
echo "Server state is ${STATE}"
echo "wait ${WAIT}\" and check again"
echo "Server state is ${STATE}, 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`);
STATE=(`awk '/occi.compute.state/{n=split($0,a," = "); print a[2];}' ${VM_INFO}`);
done;
echo "Server state is $STATE"
echo
......@@ -161,3 +162,87 @@ else
eval $CMD;
fi;
echo
echo "Check contextualization"
echo
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
echo "Create a server instance with PPK"
echo "Meaning: kamaki server create --name \"OCCI test VM\" \\"
echo " --flavor-id ${RESOURCE_TPL} --image-id ${OS_TPL} \\"
echo " -p (`pwd`)/id_rsa.pub,/root/.ssh/authorized_keys,root,root,0600"
CMD="${BASE_CMD} --action create --resource compute"
CMD="${CMD} --attribute occi.core.title=\"OCCI test VM\""
CMD="${CMD} --mixin os_tpl#${OS_TPL} --mixin resource_tpl#${RESOURCE_TPL}"
CMD="${CMD} --context public_key='${PUBLIC_KEY}'"
echo "$CMD"
VM_URL=$(eval $CMD)
echo "VM URL: ${VM_URL}"
SUFFIX=(`echo ${VM_URL}|awk '{n=split($0,a,"/"); print "/"a[n-1]"/"a[n]}'`)
echo
echo "Wait for server to get up"
CMD="${BASE_CMD} --action describe --resource ${SUFFIX} > ${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 16 seconds for the network |"
for i in `seq 1 4`; 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 ${SUFFIX}|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} --action delete --resource ${SUFFIX}";
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