summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-01-19 17:29:47 +0200
committerLars Wirzenius <liw@liw.fi>2018-01-19 17:29:47 +0200
commit3bc16ac24091009e73d9c4b9c2fbda0cdca6cff5 (patch)
treeee7530bbb5128a369e104ec547ca05f666f54941
parent7eb210040641c1fd77c0ff9a71260915ecb8bf11 (diff)
downloadick2-3bc16ac24091009e73d9c4b9c2fbda0cdca6cff5.tar.gz
Add: yarn scenario for building two project sequentially
-rw-r--r--yarns/400-build.yarn156
-rw-r--r--yarns/900-implements.yarn27
2 files changed, 183 insertions, 0 deletions
diff --git a/yarns/400-build.yarn b/yarns/400-build.yarn
index f30e942..9ccb7ae 100644
--- a/yarns/400-build.yarn
+++ b/yarns/400-build.yarn
@@ -621,3 +621,159 @@ Start build again. This should become build number 2.
... }
FINALLY stop ick controller
+
+
+# Build two projects sequentially
+
+This scenario tests the controller API to simulate a build.
+
+ SCENARIO build two projects sequentially
+
+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_pipelines_post
+ ... uapi_projects_post
+ ... uapi_projects_id_pipelines_id_put
+ ... uapi_projects_id_pipelines_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 a couple of projects.
+
+ WHEN user makes request POST /pipelines with a valid token and body
+ ... {
+ ... "pipeline": "do_something",
+ ... "actions": [
+ ... { "shell": "something" }
+ ... ]
+ ... }
+ THEN result has status code 201
+ WHEN user makes request POST /projects with a valid token and body
+ ... {
+ ... "project": "first",
+ ... "pipelines": ["do_something"]
+ ... }
+ THEN result has status code 201
+ WHEN user makes request POST /projects with a valid token and body
+ ... {
+ ... "project": "second",
+ ... "pipelines": ["do_something"]
+ ... }
+ THEN result has status code 201
+
+Register a worker.
+
+ GIVEN an access token for worker-manager with scopes
+ ... uapi_workers_post
+ ... uapi_work_post
+ ... uapi_work_id_get
+ WHEN worker-manager makes request POST /workers with a valid token and body
+ ... {
+ ... "worker": "obelix"
+ ... }
+ THEN result has status code 201
+
+Build the first project.
+
+ WHEN user makes request PUT /projects/first/pipelines/do_something
+ ... with a valid token and body { "status": "triggered" }
+ THEN result has status code 200
+
+ WHEN worker-manager makes request GET /work/obelix
+ THEN result is step
+ ... {
+ ... "action": "create_workspace"
+ ... }
+
+ WHEN worker-manager makes request POST /work with a valid token and body
+ ... {
+ ... "build_id": 1,
+ ... "worker": "obelix",
+ ... "project": "first",
+ ... "pipeline": "do_something",
+ ... "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 is step
+ ... {
+ ... "shell": "something"
+ ... }
+
+ WHEN worker-manager makes request POST /work with a valid token and body
+ ... {
+ ... "build_id": 1,
+ ... "worker": "obelix",
+ ... "project": "first",
+ ... "pipeline": "do_something",
+ ... "exit_code": 0,
+ ... "stdout": "",
+ ... "stderr": "",
+ ... "timestamp": "2017-10-27T17:08:49"
+ ... }
+ THEN result has status code 201
+
+ WHEN user requests list of builds
+ THEN the list of builds is [1]
+
+Build second project.
+
+ WHEN user makes request PUT /projects/second/pipelines/do_something
+ ... with a valid token and body { "status": "triggered" }
+ THEN result has status code 200
+
+ WHEN worker-manager makes request GET /work/obelix
+ THEN result is step
+ ... {
+ ... "action": "create_workspace"
+ ... }
+
+ WHEN worker-manager makes request POST /work with a valid token and body
+ ... {
+ ... "build_id": 2,
+ ... "worker": "obelix",
+ ... "project": "second",
+ ... "pipeline": "do_something",
+ ... "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 is step
+ ... {
+ ... "shell": "something"
+ ... }
+
+ WHEN worker-manager makes request POST /work with a valid token and body
+ ... {
+ ... "build_id": 2,
+ ... "worker": "obelix",
+ ... "project": "second",
+ ... "pipeline": "do_something",
+ ... "exit_code": 0,
+ ... "stdout": "",
+ ... "stderr": "",
+ ... "timestamp": "2017-10-27T17:08:49"
+ ... }
+ THEN result has status code 201
+
+ WHEN user requests list of builds
+ THEN the list of builds is [1, 2]
+
+Finish up.
+
+ FINALLY stop ick controller
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn
index 39b590b..b27b830 100644
--- a/yarns/900-implements.yarn
+++ b/yarns/900-implements.yarn
@@ -139,3 +139,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
value = get_next_match()
headers = vars['headers']
assertEqual(headers[name].lower(), value.lower())
+
+ IMPLEMENTS THEN result is step (.+)
+ step = json.loads(get_next_match())
+ body = json.loads(vars['body'])
+ actual_step = body['step']
+ print('expected step', step)
+ print('actual body', body)
+ print('actual step', actual_step)
+ diff = dict_diff(step, actual_step)
+ print('diff', diff)
+ assertEqual(diff, None)
+
+ IMPLEMENTS WHEN (\S+) requests list of builds
+ user = get_next_match()
+ token = get_token(user)
+ url = vars['url']
+ path = '/builds'
+ http(vars, get, url + path, token=token)
+
+ IMPLEMENTS THEN the list of builds is (.+)
+ expected = json.loads(get_next_match())
+ print('expected', expected)
+ body = json.loads(vars['body'])
+ print('body', body)
+ actual = [o['build_id'] for o in body['builds']]
+ print('actual', actual)
+ assertEqual(actual, expected)