Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): deployment progress shows stack name #16604

Merged
merged 7 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,9 @@ export class HistoryActivityPrinter extends ActivityPrinterBase {

this.stream.write(
util.format(
' %s%s | %s | %s | %s %s%s%s\n',
(progress !== false ? ` ${this.progress()} | ` : ''),
'%s | %s%s | %s | %s | %s %s%s%s\n',
e.StackName,
(progress !== false ? `${this.progress()} | ` : ''),
new Date(e.Timestamp).toLocaleTimeString(),
color(padRight(STATUS_WIDTH, (e.ResourceStatus || '').substr(0, STATUS_WIDTH))), // pad left and trim
padRight(this.props.resourceTypeColumnWidth, e.ResourceType || ''),
Expand Down
42 changes: 21 additions & 21 deletions packages/aws-cdk/test/api/stack-activity-monitor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ test('prints 0/4 progress report, when addActivity is called with an "IN_PROGRES
ResourceType: 'AWS::CloudFormation::Stack',
StackId: '',
EventId: '',
StackName: '',
StackName: 'stack-name',
},
});
});

expect(output[0].trim()).toStrictEqual(`0/4 | ${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`);
expect(output[0].trim()).toStrictEqual(`stack-name | 0/4 | ${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`);
});

test('prints 1/4 progress report, when addActivity is called with an "UPDATE_COMPLETE" ResourceStatus', () => {
Expand All @@ -51,12 +51,12 @@ test('prints 1/4 progress report, when addActivity is called with an "UPDATE_COM
ResourceType: 'AWS::CloudFormation::Stack',
StackId: '',
EventId: '',
StackName: '',
StackName: 'stack-name',
},
});
});

expect(output[0].trim()).toStrictEqual(`1/4 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`);
expect(output[0].trim()).toStrictEqual(`stack-name | 1/4 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`);
});

test('prints 1/4 progress report, when addActivity is called with an "UPDATE_COMPLETE_CLEAN_IN_PROGRESS" ResourceStatus', () => {
Expand All @@ -75,12 +75,12 @@ test('prints 1/4 progress report, when addActivity is called with an "UPDATE_COM
ResourceType: 'AWS::CloudFormation::Stack',
StackId: '',
EventId: '',
StackName: '',
StackName: 'stack-name',
},
});
});

expect(output[0].trim()).toStrictEqual(`1/4 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE_CLEA')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`);
expect(output[0].trim()).toStrictEqual(`stack-name | 1/4 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE_CLEA')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`);
});


Expand All @@ -100,12 +100,12 @@ test('prints 1/4 progress report, when addActivity is called with an "ROLLBACK_C
ResourceType: 'AWS::CloudFormation::Stack',
StackId: '',
EventId: '',
StackName: '',
StackName: 'stack-name',
},
});
});

expect(output[0].trim()).toStrictEqual(`1/4 | ${HUMAN_TIME} | ${yellow('ROLLBACK_COMPLETE_CL')} | AWS::CloudFormation::Stack | ${yellow(bold('stack1'))}`);
expect(output[0].trim()).toStrictEqual(`stack-name | 1/4 | ${HUMAN_TIME} | ${yellow('ROLLBACK_COMPLETE_CL')} | AWS::CloudFormation::Stack | ${yellow(bold('stack1'))}`);
});

test('prints 0/4 progress report, when addActivity is called with an "UPDATE_FAILED" ResourceStatus', () => {
Expand All @@ -124,12 +124,12 @@ test('prints 0/4 progress report, when addActivity is called with an "UPDATE_FAI
ResourceType: 'AWS::CloudFormation::Stack',
StackId: '',
EventId: '',
StackName: '',
StackName: 'stack-name',
},
});
});

expect(output[0].trim()).toStrictEqual(`0/4 | ${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`);
expect(output[0].trim()).toStrictEqual(`stack-name | 0/4 | ${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`);
});


Expand All @@ -149,7 +149,7 @@ test('does not print "Failed Resources:" list, when all deployments are successf
ResourceType: 'AWS::CloudFormation::Stack',
StackId: '',
EventId: '',
StackName: '',
StackName: 'stack-name',
},
});
historyActivityPrinter.addActivity({
Expand All @@ -160,7 +160,7 @@ test('does not print "Failed Resources:" list, when all deployments are successf
ResourceType: 'AWS::CloudFormation::Stack',
StackId: '',
EventId: '',
StackName: '',
StackName: 'stack-name',
},
});
historyActivityPrinter.addActivity({
Expand All @@ -171,16 +171,16 @@ test('does not print "Failed Resources:" list, when all deployments are successf
ResourceType: 'AWS::CloudFormation::Stack',
StackId: '',
EventId: '',
StackName: '',
StackName: 'stack-name',
},
});
historyActivityPrinter.stop();
});

expect(output.length).toStrictEqual(3);
expect(output[0].trim()).toStrictEqual(`0/2 | ${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`);
expect(output[1].trim()).toStrictEqual(`1/2 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`);
expect(output[2].trim()).toStrictEqual(`2/2 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack2'))}`);
expect(output[0].trim()).toStrictEqual(`stack-name | 0/2 | ${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`);
expect(output[1].trim()).toStrictEqual(`stack-name | 1/2 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`);
expect(output[2].trim()).toStrictEqual(`stack-name | 2/2 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack2'))}`);
});

test('prints "Failed Resources:" list, when at least one deployment fails', () => {
Expand All @@ -199,7 +199,7 @@ test('prints "Failed Resources:" list, when at least one deployment fails', () =
ResourceType: 'AWS::CloudFormation::Stack',
StackId: '',
EventId: '',
StackName: '',
StackName: 'stack-name',
},
});
historyActivityPrinter.addActivity({
Expand All @@ -210,15 +210,15 @@ test('prints "Failed Resources:" list, when at least one deployment fails', () =
ResourceType: 'AWS::CloudFormation::Stack',
StackId: '',
EventId: '',
StackName: '',
StackName: 'stack-name',
},
});
historyActivityPrinter.stop();
});

expect(output.length).toStrictEqual(4);
expect(output[0].trim()).toStrictEqual(`0/2 | ${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`);
expect(output[1].trim()).toStrictEqual(`0/2 | ${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`);
expect(output[0].trim()).toStrictEqual(`stack-name | 0/2 | ${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`);
expect(output[1].trim()).toStrictEqual(`stack-name | 0/2 | ${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`);
expect(output[2].trim()).toStrictEqual('Failed resources:');
expect(output[3].trim()).toStrictEqual(`${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`);
expect(output[3].trim()).toStrictEqual(`stack-name | ${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`);
});