diff options
author | Antonio Terceiro <antonio.terceiro@linaro.org> | 2013-06-03 15:06:49 -0300 |
---|---|---|
committer | Antonio Terceiro <antonio.terceiro@linaro.org> | 2013-06-03 15:06:49 -0300 |
commit | 989d48dbe4070d5feca1eb1ca07e335579d16f33 (patch) | |
tree | a04b68232c09ec396b1a09e98d27a5467e063a44 /integration-tests.d | |
parent | fc8122956e59863ff821be224d51f4853348eb33 (diff) |
$ lava job submit JOB
Lots of infrastructure added; still missing proper unit testing in some places. At least an integraion test was added
Diffstat (limited to 'integration-tests.d')
-rw-r--r-- | integration-tests.d/lava-job-submit.sh | 12 | ||||
-rwxr-xr-x | integration-tests.d/lib/fixed_response | 11 | ||||
-rwxr-xr-x | integration-tests.d/lib/lava_config | 5 | ||||
-rw-r--r-- | integration-tests.d/lib/server.py | 59 | ||||
-rw-r--r-- | integration-tests.d/sample/nexus.json | 15 |
5 files changed, 102 insertions, 0 deletions
diff --git a/integration-tests.d/lava-job-submit.sh b/integration-tests.d/lava-job-submit.sh new file mode 100644 index 0000000..c459492 --- /dev/null +++ b/integration-tests.d/lava-job-submit.sh @@ -0,0 +1,12 @@ +fixed_response 999 + +lava_config <<CONFIG +[DEFAULT] +server = validation.example.com + +[server=validation.example.com] +rpc_endpoint = http://localhost:5000/ok +CONFIG + +lava job submit integration-tests.d/sample/nexus.json > $tmpdir/output +grep "Job submitted with job ID 999" $tmpdir/output diff --git a/integration-tests.d/lib/fixed_response b/integration-tests.d/lib/fixed_response new file mode 100755 index 0000000..5bc8e60 --- /dev/null +++ b/integration-tests.d/lib/fixed_response @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +import os +import sys +import xmlrpclib + +data = eval(sys.argv[1]) + +output = os.path.join(os.path.dirname(__file__), 'fixed_response.txt') +with open(output, 'w') as f: + f.write(xmlrpclib.dumps((data,), methodresponse=True)) diff --git a/integration-tests.d/lib/lava_config b/integration-tests.d/lib/lava_config new file mode 100755 index 0000000..b8551b2 --- /dev/null +++ b/integration-tests.d/lib/lava_config @@ -0,0 +1,5 @@ +#!/bin/sh + +set -e + +cat > "$LAVACONFIG" diff --git a/integration-tests.d/lib/server.py b/integration-tests.d/lib/server.py new file mode 100644 index 0000000..8ecb2cd --- /dev/null +++ b/integration-tests.d/lib/server.py @@ -0,0 +1,59 @@ +import os +import sys +import yaml + +from flask import ( + Flask, + request, +) + +app = Flask(__name__) + +aliases = { + 'ok': 200, + 'forbidden': 403, + 'notfound': 404, +} + +fixed_response = None + +@app.route('/exit') +def exit(): + # http://werkzeug.pocoo.org/docs/serving/#shutting-down-the-server + if not 'werkzeug.server.shutdown' in request.environ: + raise RuntimeError('Not running the development server') + request.environ['werkzeug.server.shutdown']() + return "" + +@app.route('/<status_code>', methods=['GET', 'POST']) +def reply(status_code): + + status = int(aliases.get(status_code, status_code)) + + headers = {} + for k,v in request.headers: + headers[k] = v + + response_file = os.path.join(os.path.dirname(__file__), 'fixed_response.txt') + if os.path.exists(response_file): + response = open(response_file).read() + os.remove(response_file) + else: + response = yaml.dump( + { + 'status': status, + 'headers': headers, + 'body': request.form.keys(), + 'query': dict(request.args), + }, + encoding='utf-8', + default_flow_style=False, + ) + return response, status, { 'Content-Type': 'text/plain' } + +@app.route('/', methods=['GET','POST']) +def root(): + return reply(200) + +if __name__ == '__main__': + app.run(debug=('DEBUG' in os.environ)) diff --git a/integration-tests.d/sample/nexus.json b/integration-tests.d/sample/nexus.json new file mode 100644 index 0000000..442014d --- /dev/null +++ b/integration-tests.d/sample/nexus.json @@ -0,0 +1,15 @@ +{ + "device_type": "nexus", + "job_name": "Boot test", + "actions": [ + { + "command": "deploy_linaro_image", + "parameters": { + "image": "http:///url/to/nexus.img" + } + }, + { + "command": "boot_linaro_image" + } + ] +}
\ No newline at end of file |