summaryrefslogtreecommitdiff
path: root/yarns/500-build-fail.yarn
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-11-13 19:50:16 +0100
committerLars Wirzenius <liw@liw.fi>2017-11-13 19:50:16 +0100
commit23b7b2f901e4291ae4009f845a12b1ae32b66bb3 (patch)
tree8ec8fa278178620711852b905f1aced3bf346489 /yarns/500-build-fail.yarn
parent06186f1a5313b7b97176e1cf1d75ff42c4b8ac2f (diff)
downloadick2-23b7b2f901e4291ae4009f845a12b1ae32b66bb3.tar.gz
Add: scenario for build in which a step fails
Diffstat (limited to 'yarns/500-build-fail.yarn')
-rw-r--r--yarns/500-build-fail.yarn169
1 files changed, 169 insertions, 0 deletions
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 @@
+<!--
+
+Copyright 2017 Lars Wirzenius
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+-->
+
+# 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