diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2015-09-10 12:18:43 +0000 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2015-09-11 08:50:45 +0000 |
commit | 26eecba01073c116be934a017fd9a17c0baf0f89 (patch) | |
tree | 7d6cedc137f4051f86a71aaf3078f51f92498e55 | |
parent | 453e61d0a11d9bf01f803c974d3333751340a4cb (diff) | |
download | definitions-26eecba01073c116be934a017fd9a17c0baf0f89.tar.gz |
Test commands passed as yaml files, rather than hardcoded.
-rwxr-xr-x | scripts/release-test-os | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/scripts/release-test-os b/scripts/release-test-os index 44763c36..5dd9769e 100755 --- a/scripts/release-test-os +++ b/scripts/release-test-os @@ -31,6 +31,7 @@ import socket import tempfile import time import uuid +import yaml from novaclient import client @@ -276,28 +277,28 @@ class ReleaseApp(cliapp.Application): default=None, group=group_main) - def run_tests(self, instance): + def run_tests(self, instance, tests): instance.wait_until_online() - tests = [] - - def uname_test(instance): - print('# uname test'); - instance.runcmd(['uname', '-a'], stdout=self.output) - - def python_smoke_test(instance): - print('# python test') - instance.runcmd(['python', '-c', 'print "Hello World"'], - stdout=self.output) - - # TODO: Come up with a better way of determining which tests to run - tests.append(uname_test) - tests.append(python_smoke_test) - for test in tests: - test(instance) - - def deploy_and_test_systems(self): + with open(test, 'r') as stream: + data=yaml.load(stream) + + if data == None: + continue + if 'name' not in data: + print('Bad test: no name') + continue + if 'commands' not in data: + print('Bad test: no commands') + continue + + print('Running test: ' + data['name']) + for cmd in data['commands']: + print('$ ' + cmd) + instance.runcmd(shlex.split(cmd), stdout=self.output) + + def deploy_and_test_systems(self, tests): """Run the deployments and tests""" # TODO: Don't assume root is the user we ssh to for tests @@ -310,7 +311,7 @@ class ReleaseApp(cliapp.Application): instance = deployment.deploy() try: - self.run_tests(instance) + self.run_tests(instance, tests) finally: instance.delete() @@ -319,10 +320,11 @@ class ReleaseApp(cliapp.Application): for setting in ('os-host', 'net-id', 'image-file', 'flavour'): self.settings.require(setting) - if len(args) != 0: + if len(args) == 0: raise cliapp.AppException( - 'Usage: release-test-os --os-host <HOST> --net-id <ID> --image-file <PATH> --flavour <NAME>') - self.deploy_and_test_systems() + 'Usage: release-test-os --os-host <HOST> --net-id <ID> --image-file <PATH> --flavour <NAME> <TEST_FILE>...') + + self.deploy_and_test_systems(args) if __name__ == '__main__': |