From f11a8ecd409f280759af7227db52b1e87e389092 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 19 Apr 2018 22:31:01 +0300 Subject: Change: trigger a project, build all pipelines in the project --- ick2/__init__.py | 3 +- ick2/apibase.py | 4 +- ick2/projectapi.py | 62 ++++++++++++--------------- ick2/projectapi_tests.py | 107 +++++++++++++--------------------------------- ick2/state.py | 25 ++++++++++- ick2/workapi.py | 69 +++++++++--------------------- ick2/workapi_tests.py | 17 +++----- icktool | 4 +- icktool2 | 4 +- yarns/400-build.yarn | 64 +++++++-------------------- yarns/500-build-fail.yarn | 14 +++--- yarns/600-unauthz.yarn | 8 ++-- 12 files changed, 140 insertions(+), 241 deletions(-) diff --git a/ick2/__init__.py b/ick2/__init__.py index 1f6b514..6884c16 100644 --- a/ick2/__init__.py +++ b/ick2/__init__.py @@ -18,10 +18,11 @@ from .logging import setup_logging, log from .state import ( ControllerState, NotFound, - WrongPipelineStatus, + WrongProjectStatus, Workers, Projects, PipelineInstances, + ProjectStatus, Builds, ) from .exceptions import ( diff --git a/ick2/apibase.py b/ick2/apibase.py index 13b258a..50b8390 100644 --- a/ick2/apibase.py +++ b/ick2/apibase.py @@ -100,10 +100,10 @@ class APIbase: ick2.log.log( 'warning', msg_text='PUT Not found', kwargs=kwargs) return ick2.not_found(e) - except ick2.WrongPipelineStatus as e: + except ick2.WrongProjectStatus as e: ick2.log.log( 'error', - msg_text='Wrong state for pipeline', + msg_text='Wrong state for project', exception=str(e)) return ick2.bad_request(e) ick2.log.log('trace', msg_text='returned body', body=repr(body)) diff --git a/ick2/projectapi.py b/ick2/projectapi.py index 9548c38..d689b4a 100644 --- a/ick2/projectapi.py +++ b/ick2/projectapi.py @@ -20,7 +20,7 @@ class ProjectAPI(ick2.ResourceApiBase): def __init__(self, state): super().__init__('projects', state) - self._pi = ick2.PipelineInstances(self.get_state()) + self._ps = ick2.ProjectStatus(self.get_state()) def mangle_new_resource(self, resource): new = dict(resource) @@ -37,47 +37,44 @@ class ProjectAPI(ick2.ResourceApiBase): return resource['project'] def get_routes(self, path): # pragma: no cover - return super().get_routes(path) + self.get_pipeline_routes(path) + return super().get_routes(path) + self.get_status_routes(path) - def get_pipeline_routes(self, path): # pragma: no cover - pipeline_path = '{}//pipelines/'.format(path) + def get_status_routes(self, path): # pragma: no cover + status_path = '{}//status'.format(path) + trigger_path = '{}//+trigger'.format(path) return [ { 'method': 'GET', - 'path': pipeline_path, - 'callback': self.GET(self.get_pipeline), + 'path': status_path, + 'callback': self.GET(self.get_status), }, { 'method': 'PUT', - 'path': pipeline_path, - 'callback': self.PUT(self.set_pipeline_callback), + 'path': status_path, + 'callback': self.PUT(self.set_status_callback), }, { 'needs-authorization': False, 'method': 'GET', - 'path': pipeline_path + '/+trigger', - 'callback': self.GET(self.trigger_pipeline), + 'path': trigger_path, + 'callback': self.GET(self.trigger_project), }, ] - def get_pipeline(self, project, pipeline, **kwargs): - p = self._state.get_resource(self._type_name, project) - if pipeline not in p['pipelines']: - raise ick2.NotFound() - - pl = self._pi.get_instance(project, pipeline) + def get_status(self, project, **kwargs): + _ = self._state.get_resource(self._type_name, project) + ps = self._ps.get_instance(project) return { - 'status': pl.get('status', 'idle'), + 'status': ps.get('status', 'idle'), } - def set_pipeline_callback( - self, body, project, pipeline, **kwargs): # pragma: no cover - return self.set_pipeline(body['status'], project, pipeline) + def set_status_callback(self, body, project, **kwargs): # pragma: no cover + return self.set_status(project, body['status']) - def set_pipeline(self, status, project, pipeline): + def set_status(self, project, status): ick2.log.log( - 'trace', msg_text='Setting pipeline status', - project=project, pipeline=pipeline, status=status) + 'trace', msg_text='Setting project status', + project=project, status=status) allowed_changes = { 'idle': 'triggered', @@ -86,22 +83,17 @@ class ProjectAPI(ick2.ResourceApiBase): } p = self._state.get_resource(self._type_name, project) - if pipeline not in p['pipelines']: - ick2.log.log( - 'error', msg_text='Project not found', project=project) - raise ick2.NotFound() ick2.log.log('trace', msg_text='Found project', project=p) - pl = self._pi.get_instance(project, pipeline) - old_status = pl.get('status', 'idle') + ps = self._ps.get_instance(project) + old_status = ps.get('status', 'idle') if allowed_changes[old_status] != status: - raise ick2.WrongPipelineStatus(status) - pl['status'] = status - self._pi.update_instance(project, pipeline, pl) + raise ick2.WrongProjectStatus(status) + ps['status'] = status + self._ps.update_instance(project, ps) return {'status': status} # This needs to go away as it is not protected. Once an IDP is # added. - def trigger_pipeline( - self, project, pipeline, **kwargs): # pragma: no cover - return self.set_pipeline('triggered', project, pipeline) + def trigger_project(self, project, **kwargs): # pragma: no cover + return self.set_status(project, 'triggered') diff --git a/ick2/projectapi_tests.py b/ick2/projectapi_tests.py index 96242ef..2ef1dbe 100644 --- a/ick2/projectapi_tests.py +++ b/ick2/projectapi_tests.py @@ -19,6 +19,9 @@ import tempfile import unittest +import yaml + + import ick2 @@ -44,15 +47,6 @@ class ProjectAPITests(unittest.TestCase): self.assertEqual(api.list(), {'projects': []}) def test_creates_project(self): - pipeline = { - 'pipeline': 'build', - 'actions': [ - {'shell': 'step-1'}, - ], - } - pipeapi = self.create_pipeline_api() - pipeapi.create(pipeline) - project = { 'project': 'foo', 'pipelines': ['build'], @@ -61,32 +55,19 @@ class ProjectAPITests(unittest.TestCase): }, } api = self.create_api() - new = api.create(project) project['next_build_id'] = None self.assertEqual(new, project) self.assertEqual(api.list(), {'projects': [new]}) - self.assertEqual(api.get_pipeline('foo', 'build'), {'status': 'idle'}) - self.assertEqual(api.get_pipeline('foo', 'build'), {'status': 'idle'}) + dirname = os.path.join(self.statedir, 'projects') + filename = os.listdir(dirname)[0] + obj = yaml.safe_load(open(os.path.join(dirname, filename))) + self.assertEqual(api.get_status('foo'), {'status': 'idle'}) - def test_raises_error_when_getting_missing_pipeline(self): - project = { - 'project': 'foo', - 'pipelines': [ - { - 'pipeline': 'build', - 'actions': [ - { - 'shell': 'step-1', - }, - ], - }, - ], - } + def test_raises_error_when_getting_missing_project_status(self): api = self.create_api() - api.create(project) with self.assertRaises(ick2.NotFound): - api.get_pipeline('foo', 'does-not-exist') + api.get_status('does-not-exist') def test_loads_projects_from_state_directory(self): project = { @@ -141,61 +122,33 @@ class ProjectAPITests(unittest.TestCase): with self.assertRaises(ick2.NotFound): api.delete('foo') - def test_updates_pipeline_status(self): - pipeline = { - 'pipeline': 'build', - 'actions': [ - {'shell': 'step-1'}, - ], - } - pipeapi = self.create_pipeline_api() - pipeapi.create(pipeline) - + def test_updates_project_status(self): project = { 'project': 'foo', - 'pipelines': ['build'], } api = self.create_api() api.create(project) - self.assertEqual(api.get_pipeline('foo', 'build'), {'status': 'idle'}) - self.assertEqual(pipeapi.show('build'), pipeline) - - with self.assertRaises(ick2.WrongPipelineStatus): - api.set_pipeline('building', 'foo', 'build') - - api.set_pipeline('triggered', 'foo', 'build') - self.assertEqual(pipeapi.show('build'), pipeline) - self.assertEqual( - api.get_pipeline('foo', 'build'), - {'status': 'triggered'} - ) - - with self.assertRaises(ick2.WrongPipelineStatus): - api.set_pipeline('idle', 'foo', 'build') - - api.set_pipeline('building', 'foo', 'build') - self.assertEqual(pipeapi.show('build'), pipeline) - self.assertEqual( - api.get_pipeline('foo', 'build'), - {'status': 'building'} - ) - - with self.assertRaises(ick2.WrongPipelineStatus): - api.set_pipeline('triggered', 'foo', 'build') - - api.set_pipeline('idle', 'foo', 'build') - self.assertEqual(pipeapi.show('build'), pipeline) - self.assertEqual( - api.get_pipeline('foo', 'build'), - {'status': 'idle'} - ) + self.assertEqual(api.get_status('foo'), {'status': 'idle'}) + + with self.assertRaises(ick2.WrongProjectStatus): + api.set_status('foo', 'build') + + api.set_status('foo', 'triggered') + self.assertEqual(api.get_status('foo'), {'status': 'triggered'}) + + with self.assertRaises(ick2.WrongProjectStatus): + api.set_status('foo', 'idle') + + api.set_status('foo', 'building') + self.assertEqual(api.get_status('foo'), {'status': 'building'}) + + with self.assertRaises(ick2.WrongProjectStatus): + api.set_status('foo', 'triggered') + + api.set_status('foo', 'idle') + self.assertEqual(api.get_status('foo'), {'status': 'idle'}) def test_raises_error_updating_status_of_missing_pipeline(self): - project = { - 'project': 'foo', - 'pipelines': [], - } api = self.create_api() - api.create(project) with self.assertRaises(ick2.NotFound): - api.set_pipeline('idle', 'foo', 'build') + api.set_status('does-not-exist', 'triggered') diff --git a/ick2/state.py b/ick2/state.py index 846b113..40dcfe8 100644 --- a/ick2/state.py +++ b/ick2/state.py @@ -105,10 +105,10 @@ class NotFound(Exception): super().__init__('Resource not found') -class WrongPipelineStatus(Exception): # pragma: no cover +class WrongProjectStatus(Exception): # pragma: no cover def __init__(self, new_state): - super().__init__('Cannot set pipeline state to {}'.format(new_state)) + super().__init__('Cannot set project state to {}'.format(new_state)) class ResourceStore: # pragma: no cover @@ -202,3 +202,24 @@ class PipelineInstances(ResourceStore): # pragma: no cover def update_instance(self, project_name, pipeline_name, instance): name = self._name(project_name, pipeline_name) self.add(name, instance) + + +class ProjectStatus(ResourceStore): # pragma: no cover + + def __init__(self, state): + super().__init__(state, 'project_status', 'project') + + def _name(self, project_name): + return project_name + + def get_instance(self, project_name): + name = self._name(project_name) + return self.get(name) + + def add_instance(self, project_name, instance): + name = self._name(project_name) + self.add(name, instance) + + def update_instance(self, project_name, instance): + name = self._name(project_name) + self.add(name, instance) diff --git a/ick2/workapi.py b/ick2/workapi.py index f1352d0..fa9c2bc 100644 --- a/ick2/workapi.py +++ b/ick2/workapi.py @@ -22,7 +22,7 @@ class WorkAPI(ick2.APIbase): super().__init__(state) self._workers = ick2.Workers(state) self._projects = ick2.Projects(state) - self._pinstances = ick2.PipelineInstances(state) + self._ps = ick2.ProjectStatus(state) self._builds = ick2.Builds(state) self._type_name = 'work' @@ -43,15 +43,13 @@ class WorkAPI(ick2.APIbase): def get_work(self, worker, **kwargs): worker_state = self._workers.get_worker(worker) if not worker_state.get('doing'): - project, pipeline = self._pick_triggered_pipeline() + project = self._pick_triggered_project() if project is None: doing = {} else: - pipeline['status'] = 'building' - self._update_pipeline(project, pipeline) + self._set_project_status(project['project'], 'building') - build_id, build_no = self._start_build( - project, pipeline, worker) + build_id, build_no = self._start_build(project, worker) self._start_log(build_id) build = self._get_build(build_id) actions = build['actions'] @@ -62,7 +60,6 @@ class WorkAPI(ick2.APIbase): 'build_number': build_no, 'worker': worker, 'project': project['project'], - 'pipeline': pipeline['pipeline'], 'parameters': project.get('parameters', {}), 'step': actions[current_action], 'log': '/logs/{}'.format(build_id), @@ -86,27 +83,20 @@ class WorkAPI(ick2.APIbase): old_build_no=old_build_no, build_no=build_no) return build_no - def _pick_triggered_pipeline(self): + def _pick_triggered_project(self): projects = self._projects.get_projects() for project in projects: - for name in project['pipelines']: - pl = self._pinstances.get_instance(project['project'], name) - if pl.get('status') == 'triggered': - pt = self._state.get_resource('pipelines', name) - return project, pt - return None, None - - def _update_pipeline(self, project, pipeline_instance): - project_name = project['project'] - pipeline_name = pipeline_instance['pipeline'] - try: - self._pinstances.update_instance( - project_name, pipeline_name, pipeline_instance) - except ick2.NotFound: # pragma: no cover - self._pinstances.add_instance( - project_name, pipeline_name, pipeline_instance) - - def _start_build(self, project, pipeline, worker): + ps = self._ps.get_instance(project['project']) + if ps.get('status') == 'triggered': + return project + return None + + def _set_project_status(self, project_name, status): + ps = self._ps.get_instance(project_name) + ps['status'] = status + self._ps.update_instance(project_name, ps) + + def _start_build(self, project, worker): build_no = self._pick_build_number(project) build_id = '{}/{}'.format(project['project'], build_no) @@ -124,7 +114,6 @@ class WorkAPI(ick2.APIbase): 'log': '/logs/{}'.format(build_id), 'worker': worker, 'project': project['project'], - 'pipeline': pipeline['pipeline'], 'parameters': parameters, 'status': 'building', 'actions': actions, @@ -159,8 +148,8 @@ class WorkAPI(ick2.APIbase): doing = worker_state.get('doing', {}) self._check_work_update(doing, update) - project, pipeline = self._get_pipeline( - update['project'], update['pipeline']) + project_name = update['project'] + self._append_to_build_log(update) exit_code = update.get('exit_code') @@ -170,8 +159,7 @@ class WorkAPI(ick2.APIbase): actions = build['actions'] current_action = build['current_action'] if current_action + 1 >= len(actions): - pipeline['status'] = 'idle' - self._update_pipeline(project, pipeline) + self._set_project_status(project_name, 'idle') doing = {} self._finish_build(update) else: @@ -188,8 +176,7 @@ class WorkAPI(ick2.APIbase): elif exit_code is not None: assert isinstance(exit_code, int) assert exit_code != 0 - pipeline['status'] = 'idle' - self._update_pipeline(project, pipeline) + self._set_project_status(project_name, 'idle') self._finish_build(update) worker_state = { @@ -199,7 +186,7 @@ class WorkAPI(ick2.APIbase): self._workers.update_worker(worker_state) def _check_work_update(self, doing, update): # pragma: no cover - must_match = ['worker', 'project', 'pipeline', 'build_id'] + must_match = ['worker', 'project', 'build_id'] for name in must_match: if name not in update: raise ick2.BadUpdate('{} not specified'.format(name)) @@ -208,20 +195,6 @@ class WorkAPI(ick2.APIbase): '{} differs from current work: {} vs {}'.format( name, doing.get(name), update[name])) - def _get_pipeline(self, project, pipeline): # pragma: no cover - projects = [ - p - for p in self._projects.get_projects() - if p['project'] == project - ] - if not projects: - raise ick2.NotFound() - p = projects[0] - if pipeline not in p['pipelines']: - raise ick2.NotFound() - pt = self._state.get_resource('pipelines', pipeline) - return p, pt - def _append_to_build_log(self, update): build_id = update['build_id'] log = self._state.get_resource('log', str(build_id)) diff --git a/ick2/workapi_tests.py b/ick2/workapi_tests.py index 1ee4625..92d34e5 100644 --- a/ick2/workapi_tests.py +++ b/ick2/workapi_tests.py @@ -75,7 +75,7 @@ class WorkAPITests(unittest.TestCase): def test_worker_gets_work_when_a_pipeline_is_triggered(self): projects = self.create_project_api() - projects.set_pipeline('triggered', 'foo', 'build') + projects.set_status('foo', 'triggered') self.create_worker_api() work = self.create_work_api() expected = { @@ -83,7 +83,6 @@ class WorkAPITests(unittest.TestCase): 'build_number': 1, 'worker': 'asterix', 'project': 'foo', - 'pipeline': 'build', 'parameters': { 'foo': 'bar', }, @@ -99,7 +98,7 @@ class WorkAPITests(unittest.TestCase): def test_worker_manager_posts_work_updates(self): projects = self.create_project_api() - projects.set_pipeline('triggered', 'foo', 'build') + projects.set_status('foo', 'triggered') self.create_worker_api() work = self.create_work_api() @@ -109,7 +108,6 @@ class WorkAPITests(unittest.TestCase): 'build_number': 1, 'worker': 'asterix', 'project': 'foo', - 'pipeline': 'build', 'parameters': { 'foo': 'bar', }, @@ -125,7 +123,6 @@ class WorkAPITests(unittest.TestCase): 'build_id': 'foo/1', 'worker': 'asterix', 'project': 'foo', - 'pipeline': 'build', 'exit_code': None, 'stdout': 'out', 'stderr': 'err', @@ -162,12 +159,12 @@ class WorkAPITests(unittest.TestCase): # An pipeline status has changed. self.assertEqual( - projects.get_pipeline('foo', 'build'), + projects.get_status('foo'), {'status': 'idle'}) def test_worker_manager_posts_failure(self): projects = self.create_project_api() - projects.set_pipeline('triggered', 'foo', 'build') + projects.set_status('foo', 'triggered') self.create_worker_api() work = self.create_work_api() @@ -177,7 +174,6 @@ class WorkAPITests(unittest.TestCase): 'build_number': 1, 'worker': 'asterix', 'project': 'foo', - 'pipeline': 'build', 'parameters': { 'foo': 'bar', }, @@ -193,7 +189,6 @@ class WorkAPITests(unittest.TestCase): 'build_id': 'foo/1', 'worker': 'asterix', 'project': 'foo', - 'pipeline': 'build', 'exit_code': 1, 'stdout': 'out', 'stderr': 'err', @@ -204,7 +199,7 @@ class WorkAPITests(unittest.TestCase): # Ask for work again. self.assertEqual(work.get_work('asterix'), {}) - # An pipeline status has changed. + # And project status has changed. self.assertEqual( - projects.get_pipeline('foo', 'build'), + projects.get_status('foo'), {'status': 'idle'}) diff --git a/icktool b/icktool index b4cbc9d..7890f7f 100755 --- a/icktool +++ b/icktool @@ -60,8 +60,8 @@ class Icktool(cliapp.Application): _default_scopes = [ 'uapi_version_get', 'uapi_work_post', - 'uapi_projects_id_pipelines_id_get', - 'uapi_projects_id_pipelines_id_put', + 'uapi_projects_id_status_get', + 'uapi_projects_id_status_put', 'uapi_blobs_id_get', 'uapi_blobs_id_put', ] + scopes_for_types(types) diff --git a/icktool2 b/icktool2 index df5ccdd..20140ee 100755 --- a/icktool2 +++ b/icktool2 @@ -63,8 +63,8 @@ class Icktool(cliapp.Application): _default_scopes = [ 'uapi_version_get', 'uapi_work_post', - 'uapi_projects_id_pipelines_id_get', - 'uapi_projects_id_pipelines_id_put', + 'uapi_projects_id_status_get', + 'uapi_projects_id_status_put', 'uapi_blobs_id_get', 'uapi_blobs_id_put', ] + scopes_for_types(types) diff --git a/yarns/400-build.yarn b/yarns/400-build.yarn index 3ee30a6..796bd20 100644 --- a/yarns/400-build.yarn +++ b/yarns/400-build.yarn @@ -32,8 +32,8 @@ Set up the controller. AND an access token for user with scopes ... uapi_pipelines_post ... uapi_projects_post - ... uapi_projects_id_pipelines_id_put - ... uapi_projects_id_pipelines_id_get + ... uapi_projects_id_status_put + ... uapi_projects_id_status_get ... uapi_projects_id_builds_get ... uapi_workers_id_get ... uapi_builds_get @@ -76,7 +76,7 @@ Add a second project so we know each project gets its own work steps. There are no builds for the project yet, and is idle. - WHEN user makes request GET /projects/rome/pipelines/construct + WHEN user makes request GET /projects/rome/status THEN result has status code 200 AND body matches { "status": "idle" } @@ -98,11 +98,11 @@ Register a worker. Trigger build. First with an invalid status, then a real one. - WHEN user makes request PUT /projects/rome/pipelines/construct + WHEN user makes request PUT /projects/rome/status ... with a valid token and body { "status": "VANDALS!" } THEN result has status code 400 - WHEN user makes request PUT /projects/rome/pipelines/construct + WHEN user makes request PUT /projects/rome/status ... with a valid token and body { "status": "triggered" } THEN result has status code 200 @@ -122,7 +122,6 @@ the worker to construct a new workspace for the build. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "parameters": { ... "foo": "bar" ... }, @@ -140,7 +139,6 @@ the worker to construct a new workspace for the build. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "parameters": { ... "foo": "bar" ... }, @@ -151,7 +149,7 @@ the worker to construct a new workspace for the build. User can now see pipeline is running and which worker is building it. - WHEN user makes request GET /projects/rome/pipelines/construct + WHEN user makes request GET /projects/rome/status THEN result has status code 200 AND body matches ... { @@ -169,7 +167,6 @@ User can now see pipeline is running and which worker is building it. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "parameters": { ... "foo": "bar" ... }, @@ -190,7 +187,6 @@ User can now see pipeline is running and which worker is building it. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "actions": [ ... { "action": "create_workspace" }, ... { "shell": "day 1" }, @@ -218,7 +214,6 @@ Worker reports workspace creation is done. Note the zero exit code. ... "build_id": "rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "exit_code": 0, ... "stdout": "", ... "stderr": "", @@ -237,7 +232,6 @@ Worker requests more work, and gets the first actual build step. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "parameters": { ... "foo": "bar" ... }, @@ -254,7 +248,6 @@ hasn't finished yet. ... "build_id": "rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "exit_code": null, ... "stdout": "hey ho", ... "stderr": "", @@ -274,7 +267,6 @@ didnt't finish. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "parameters": { ... "foo": "bar" ... }, @@ -297,7 +289,6 @@ Report the step is done, and successfully. ... "build_id": "rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "exit_code": 0, ... "stdout": ", hey ho\n", ... "stderr": "", @@ -323,7 +314,6 @@ The build status now shows the next step as the active one. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "actions": [ ... { "action": "create_workspace" }, ... { "shell": "day 1" }, @@ -350,7 +340,6 @@ Now there's another step to do. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "parameters": { ... "foo": "bar" ... }, @@ -371,7 +360,6 @@ User sees changed status. ... "build_number": 1, ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "parameters": { ... "foo": "bar" ... }, @@ -389,7 +377,6 @@ Report it done. ... "build_id": "rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "exit_code": 0, ... "stdout": "to the gold mine we go!\n", ... "stderr": "", @@ -405,7 +392,7 @@ Now there's no more work to do. The pipeline status indicates success. - WHEN user makes request GET /projects/rome/pipelines/construct + WHEN user makes request GET /projects/rome/status THEN result has status code 200 AND body matches { "status": "idle" } @@ -423,7 +410,6 @@ no current action. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "actions": [ ... { "action": "create_workspace" }, ... { "shell": "day 1" }, @@ -447,7 +433,6 @@ no current action. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "actions": [ ... { "action": "create_workspace" }, ... { "shell": "day 1" }, @@ -467,7 +452,7 @@ no current action. Start build again. This should become build number 2. - WHEN user makes request PUT /projects/rome/pipelines/construct + WHEN user makes request PUT /projects/rome/status ... with a valid token and body { "status": "triggered" } THEN result has status code 200 @@ -480,7 +465,6 @@ Start build again. This should become build number 2. ... "log": "/logs/rome/2", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "parameters": { ... "foo": "bar" ... }, @@ -500,7 +484,6 @@ Start build again. This should become build number 2. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "actions": [ ... { "action": "create_workspace" }, ... { "shell": "day 1" }, @@ -518,7 +501,6 @@ Start build again. This should become build number 2. ... "log": "/logs/rome/2", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "actions": [ ... { "action": "create_workspace" }, ... { "shell": "day 1" }, @@ -538,7 +520,6 @@ Start build again. This should become build number 2. ... "build_id": "rome/2", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "exit_code": 0, ... "stdout": "", ... "stderr": "", @@ -555,7 +536,6 @@ Start build again. This should become build number 2. ... "log": "/logs/rome/2", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "parameters": { ... "foo": "bar" ... }, @@ -569,7 +549,6 @@ Start build again. This should become build number 2. ... "build_id": "rome/2", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "exit_code": 0, ... "stdout": "hey ho", ... "stderr": "", @@ -585,7 +564,6 @@ Start build again. This should become build number 2. ... "build_id": "rome/2", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "exit_code": 0, ... "stdout": "hey ho", ... "stderr": "", @@ -604,7 +582,6 @@ Start build again. This should become build number 2. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "actions": [ ... { "action": "create_workspace" }, ... { "shell": "day 1" }, @@ -622,7 +599,6 @@ Start build again. This should become build number 2. ... "log": "/logs/rome/2", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "actions": [ ... { "action": "create_workspace" }, ... { "shell": "day 1" }, @@ -655,8 +631,8 @@ Set up the controller. AND an access token for user with scopes ... uapi_pipelines_post ... uapi_projects_post - ... uapi_projects_id_pipelines_id_put - ... uapi_projects_id_pipelines_id_get + ... uapi_projects_id_status_put + ... uapi_projects_id_status_get ... uapi_projects_id_builds_get ... uapi_workers_id_get ... uapi_builds_get @@ -701,7 +677,7 @@ Register a worker. Build the first project. - WHEN user makes request PUT /projects/first/pipelines/do_something + WHEN user makes request PUT /projects/first/status ... with a valid token and body { "status": "triggered" } THEN result has status code 200 @@ -717,7 +693,6 @@ Build the first project. ... "build_number": 1, ... "worker": "obelix", ... "project": "first", - ... "pipeline": "do_something", ... "exit_code": 0, ... "stdout": "", ... "stderr": "", @@ -737,7 +712,6 @@ Build the first project. ... "build_number": 1, ... "worker": "obelix", ... "project": "first", - ... "pipeline": "do_something", ... "exit_code": 0, ... "stdout": "", ... "stderr": "", @@ -750,7 +724,7 @@ Build the first project. Build second project. - WHEN user makes request PUT /projects/second/pipelines/do_something + WHEN user makes request PUT /projects/second/status ... with a valid token and body { "status": "triggered" } THEN result has status code 200 @@ -765,7 +739,6 @@ Build second project. ... "build_id": "second/1", ... "worker": "obelix", ... "project": "second", - ... "pipeline": "do_something", ... "exit_code": 0, ... "stdout": "", ... "stderr": "", @@ -784,7 +757,6 @@ Build second project. ... "build_id": "second/1", ... "worker": "obelix", ... "project": "second", - ... "pipeline": "do_something", ... "exit_code": 0, ... "stdout": "", ... "stderr": "", @@ -815,8 +787,8 @@ Set up the controller. AND an access token for user with scopes ... uapi_pipelines_post ... uapi_projects_post - ... uapi_projects_id_pipelines_id_put - ... uapi_projects_id_pipelines_id_get + ... uapi_projects_id_status_put + ... uapi_projects_id_status_get ... uapi_projects_id_builds_get ... uapi_workers_id_get ... uapi_builds_get @@ -873,7 +845,7 @@ Register a couple of workers. Trigger both projects. - WHEN user makes request PUT /projects/first/pipelines/do_something + WHEN user makes request PUT /projects/first/status ... with a valid token and body { "status": "triggered" } THEN result has status code 200 @@ -889,7 +861,7 @@ Trigger both projects. WHEN user requests list of builds THEN the list of builds is ["first/1"] - WHEN user makes request PUT /projects/second/pipelines/do_something + WHEN user makes request PUT /projects/second/status ... with a valid token and body { "status": "triggered" } THEN result has status code 200 @@ -908,7 +880,6 @@ Trigger both projects. ... "build_number": 1, ... "worker": "asterix", ... "project": "first", - ... "pipeline": "do_something", ... "exit_code": 0, ... "stdout": "", ... "stderr": "", @@ -934,7 +905,6 @@ Trigger both projects. ... "build_number": 1, ... "worker": "obelix", ... "project": "second", - ... "pipeline": "do_something", ... "exit_code": 0, ... "stdout": "", ... "stderr": "", @@ -953,7 +923,6 @@ Trigger both projects. ... "build_id": "first/1", ... "worker": "asterix", ... "project": "first", - ... "pipeline": "do_something", ... "exit_code": 0, ... "stdout": "", ... "stderr": "", @@ -969,7 +938,6 @@ Trigger both projects. ... "build_id": "second/1", ... "worker": "obelix", ... "project": "second", - ... "pipeline": "do_something", ... "exit_code": 0, ... "stdout": "", ... "stderr": "", diff --git a/yarns/500-build-fail.yarn b/yarns/500-build-fail.yarn index 95fcd5e..0a12178 100644 --- a/yarns/500-build-fail.yarn +++ b/yarns/500-build-fail.yarn @@ -33,8 +33,8 @@ Set up the controller. AND an access token for user with scopes ... uapi_pipelines_post ... uapi_projects_post - ... uapi_projects_id_pipelines_id_put - ... uapi_projects_id_pipelines_id_get + ... uapi_projects_id_status_put + ... uapi_projects_id_status_get ... uapi_projects_id_builds_get ... uapi_workers_id_get ... uapi_builds_get @@ -72,9 +72,9 @@ Register a worker. ... } THEN result has status code 201 -Trigger build. First with an invalid status, then a real one. +Trigger build. - WHEN user makes request PUT /projects/rome/pipelines/construct + WHEN user makes request PUT /projects/rome/status ... with a valid token and body { "status": "triggered" } THEN result has status code 200 @@ -89,7 +89,6 @@ Worker wants work and gets the first step to run. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "parameters": {}, ... "step": { ... "action": "create_workspace" @@ -104,7 +103,6 @@ failure. ... "build_id": "rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "exit_code": 1, ... "stdout": "", ... "stderr": "eek!", @@ -131,7 +129,7 @@ User sees changed status. The pipeline status indicates it's idle. - WHEN user makes request GET /projects/rome/pipelines/construct + WHEN user makes request GET /projects/rome/status THEN result has status code 200 AND body matches { "status": "idle" } @@ -148,7 +146,6 @@ Also, there's a build with a log. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "actions": [ ... { "action": "create_workspace" }, ... { "shell": "day 1" }, @@ -170,7 +167,6 @@ Also, there's a build with a log. ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", - ... "pipeline": "construct", ... "actions": [ ... { "action": "create_workspace" }, ... { "shell": "day 1" }, diff --git a/yarns/600-unauthz.yarn b/yarns/600-unauthz.yarn index 14e0015..176ac49 100644 --- a/yarns/600-unauthz.yarn +++ b/yarns/600-unauthz.yarn @@ -32,8 +32,8 @@ Set up the controller. AND controller config uses https://auth.example.com as authentication AND an access token for user with scopes ... uapi_projects_post - ... uapi_projects_id_pipelines_id_put - ... uapi_projects_id_pipelines_id_get + ... uapi_projects_id_status_put + ... uapi_projects_id_status_get ... uapi_projects_id_builds_get ... uapi_workers_id_get ... uapi_builds_get @@ -63,7 +63,7 @@ Set up the controller. THEN result has status code 401 WHEN outsider makes request - ... GET /projects/rome/pipelines/construct + ... GET /projects/rome/status ... with an invalid token THEN result has status code 401 @@ -75,7 +75,7 @@ Set up the controller. THEN result has status code 401 WHEN outsider makes request - ... PUT /projects/rome/pipelines/construct with an invalid token + ... PUT /projects/rome/status with an invalid token THEN result has status code 401 WHEN outsider makes request -- cgit v1.2.1