Description: Test a new worker before creating it, or test an existing worker before updating it.
Since: 7.63.2
Security: Admin authentication is required.
Usage: POST /worker/api/v1/test/[/{workerKey}]
Produces: application/json; charset=utf-8
Parameters
Name | Datatype | Mandatory | Description |
---|---|---|---|
|
| Yes | The worker script in TypeScript or JavaScript. |
|
| Yes | Choose one of the following worker actions with which the worker is associated.
|
|
| Yes | An object that matches the action's event data. The object should match the |
|
| No | If provided, identifies an existing worker to be tested |
|
| No | The secrets to be made available during the test. If testing an existing worker, its secrets will be made available during the test. |
Sample Usage
curl -X POST 'https://myserver.com/worker/api/v1/system/test' Ok
Sample Request
{ "code": string, "action": string, "data": object, // action specific payload "stagedSecrets": undefined | Secret[] }
Sample Response
{ "logs": string, // All logs generated by the worker's script appear in one line. "beforeDownload": { // The type of action. "status": DownloadStatus, // The status returned by the worker script itself. "message": string, // The message returned by the worker script. "executionStatus": “STATUS_SUCCESS” // Execution status for the worker service. } }
Secrets
Define the secret type:
{ "key": string, // The name of the secret. "value": string // The value of the secret. }
When testing an existing worker, identified by a workerKey
, it is not possible to change the value of an existing secret.
If a staged secret is similar to an existing one, the secret should be marked for removal and then added with a new value, as in the following example.
{ "stagedSecrets": [ { “key”: “my-secret-0”, markedForRemoval: true }, { “key”: “my-secret-0”, “value”: “new-value-of-my-secret-0” } ] }
Success Response Codes:
200: OK response.
Error Response Codes:
400 The request payload is malformed.
401 Invalid credentials.
403 Insufficient permissions.
422 Error occurs when the worker service cannot encrypt a secret.
500 Error occurred during the request processing.
Sample Errors
Request Error
{ "errors": [ { "status": number, // HTTP Error status code "message": string // Reason for error } ] }
Caution
The status should be either STATUS_SUCCESS
or STATUS_FAIL
.
Execution Error
{ "message": string, // This is the message containing the error. "executionStatus": "STATUS_FAIL" }