[buildout]

eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
offline = true

parts =
  request-kvm
  deploy-unit-test
  httpd
  httpd-promise

[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.get('image-to-test-url') }}
config-virtual-hard-drive-md5sum = {{ slapparameter_dict.get('image-to-test-md5sum') }}

# The test script
config-bootstrap-script-url = {{ in_vm_test_script }}#{{ in_vm_test_script_md5 }}

# Script configuration
config-data-to-vm =
  SCRIPTURL=TODO
  POSTURL=http://[${httpd:host}]:${httpd:port}/test-result/
  WAITTIME=3600
  TRIES=10

# require HTTP server
config-enable-http-server = true

[httpd]
recipe = slapos.cookbook:simplehttpserver
host = ${slap-network-information:global-ipv6}
port = 8080
base-path = ${directory:httpd}
wrapper = ${directory:services}/http-server
log-file = ${directory:log}/httpd.log
use-hash-url = false

[httpd-promise]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promises}/httpd
hostname = ${httpd:host}
port = ${httpd:port}

[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/
httpd = ${:srv}/httpd/
promises = ${:etc}/promise

[deploy-unit-test]
recipe = collective.recipe.template
input = inline:
  #!/bin/sh
  exit 0
output = ${directory:bin}/runTestSuite
mode = 755

