summaryrefslogtreecommitdiff
path: root/yarns/400-build.yarn
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-01-13 15:06:15 +0200
committerLars Wirzenius <liw@liw.fi>2018-01-14 22:23:47 +0200
commitefba85dcfa234b40160864e6eeddd472fb9853a9 (patch)
tree24123be0482f40f877a1693dff91508f11c83c3c /yarns/400-build.yarn
parentb1a4f39271979b1f1f9e461d8f97c2f01b6ab407 (diff)
downloadick2-efba85dcfa234b40160864e6eeddd472fb9853a9.tar.gz
Add: prepend a create_workspace action to pipelines
This replaces the old fresh_workspace attribute of work resources. It's better this way, because it moves policy from worker-manager to controller, where it belongs.
Diffstat (limited to 'yarns/400-build.yarn')
-rw-r--r--yarns/400-build.yarn95
1 files changed, 82 insertions, 13 deletions
diff --git a/yarns/400-build.yarn b/yarns/400-build.yarn
index 047c2b8..b18a0e6 100644
--- a/yarns/400-build.yarn
+++ b/yarns/400-build.yarn
@@ -108,6 +108,9 @@ Worker wants work and gets the first step to run. If the worker asks
again, it gets the same answer. **FIXME: should the name of the worker
be in the path or can we get it in the access token?**
+Note that the controller has inserted a special additional step to get
+the worker to construct a new workspace for the build.
+
WHEN worker-manager makes request GET /work/obelix
THEN result has status code 200
AND body matches
@@ -120,9 +123,8 @@ be in the path or can we get it in the access token?**
... "parameters": {
... "foo": "bar"
... },
- ... "fresh_workspace": true,
... "step": {
- ... "shell": "day 1"
+ ... "action": "create_workspace"
... }
... }
@@ -138,9 +140,8 @@ be in the path or can we get it in the access token?**
... "parameters": {
... "foo": "bar"
... },
- ... "fresh_workspace": true,
... "step": {
- ... "shell": "day 1"
+ ... "action": "create_workspace"
... }
... }
@@ -167,9 +168,8 @@ User can now see pipeline is running and which worker is building it.
... "parameters": {
... "foo": "bar"
... },
- ... "fresh_workspace": true,
... "step": {
- ... "shell": "day 1"
+ ... "action": "create_workspace"
... }
... }
... }
@@ -186,6 +186,7 @@ User can now see pipeline is running and which worker is building it.
... "project": "rome",
... "pipeline": "construct",
... "actions": [
+ ... { "action": "create_workspace" },
... { "shell": "day 1" },
... { "shell": "day 2" }
... ],
@@ -204,7 +205,42 @@ User can now see pipeline is running and which worker is building it.
AND result has header Content-Type: text/plain
AND body text is ""
-Worker reports some build output. Note the null exit code.
+Worker reports workspace creation is done. Note the zero exit code.
+
+ WHEN worker-manager makes request POST /work with a valid token and body
+ ... {
+ ... "build_id": 1,
+ ... "worker": "obelix",
+ ... "project": "rome",
+ ... "pipeline": "construct",
+ ... "exit_code": 0,
+ ... "stdout": "",
+ ... "stderr": "",
+ ... "timestamp": "2017-10-27T17:08:49"
+ ... }
+ THEN result has status code 201
+
+Worker requests more work, and gets the first actual build step.
+
+ 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",
+ ... "parameters": {
+ ... "foo": "bar"
+ ... },
+ ... "step": {
+ ... "shell": "day 1"
+ ... }
+ ... }
+
+Worker reports some build output. Note the null exit code. The step
+hasn't finished yet.
WHEN worker-manager makes request POST /work with a valid token and body
... {
@@ -234,7 +270,6 @@ didnt't finish.
... "parameters": {
... "foo": "bar"
... },
- ... "fresh_workspace": true,
... "step": {
... "shell": "day 1"
... }
@@ -281,10 +316,11 @@ The build status now shows the next step as the active one.
... "project": "rome",
... "pipeline": "construct",
... "actions": [
+ ... { "action": "create_workspace" },
... { "shell": "day 1" },
... { "shell": "day 2" }
... ],
- ... "current_action": 1,
+ ... "current_action": 2,
... "parameters": {
... "foo": "bar"
... },
@@ -308,7 +344,6 @@ Now there's another step to do.
... "parameters": {
... "foo": "bar"
... },
- ... "fresh_workspace": false,
... "step": {
... "shell": "day 2"
... }
@@ -329,7 +364,6 @@ User sees changed status.
... "parameters": {
... "foo": "bar"
... },
- ... "fresh_workspace": false,
... "step": {
... "shell": "day 2"
... },
@@ -379,6 +413,7 @@ no current action.
... "project": "rome",
... "pipeline": "construct",
... "actions": [
+ ... { "action": "create_workspace" },
... { "shell": "day 1" },
... { "shell": "day 2" }
... ],
@@ -402,6 +437,7 @@ no current action.
... "project": "rome",
... "pipeline": "construct",
... "actions": [
+ ... { "action": "create_workspace" },
... { "shell": "day 1" },
... { "shell": "day 2" }
... ],
@@ -436,9 +472,8 @@ Start build again. This should become build number 2.
... "parameters": {
... "foo": "bar"
... },
- ... "fresh_workspace": true,
... "step": {
- ... "shell": "day 1"
+ ... "action": "create_workspace"
... }
... }
@@ -454,6 +489,7 @@ Start build again. This should become build number 2.
... "project": "rome",
... "pipeline": "construct",
... "actions": [
+ ... { "action": "create_workspace" },
... { "shell": "day 1" },
... { "shell": "day 2" }
... ],
@@ -470,6 +506,7 @@ Start build again. This should become build number 2.
... "project": "rome",
... "pipeline": "construct",
... "actions": [
+ ... { "action": "create_workspace" },
... { "shell": "day 1" },
... { "shell": "day 2" }
... ],
@@ -489,6 +526,36 @@ Start build again. This should become build number 2.
... "project": "rome",
... "pipeline": "construct",
... "exit_code": 0,
+ ... "stdout": "",
+ ... "stderr": "",
+ ... "timestamp": "2017-10-27T17:08:49"
+ ... }
+ THEN result has status code 201
+
+ WHEN worker-manager makes request GET /work/obelix
+ THEN result has status code 200
+ AND body matches
+ ... {
+ ... "build_id": 2,
+ ... "log": "/logs/2",
+ ... "worker": "obelix",
+ ... "project": "rome",
+ ... "pipeline": "construct",
+ ... "parameters": {
+ ... "foo": "bar"
+ ... },
+ ... "step": {
+ ... "shell": "day 1"
+ ... }
+ ... }
+
+ WHEN worker-manager makes request POST /work with a valid token and body
+ ... {
+ ... "build_id": 2,
+ ... "worker": "obelix",
+ ... "project": "rome",
+ ... "pipeline": "construct",
+ ... "exit_code": 0,
... "stdout": "hey ho",
... "stderr": "",
... "timestamp": "2017-10-27T17:08:49"
@@ -523,6 +590,7 @@ Start build again. This should become build number 2.
... "project": "rome",
... "pipeline": "construct",
... "actions": [
+ ... { "action": "create_workspace" },
... { "shell": "day 1" },
... { "shell": "day 2" }
... ],
@@ -539,6 +607,7 @@ Start build again. This should become build number 2.
... "project": "rome",
... "pipeline": "construct",
... "actions": [
+ ... { "action": "create_workspace" },
... { "shell": "day 1" },
... { "shell": "day 2" }
... ],