Commit 0bb92be2 authored by Łukasz Nowak's avatar Łukasz Nowak

XXX: erp5testnode: Initialize playbook-test

parent 2db64cda
# THIS IS NOT A BUILDOUT FILE, despite purposedly using a compatible syntax.
# The only allowed lines here are (regexes):
# - "^#" comments, copied verbatim
# - "^[" section beginings, copied verbatim
# - lines containing an "=" sign which must fit in the following categorie.
# - "^\s*filename\s*=\s*path\s*$" where "path" is relative to this file
# Copied verbatim.
# - "^\s*hashtype\s*=.*" where "hashtype" is one of the values supported
# by the re-generation script.
# Re-generated.
# - other lines are copied verbatim
# Substitution (${...:...}), extension ([buildout] extends = ...) and
# section inheritance (< = ...) are NOT supported (but you should really
# not need these here).
[template-playbook-test]
filename = instance.cfg.in
md5sum = 5f5446caf631b68172a5e973b4fc28ff
[dynamic-template-playbook-test]
filename = instance-playbook-test.cfg.jinja2
md5sum = 8e428a77026f405c712909a7f8d58dba
[vm-test-script]
filename = vm-test-script
md5sum = eb8b8a27034fde8e5ff5cf8c0c7d16f5
[buildout]
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
offline = true
parts =
request-kvm
[request-kvm]
<= slap-connection
recipe = slapos.cookbook:request
software-url = ${slap-connection:software-release-url}
software-type = kvm
name = test-kvm
sla-computer_guid = ${slap-connection:computer-id}
# Tested image
# Passed by request
config-virtual-hard-drive-url = {{ slapparameter_dict['image-to-test-url'] }}
config-virtual-hard-drive-md5sum = {{ slapparameter_dict['image-to-test-md5sum'] }}
config-virtual-hard-drive-gzipped = {{ slapparameter_dict.get('image-to-test-gzipped', 'False') }}
# The test script
config-bootstrap-script-url = file://{{ in_vm_test_script }}#{{ in_vm_test_script_md5 }}
# Script configuration
config-data-to-vm =
SLAPOS_TEST_COMPUTER_TOKEN=GENERATE_ME
# require HTTP server
config-enable-http-server = true
# VM options
config-ram-size = 4096
config-cpu-count = 2
# await for system to be ready
return =
url
backend-url
ipv6
nat-rule-port-tcp-443
nat-rule-port-tcp-80
[directory]
recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory}
etc = ${:home}/etc/
var = ${:home}/var/
srv = ${:home}/srv/
bin = ${:home}/bin/
tmp = ${:home}/tmp/
log = ${:var}/log/
services = ${:etc}/service/
scripts = ${:etc}/run/
[buildout]
extends = ${template:output}
parts +=
runTestSuite
copy-test-data
[copy-test-data]
# Note: This is a hack, as such while requesting KVM it is not possible
# to fill correctly http directory
# Note: This will only work inside of non-user related environment
# dest shell variable will evaluate to requested partition's
# srv/public directory
# The "if" statement makes this script be run only in partition
# *without* srv/public - so according to current knowledge, the
# one which requests KVM backend for testing
recipe = plone.recipe.command
stop-on-error = true
update-command = $${:command}
command =
if [ ! -d srv/public ] ; then
dest=`echo ../*/srv/public`
cp ${playbook:output} $dest/playbook.tar.gz
fi
[runTestSuite]
recipe = slapos.recipe.template:jinja2
rendered = $${buildout:directory}/bin/$${:_buildout_section_name_}
template = inline:
#!/bin/sh
export PATH=${python2.7-with-eggs:location}:$PATH
exec ${buildout:bin-directory}/${runTestSuite_py:interpreter} ${runTestSuite.py:target} --partition_ipv4 {{ list(partition_ipv4)[0] }} --partition_path $${buildout:directory} --test_reference "{{ slapparameter_dict.get('image-to-test-url') }} {{ slapparameter_dict.get('test-relative-directory')}}" --test_location "${test-location:base}/{{ slapparameter_dict.get('test-relative-directory') }}" --python_interpreter=${buildout:bin-directory}/${runTestSuite_py:interpreter} "$@"
mode = 0755
context =
key slapparameter_dict slap-configuration:configuration
key partition_ipv4 slap-configuration:ipv4
[switch_softwaretype]
default = $${:playbook-test}
playbook-test = dynamic-template-playbook-test:rendered
[dynamic-template-playbook-test]
recipe = slapos.recipe.template:jinja2
template = ${dynamic-template-playbook-test:target}
rendered = $${buildout:directory}/template-playbook-test.cfg
context =
key develop_eggs_directory buildout:develop-eggs-directory
key eggs_directory buildout:eggs-directory
key slapparameter_dict slap-configuration:configuration
raw bin_directory ${buildout:bin-directory}
raw in_vm_test_script ${vm-test-script:target}
raw in_vm_test_script_md5 ${vm-test-script:md5sum}
raw waittime ${vm-test-script:waittime}
mode = 0644
[buildout]
extends =
../deploy-test/software.cfg
buildout.hash.cfg
parts =
template-playbook-test
[vm-test-script]
<= deploy-script-controller-script
url = ${:_profile_base_location_}/${:filename}
[dynamic-template-playbook-test]
<= dynamic-template-deploy-test
url = ${:_profile_base_location_}/${:filename}
[template-playbook-test]
<= template-deploy-test
url = ${:_profile_base_location_}/${:filename}
#!/bin/bash
# Script for executing ansible playbook test in the VM
# run it only once, means: no retries
echo 0 > /root/bootstrap/bootstrap-max-retry
# hack around to have only one run, as there seem
# to be bug in bootstrap script
echo 255 > /root/bootstrap/retry-amount
# setup
LOG_FILE=/var/log/test-script-deployment.log
WORKDIR=$(mktemp -d)
CONFIG=${WORKDIR}/test-script.cfg
# fetching configuration
wget -O $CONFIG -q http://10.0.2.100/data
source $CONFIG
if [ -z "$LOG_FILE" ] ; then
echo "Output log file is missing"
exit 1
fi
if [ -z "$SLAPOS_TEST_COMPUTER_TOKEN" ] ; then
echo "SLAPOS_TEST_COMPUTER_TOKEN is missing" >> $LOG_FILE 2>&1
exit 1
fi
# PREPARATION
# Install required python package
apt-get -y install python-setuptools >> $LOG_FILE 2>&1
# fetch the playbook
PLAYBOOK=${WORKDIR}/playbook.tar.gz
PLAYBOOK_URL=http://10.0.2.100/playbook.tar.gz
wget -O ${PLAYBOOK} -q $PLAYBOOK_URL|| (echo "Failed to fetch playbook from ${PLAYBOOK_URL}" ; exit 1)
mkdir -p ${WORKDIR}/unpacked
tar -C ${WORKDIR}/unpacked -xzf ${PLAYBOOK}
cd $WORKDIR
SLAPOS_TEST_COMPUTER_TOKEN=$SLAPOS_TEST_COMPUTER_TOKEN python ${WORKDIR}/unpacked/setup.py test >> $LOG_FILE 2>&1
function upload ()
{
LOG_FILE=$1
t=`date '+%Y%m%d%H%S'`
mv $LOG_FILE ${LOG_FILE}.$t
# just to be sure flush all disk operations before uploading
flush
curl -q -X POST --data-urlencode "path=test-script-result/log-file.log.$t" --data-urlencode "content@${LOG_FILE}.$t" http://10.0.2.100/
}
upload $LOG_FILE
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