From 26eecba01073c116be934a017fd9a17c0baf0f89 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 10 Sep 2015 12:18:43 +0000 Subject: Test commands passed as yaml files, rather than hardcoded. --- scripts/release-test-os | 48 +++++++++++++++++++++++++----------------------- 1 file 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 --net-id --image-file --flavour ') - self.deploy_and_test_systems() + 'Usage: release-test-os --os-host --net-id --image-file --flavour ...') + + self.deploy_and_test_systems(args) if __name__ == '__main__': -- cgit v1.2.1