slave-test: add promise to self-test.

parent f1f49642
...@@ -2,10 +2,19 @@ ...@@ -2,10 +2,19 @@
parts = parts =
publish-connection-informations publish-connection-informations
request-slave-instance request-slave-instance
check-connection-informations-promise
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true offline = true
[directories]
recipe = slapos.cookbook:mkdirectory
bin = $${buildout:directory}/bin
etc = $${buildout:directory}/etc
scripts = $${:etc}/run
services = $${:etc}/service
promises = $${:etc}/promise
[slap-configuration] [slap-configuration]
recipe = slapos.cookbook:slapconfiguration.serialised recipe = slapos.cookbook:slapconfiguration.serialised
computer = $${slap-connection:computer-id} computer = $${slap-connection:computer-id}
...@@ -43,3 +52,16 @@ test-instance-state = $${request-test-instance:instance-state} ...@@ -43,3 +52,16 @@ test-instance-state = $${request-test-instance:instance-state}
test-instance-slave-instance-list = $${request-test-instance:connection-slave-instance-list} test-instance-slave-instance-list = $${request-test-instance:connection-slave-instance-list}
root-instance-slave-instance-list = $${slap-configuration:slave-instance-list} root-instance-slave-instance-list = $${slap-configuration:slave-instance-list}
slave-instance-parameter = $${request-slave-instance:connection-foo} slave-instance-parameter = $${request-slave-instance:connection-foo}
# Create a file containing connection parameters
# Then create a promise that will check content of this file
[dump-connection-informations]
<= publish-connection-informations
recipe = slapos.cookbook:jsondump
json-output = $${buildout:directory}/connection-parameters.json
[check-connection-informations-promise]
recipe = collective.recipe.template
input = ${promise-template:output}
output = $${directories:promises}/checkparameters
mode = 700
#!${buildout:executable}
import sys
import os
import json
json_file = '$${dump-connection-informations:json-output}'
connection_parameter_list = json.loads(open(json_file, 'r').read())
# XXX list all problems before exit
# XXX: factor in a clean dict loop
test_instance_guid = connection_parameter_list['test-instance-guid']
if not test_instance_guid == 'slappart1':
print 'Bad test-instance-guid connection parameter: %s' % test_instance_guid
sys.exit(1)
test_instance_state = connection_parameter_list['test-instance-state']
if not test_instance_state == 'started':
print 'Bad test-instance-state connection parameter: %s instead of started' % test_instance_state
sys.exit(1)
test_instance_slave_instance_list = connection_parameter_list['test-instance-slave-instance-list']
if test_instance_slave_instance_list == []:
print 'test-instance-slave-instance-list connection parameter is empty.'
sys.exit(1)
root_instance_slave_instance_list = connection_parameter_list['root-instance-slave-instance-list']
if root_instance_slave_instance_list != []:
print 'root-instance-slave-instance-list connection parameter is not empty.'
sys.exit(1)
slave_instance_parameter = connection_parameter_list['slave-instance-parameter']
if slave_instance_parameter != 'I am slave instance, and I am deployed!':
print 'parameter slave-instance-parameter is not correct.'
sys.exit(1)
# This Software Release is used to test # This Software Release is used to test
# the behavior of Slave Instances in slapos and in slaprunner. # the behavior of Slave Instances in slapos and in slaprunner.
[buildout] [buildout]
develop =
/srv/slapgrid/slappart74/srv//runner/project/slapos
parts = parts =
slapos-cookbook slapos-cookbook
instance-profile instance-profile
collective-egg
[instance-profile] [instance-profile]
recipe = slapos.recipe.template recipe = slapos.recipe.template
...@@ -23,6 +28,16 @@ url = ${:_profile_base_location_}/instance-test.cfg ...@@ -23,6 +28,16 @@ url = ${:_profile_base_location_}/instance-test.cfg
output = ${buildout:directory}/instance-test.cfg output = ${buildout:directory}/instance-test.cfg
mode = 0644 mode = 0644
[promise-template]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/parameter-check-promise.py.in
output = ${buildout:directory}/parameter-check-promise.py
mode = 0644
[collective-egg]
recipe = zc.recipe.egg
eggs = collective.recipe.template
[versions] [versions]
Jinja2 = 2.7.3 Jinja2 = 2.7.3
MarkupSafe = 0.23 MarkupSafe = 0.23
...@@ -51,6 +66,7 @@ slapos.recipe.template = 2.5 ...@@ -51,6 +66,7 @@ slapos.recipe.template = 2.5
stevedore = 0.15 stevedore = 0.15
supervisor = 3.1.0 supervisor = 3.1.0
xml-marshaller = 0.9.7 xml-marshaller = 0.9.7
collective.recipe.template = 1.11
# Required by: # Required by:
# slapos.core==1.1.2 # slapos.core==1.1.2
......
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