From 23b7b2f901e4291ae4009f845a12b1ae32b66bb3 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 13 Nov 2017 19:50:16 +0100 Subject: Add: scenario for build in which a step fails --- yarns/500-build-fail.yarn | 169 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 yarns/500-build-fail.yarn (limited to 'yarns/500-build-fail.yarn') diff --git a/yarns/500-build-fail.yarn b/yarns/500-build-fail.yarn new file mode 100644 index 0000000..cfa1a12 --- /dev/null +++ b/yarns/500-build-fail.yarn @@ -0,0 +1,169 @@ + + +# Build step fails + +This scenario tests the controller API to simulate a build, when one +build step fails. + + SCENARIO build step fails + +Set up the controller. + + GIVEN an RSA key pair for token signing + AND controller config uses statedir at the state directory + AND an access token for user with scopes + ... uapi_projects_post + ... uapi_projects_id_pipeline_id_put + ... uapi_projects_id_pipeline_id_get + ... uapi_projects_id_builds_get + ... uapi_workers_id_get + ... uapi_builds_get + ... uapi_builds_id_get + ... uapi_logs_id_get + AND a running ick controller + +Add up a project. + + WHEN user makes request POST /projects + ... { + ... "project": "rome", + ... "pipelines": [ + ... { + ... "name": "construct", + ... "actions": [ + ... { "shell": "day 1" }, + ... { "shell": "day 2" } + ... ] + ... } + ... ] + ... } + THEN result has status code 201 + +Register a worker. + + GIVEN an access token for worker-manager with scopes + ... uapi_workers_post + ... uapi_work_post + WHEN worker-manager makes request POST /workers + ... { + ... "worker": "obelix" + ... } + THEN result has status code 201 + +Trigger build. First with an invalid status, then a real one. + + WHEN user makes request PUT /projects/rome/pipelines/construct + ... { "status": "triggered" } + THEN result has status code 200 + +Worker wants work and gets the first step to run. + + WHEN worker-manager makes request GET /work/obelix + THEN result has status code 200 + AND body matches + ... { + ... "build_id": 1, + ... "log": "/logs/1", + ... "worker": "obelix", + ... "project": "rome", + ... "pipeline": "construct", + ... "step": { + ... "shell": "day 1" + ... }, + ... "step_index": 0 + ... } + +Worker reports some build output. Note the exit code indicating +failure. + + WHEN worker-manager makes request POST /work + ... { + ... "build_id": 1, + ... "worker": "obelix", + ... "project": "rome", + ... "pipeline": "construct", + ... "exit_code": 1, + ... "stdout": "", + ... "stderr": "eek!", + ... "timestamp": "2017-10-27T17:08:49" + ... } + THEN result has status code 201 + +A build step failed, so now the build has ended, and there's no more +work to do. + + WHEN worker-manager makes request GET /work/obelix + THEN result has status code 200 + AND body matches {} + +User sees changed status. + + WHEN user makes request GET /workers/obelix + THEN result has status code 200 + AND body matches + ... { + ... "worker": "obelix", + ... "doing": {} + ... } + +The pipeline status indicates it's idle. + + WHEN user makes request GET /projects/rome/pipelines/construct + THEN result has status code 200 + AND body matches { "status": "idle" } + +Also, there's a build with a log. + + WHEN user makes request GET /builds + THEN result has status code 200 + AND body matches + ... { + ... "builds": [ + ... { + ... "build_id": 1, + ... "log": "/logs/1", + ... "worker": "obelix", + ... "project": "rome", + ... "pipeline": "construct", + ... "status": 1, + ... "log": "/logs/1" + ... } + ... ] + ... } + + WHEN user makes request GET /builds/1 + THEN result has status code 200 + AND body matches + ... { + ... "build_id": 1, + ... "log": "/logs/1", + ... "worker": "obelix", + ... "project": "rome", + ... "pipeline": "construct", + ... "status": 1, + ... "log": "/logs/1" + ... } + + WHEN user makes request GET /logs/1 + THEN result has status code 200 + AND result has header Content-Type: text/plain + AND body text is "eek!" + + FINALLY stop ick controller -- cgit v1.2.1