diff options
author | Mason Test Runner <mason@test.runner> | 2014-11-07 16:38:10 +0000 |
---|---|---|
committer | Mason Test Runner <mason@test.runner> | 2014-11-07 16:38:10 +0000 |
commit | 79977555a97e526e651c178357746cb0623c7027 (patch) | |
tree | f93d1d41825127e9410f189b9c4adb87c6d3f06c | |
parent | 2af90ed7f4bcf754bc9d2466d9ab297ed10129dd (diff) | |
download | turbo-hipster-79977555a97e526e651c178357746cb0623c7027.tar.gz |
Add a plugin which implements the current Mason test
This is a prototype for me to get my head around how
turbo-hipster plugins work and how they can be useful
to us.
-rw-r--r-- | turbo_hipster/task_plugins/build_deploy_test/__init__.py | 0 | ||||
-rw-r--r-- | turbo_hipster/task_plugins/build_deploy_test/task.py | 122 |
2 files changed, 122 insertions, 0 deletions
diff --git a/turbo_hipster/task_plugins/build_deploy_test/__init__.py b/turbo_hipster/task_plugins/build_deploy_test/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/turbo_hipster/task_plugins/build_deploy_test/__init__.py diff --git a/turbo_hipster/task_plugins/build_deploy_test/task.py b/turbo_hipster/task_plugins/build_deploy_test/task.py new file mode 100644 index 0000000..5e68dde --- /dev/null +++ b/turbo_hipster/task_plugins/build_deploy_test/task.py @@ -0,0 +1,122 @@ +# Copyright 2014 Codethink Ltd + +import cliapp +import json +import logging +import os +import urlparse + +from turbo_hipster.lib import common +from turbo_hipster.lib import models + + +class Runner(models.Task): + + """This thread handles running the build-deploy-build test, + which is used to ensure that Baserock can build Baserock.""" + + log = logging.getLogger("task_plugins.build_deploy_test.task.Runner") + + def __init__(self, worker_server, plugin_config, job_name): + super(Runner, self).__init__(worker_server, plugin_config, job_name) + + self.total_steps = 5 + print self.job_arguments + + def do_job_steps(self): + self.log.info('Step 1: Creating a workspace') + self._create_workspace() + + self.log.info('Step 2: Building the systems') + self._build_systems() + + self.log.info('Step 3: Test the systems can build themselves') + self._test_systems() + + self.log.info('Step 4: Uploading artifacts to remote cache') + self._upload_artifacts() + + self.log.info('Step 5: Clean up') + self._clean_up() + + def _do_git_config(self): + cliapp.runcmd(['git', 'config', '--global', 'user.name', + 'Mason Test Runner']) + cliapp.runcmd(['git', 'config', '--global', 'user.email', + 'mason@test.runner']) + + @common.task_step + def _create_workspace(self): + self.commit = self.job_arguments['ZUUL_COMMIT'] + self.project = self.job_arguments['ZUUL_PROJECT'] + self.ref = self.job_arguments['ZUUL_REF'] + self.workspace = '/root/mason-workspace' + self.zuul_url = self.job_arguments['ZUUL_URL'] + + url = urlparse.urlparse(self.zuul_url) + netloc = '%s@%s' % (url.username, url.hostname) + self.defs_checkout = os.path.join(self.workspace, + self.commit, + netloc, + str(url.port), + self.project) + + self._do_git_config() + cliapp.runcmd(['morph', 'init', self.workspace]) + + repo = '%s/%s' % (self.zuul_url, self.project) + cliapp.runcmd(['morph', 'checkout', repo, self.commit], cwd=self.workspace) + print 'checkout done' + #cliapp.runcmd(['git', 'checkout', commit], cwd=self.defs_checkout) + + @common.task_step + def _build_systems(self): + print 'entered build_systems' + cmd = ['/usr/lib/mason/mason-build'] + args = ['--no-default-configs', + '--trove-host', self.plugin_config['config']['trove-host'], + '--artifact-cache-server', + self.plugin_config['config']['artifact-cache-server'], + '--controllers', self.plugin_config['config']['controllers'], + self.plugin_config['config']['cluster-morphology'] + ] + print cmd + args + cliapp.runcmd(cmd + args, cwd=self.defs_checkout) + + @common.task_step + def _test_systems(self): + infrastructure = \ + self.plugin_config['config']['test-infrastructure-type'] + cmd = ['scripts/release-test'] + args = ['--deployment-host', + self.plugin_config['config']['deployment-host'], + '--trove-host', self.plugin_config['config']['trove-host'], + '--trove-id', self.plugin_config['config']['trove-id'] + ] + if infrastructure == 'openstack': + cmd = ['scripts/release-test-os'] + args += ['--net-id', + self.plugin_config['config']['openstack-network-id']] + args += [self.plugin_config['config']['cluster-morphology']] + print cmd + args + cliapp.runcmd(cmd + args, cwd=self.defs_checkout) + + @common.task_step + def _upload_artifacts(self): + cmd = ['scripts/release-upload'] + args = ['--build-trove-host', + self.plugin_config['config']['artifact-cache-server'], + '--arch', self.plugin_config['config']['architecture'], + '--log-level=debug', '--log=/var/log/release-upload.log', + '--public-trove-host', + self.plugin_config['config']['upstream-trove'], + '--public-trove-username', 'root', + '--public-trove-artifact-dir', '/home/cache/artifacts', + '--no-upload-release-artifacts', + self.plugin_config['config']['cluster-morphology']] + cliapp.runcmd(cmd + args, cwd=self.defs_checkout) + + @common.task_step + def _clean_up(self): + cliapp.runcmd(['rm', '-rf', self.workspace]) + print done |