diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2015-09-11 10:10:44 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2015-09-11 15:01:30 +0100 |
commit | 6a3a8380a69ae43d6118e824e734c12f565909ef (patch) | |
tree | 3ef8fafac55b483034778654c889dbb9f5792dc8 | |
parent | b86407668bd51a5a0b5cdabbec6cd62063c3ddd3 (diff) | |
download | ciat-tester-6a3a8380a69ae43d6118e824e734c12f565909ef.tar.gz |
Test commands passed as yaml files, rather than hardcoded.
-rwxr-xr-x | openstack/tester | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/openstack/tester b/openstack/tester index e4c57cd..ac72fbf 100755 --- a/openstack/tester +++ b/openstack/tester @@ -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__': |