@adobe/aio-lib-cloudmanager
Advanced tools
Comparing version 1.11.0 to 1.12.0
# Changelog | ||
# [1.12.0](https://github.com/adobe/aio-lib-cloudmanager/compare/1.11.0...1.12.0) (2021-10-26) | ||
### Features | ||
* **commerce:** enable downloading of commerce command logs for completed commands. fixes [#274](https://github.com/adobe/aio-lib-cloudmanager/issues/274) ([cb7ca13](https://github.com/adobe/aio-lib-cloudmanager/commit/cb7ca13ac3041318039a749ab99c254556f2a4c3)) | ||
# [1.11.0](https://github.com/adobe/aio-lib-cloudmanager/compare/1.10.1...1.11.0) (2021-10-25) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@adobe/aio-lib-cloudmanager", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "Adobe I/O Cloud Manager Library", | ||
@@ -54,3 +54,3 @@ "repository": { | ||
"eslint-plugin-jest": "25.2.2", | ||
"eslint-plugin-jsdoc": "37.0.0", | ||
"eslint-plugin-jsdoc": "37.0.3", | ||
"eslint-plugin-node": "11.1.0", | ||
@@ -57,0 +57,0 @@ "eslint-plugin-promise": "5.1.1", |
@@ -1376,4 +1376,22 @@ /* | ||
async _downloadCommerceCommandExecutionLog (programId, environmentId, commandExecutionId, outputStream) { | ||
const environment = await this._findEnvironment(programId, environmentId) | ||
const link = this._getCommerceCommandLogUrl(environment, commandExecutionId) | ||
const tailLogRedirectUrl = await this._getTailLogRedirectUrl(link) | ||
const fullLog = await fetch(tailLogRedirectUrl, { | ||
headers: { | ||
range: 'bytes=0-', | ||
}, | ||
}) | ||
if (fullLog.status === 206) { | ||
await this._pipeBodyWithTransform(fullLog.body, outputStream, this._commerceLogTransform) | ||
} else { | ||
throw new codes.ERROR_GET_LOG({ messageValues: commandExecutionId }) | ||
} | ||
} | ||
async tailCommerceCommandExecutionLog (programId, environmentId, commandExecutionId, outputStream) { | ||
let commandStatus = await this._getCommerceCommandStatus(programId, environmentId, commandExecutionId) | ||
let currentStartLimit = 0 | ||
@@ -1384,3 +1402,2 @@ if (commandStatus === 'RUNNING') { | ||
const tailLogRedirectUrl = await this._getTailLogRedirectUrl(link) | ||
let currentStartLimit = 0 | ||
@@ -1410,2 +1427,4 @@ while (commandStatus === 'RUNNING') { | ||
} | ||
} else if (commandStatus === 'COMPLETED' && currentStartLimit === 0) { | ||
await this._downloadCommerceCommandExecutionLog(programId, environmentId, commandExecutionId, outputStream) | ||
} else { | ||
@@ -1412,0 +1431,0 @@ throw new codes.ERROR_COMMAND_NOT_RUNNING({ messageValues: commandExecutionId }) |
@@ -111,4 +111,4 @@ /* | ||
test('getCommerceTailLogs - command status is not "RUNNING"', async () => { | ||
expect.assertions(2) | ||
test('getCommerceTailLogs - command status is "COMPLETED" -- success', async () => { | ||
expect.assertions(4) | ||
@@ -119,5 +119,31 @@ const sdkClient = await createSdkClient() | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).resolves.toEqual('COMPLETED') | ||
expect(fetchMock.calls('full-log-1-first').length).toEqual(1) | ||
flushWritable() | ||
expect(written).toEqual('This is the full log:\n') | ||
}) | ||
test('getCommerceTailLogs - command status is "COMPLETED" -- failed', async () => { | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.tailCommerceCommandExecutionLog('4', '10', '712f', writable) | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_COMMAND_NOT_RUNNING({ messageValues: '712' }), | ||
new codes.ERROR_GET_LOG({ messageValues: ['https://cloudmanager.adobe.io/api/program/4/pipeline/10/runtime/commerce/command-execution/712f/logs (500 Internal Server Error)'] }), | ||
) | ||
}) | ||
test('getCommerceTailLogs - command status is "FAILED"', async () => { | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.tailCommerceCommandExecutionLog('4', '10', '712000', writable) | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_COMMAND_NOT_RUNNING({ messageValues: '712000' }), | ||
) | ||
}) |
Sorry, the diff of this file is too big to display
1920674
11541
8