# Controller worker management The Ick2 controller manages information about workers. Workers are things that actually do the builds. A worker is described by a resource like this: EXAMPLE project resource { "worker": "obelix", "protocol": "ssh", "address": "obelix.ick.example.com", "user": "ick", "keywords": { "debian_release": "debian9", "debian_codename": "stretch", "debian_arch": "amd64" } } In other words, there are several things that define a worker: * The name, in the `worker` field. This is used for referreing to the project in the API. * Information for how to access the worker from the outside. The worker manager needs this, in case it's running on a different host from the worker. * Some keywords to describe the worker. The controller will use this to pick the appropriate worker to give a build to. ## Managing workers Note that this only tests managing information about workers via the controller API. It doesn't actually talk to the worker itself. SCENARIO managing workers GIVEN an access token for user with scopes ... uapi_workers_get ... uapi_workers_id_get ... uapi_workers_id_put ... uapi_workers_id_delete AND an access token for obelix with scopes ... uapi_workers_post AND a running ick controller WHEN user makes request GET /workers THEN result has status code 200 AND body matches { "workers": [] } WHEN obelix makes request POST /workers with a valid token and body ... { ... "protocol": "ssh", ... "address": "obelix.ick.example", ... "user": "ick", ... "keywords": { ... "debian_codename": "stretch" ... } ... } THEN result has status code 201 AND worker id is OBELIX AND body matches ... { ... "worker": "${OBELIX}", ... "protocol": "ssh", ... "address": "obelix.ick.example", ... "user": "ick", ... "keywords": { ... "debian_codename": "stretch" ... } ... } AND controller state directory contains worker obelix WHEN user makes request GET /workers THEN result has status code 200 AND body matches ... { ... "workers": [ ... { ... "worker": "${OBELIX}", ... "protocol": "ssh", ... "address": "obelix.ick.example", ... "user": "ick", ... "keywords": { ... "debian_codename": "stretch" ... } ... } ... ] ... } WHEN user stops ick controller GIVEN a running ick controller WHEN user makes request GET /workers/${OBELIX} THEN result has status code 200 AND body matches ... { ... "worker": "${OBELIX}", ... "protocol": "ssh", ... "address": "obelix.ick.example", ... "user": "ick", ... "keywords": { ... "debian_codename": "stretch" ... } ... } WHEN user makes request PUT /workers/${OBELIX} with a valid token ... and body ... { ... "worker": "${OBELIX}", ... "protocol": "local", ... "keywords": { ... "debian_codename": "unstable" ... } ... } THEN result has status code 200 AND body matches ... { ... "worker": "${OBELIX}", ... "protocol": "local", ... "keywords": { ... "debian_codename": "unstable" ... } ... } AND controller state directory contains worker obelix WHEN user makes request GET /workers/${OBELIX} THEN result has status code 200 AND body matches ... { ... "worker": "${OBELIX}", ... "protocol": "local", ... "keywords": { ... "debian_codename": "unstable" ... } ... } WHEN user makes request DELETE /workers/${OBELIX} THEN result has status code 200 WHEN user makes request GET /workers/${OBELIX} THEN result has status code 404 FINALLY stop ick controller