Skip to content

Commit

Permalink
Issue 6892: workerManager.registerWorker: treat test-provisioner-id s…
Browse files Browse the repository at this point in the history
…pecially
  • Loading branch information
petemoore committed Mar 8, 2024
1 parent 65542dc commit 679d036
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
8 changes: 8 additions & 0 deletions changelog/issue-6892.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
audience: developers
level: minor
reference: issue 6892
---
Worker Manager now special-cases `registerWorker` API calls with provisionerId
`test-provisioner-id`. It responds as if the call was successful with fake
`credentials`, `expiry`, and `secret`, but the real `workerConfig`, if it
exists.
4 changes: 3 additions & 1 deletion services/worker-manager/schemas/v1/worker-pool-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ properties:
type: string
pattern: {$const: workerpoolid-pattern}
description: |
The ID of this worker pool (of the form `providerId/workerType` for compatibility)
The ID of this worker pool (of the form `provisionerId/workerType` for
compatibility). Worker Pool IDs beginning `test-provisioner-id/` are
reserved for integration testing.
providerId:
title: Provider
type: string
Expand Down
18 changes: 18 additions & 0 deletions services/worker-manager/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,11 @@ builder.declare({
'This call both marks the worker as running and returns the credentials',
'the worker will require to perform its work. The worker must provide',
'some proof of its identity, and that proof varies by provider type.',
'',
'This method may also be called by integration tests by passing a `workerPoolId`',
'beginning with `test-provisioner-id/`. Such integration tests do not require',
'a valid `workerIdentityProof`, `workerId` or `workerGroup`. The response',
'will include fake `credentials`, `expires` and `secret`, but a valid `workerConfig`.',
].join('\n'),
}, async function(req, res) {
const { workerPoolId, providerId, workerGroup, workerId, workerIdentityProof } = req.body;
Expand Down Expand Up @@ -820,6 +825,19 @@ builder.declare({
`Worker pool ${workerPoolId} not associated with provider ${providerId}`, {});
}

if (workerPoolId.startsWith("test-provisioner-id/")) {
return res.reply({
expires: "2000-00-00T00:00:00Z",
credentials: {
accessToken: "test-access-token",
certificate: "test-certificate",
clientId: "test-client-id",
},
workerConfig,
secret: "test-secret",
});
}

const worker = await Worker.get(this.db, { workerPoolId, workerGroup, workerId });
if (!worker) {
this.monitor.debug({
Expand Down

0 comments on commit 679d036

Please sign in to comment.