Skip to content

Commit

Permalink
chore: improve integration test for notices (#31606)
Browse files Browse the repository at this point in the history
Our current test only captures bootstrap notices, lets capture all.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
iliapolo authored Oct 1, 2024
1 parent 5c34e1f commit 6d41250
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ class YourStack extends cdk.Stack {
}
}

class NoticesStack extends cdk.Stack {
constructor(parent, id, props) {
super(parent, id, props);
new sqs.Queue(this, 'queue');
}
}

class SsoPermissionSetNoPolicy extends Stack {
constructor(scope, id) {
super(scope, id);
Expand Down Expand Up @@ -753,6 +760,7 @@ switch (stackSet) {
// Deploy all does a wildcard ${stackPrefix}-test-*
new MyStack(app, `${stackPrefix}-test-1`, { env: defaultEnv });
new YourStack(app, `${stackPrefix}-test-2`);
new NoticesStack(app, `${stackPrefix}-notices`);
// Deploy wildcard with parameters does ${stackPrefix}-param-test-*
new ParameterStack(app, `${stackPrefix}-param-test-1`);
new OtherParameterStack(app, `${stackPrefix}-param-test-2`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2260,33 +2260,79 @@ integTest(
}),
);

integTest('cdk notices for bootstrap', withDefaultFixture(async (fixture) => {
integTest('cdk notices are displayed correctly', withDefaultFixture(async (fixture) => {

const cache = {
expiration: 4125963264000, // year 2100 so we never overwrite the cache
notices: [{
title: 'Bootstrap stack outdated',
issueNumber: 16600,
overview: 'Your environments "{resolve:ENVIRONMENTS}" are running an outdated bootstrap stack.',
components: [{
name: 'bootstrap',
version: '<2000',
}],
schemaVersion: '1',
}],
notices: [
{
title: 'CLI Notice',
issueNumber: 1111,
overview: 'Overview for CLI Notice',
components: [
{
name: 'cli',
version: '<99.0.0',
},
],
schemaVersion: '1',
},
{
title: 'Framework Notice',
issueNumber: 2222,
overview: 'Overview for Framework Notice',
components: [
{
name: 'framework',
version: '<99.0.0',
},
],
schemaVersion: '1',
},
{
title: 'Queue Notice',
issueNumber: 3333,
overview: 'Overview for Queue Notice',
components: [
{
name: 'aws-cdk-lib.aws_sqs.Queue',
version: '<99.0.0',
},
],
schemaVersion: '1',
},
{
title: 'Bootstrap 22 Notice',
issueNumber: 4444,
overview: 'Overview for Bootstrap 22 Notice. AffectedEnvironments:<{resolve:ENVIRONMENTS}>',
components: [
{
name: 'bootstrap',
version: '22',
},
],
schemaVersion: '1',
},
],
};

const cdkCacheDir = path.join(fixture.integTestDir, 'cache');
await fs.mkdir(cdkCacheDir);
await fs.writeFile(path.join(cdkCacheDir, 'notices.json'), JSON.stringify(cache));

const output = await fixture.cdkDeploy('test-2', {
const output = await fixture.cdkDeploy('notices', {
verbose: false,
modEnv: {
CDK_HOME: fixture.integTestDir,
},
});

expect(output).toContain('Your environments \"aws://');
expect(output).toContain('Overview for CLI Notice');
expect(output).toContain('Overview for Framework Notice');
expect(output).toContain('Overview for Queue Notice');
expect(output).toContain('Overview for Bootstrap 22 Notice');

// assert dynamic environments are resolved
expect(output).toContain(`AffectedEnvironments:<aws://${await fixture.aws.account()}/${fixture.aws.region}>`);

}));

0 comments on commit 6d41250

Please sign in to comment.