Skip to content

Commit

Permalink
chore: backport test changes while adjusting feature flags in v2 (#14233
Browse files Browse the repository at this point in the history
)

This is a backport of 81148f0.

The defaults for some feature flags in CDKv2 are changing from 'false'
to 'true'.

Some test are sensitive to this change. This change modifies such tests
to explicitly set the value of the feature flag so that its behavior is
consistent across the two versions of the CDK.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Niranjan Jayakar authored Apr 19, 2021
1 parent f8b6445 commit 2edf199
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export = {
},

'GlobalTable generated stacks inherit their account from the parent stack'(test: Test) {
const app = new App();
const app = new App({ context: { '@aws-cdk/core:stackRelativeExports': true } });
const stack = new Stack(app, 'GlobalTableStack', { env: { account: '123456789012', region: 'us-east-1' } });

const globalTable = new GlobalTable(stack, CONSTRUCT_NAME, {
Expand All @@ -81,7 +81,7 @@ export = {
'Outputs': {
'DynamoDbOutput': {
'Value': {
'Fn::ImportValue': 'GlobalTableStackawscdkdynamodbglobalawscdkdynamodbglobaluseast19C1C8A14:awscdkdynamodbglobalawscdkdynamodbglobaluseast1ExportsOutputFnGetAttawscdkdynamodbglobalGlobalTableuseast1FC03DD69StreamArn28E90DB8',
'Fn::ImportValue': 'GlobalTableStackawscdkdynamodbglobalawscdkdynamodbglobaluseast19C1C8A14:ExportsOutputFnGetAttawscdkdynamodbglobalGlobalTableuseast1FC03DD69StreamArn9CE585ED',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-rds/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@ describe('cluster', () => {

test('does not changes the case of the cluster identifier if the lowercaseDbIdentifier feature flag is disabled', () => {
// GIVEN
const app = new cdk.App();
const app = new cdk.App({ context: { '@aws-cdk/aws-rds:lowercaseDbIdentifier': false } });
const stack = testStack(app);
const vpc = new ec2.Vpc(stack, 'VPC');

Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-rds/test/instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,8 @@ describe('instance', () => {

test( 'does not changes the case of the cluster identifier if the lowercaseDbIdentifier feature flag is disabled', () => {
// GIVEN
stack = new cdk.Stack();
const app = new cdk.App({ context: { '@aws-cdk/aws-rds:lowercaseDbIdentifier': false } });
stack = new cdk.Stack(app);
vpc = new ec2.Vpc( stack, 'VPC' );

// WHEN
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-rds/test/serverless-cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ nodeunitShim({

'does not change the case of the cluster identifier if the lowercaseDbIdentifier feature flag is disabled'(test: Test) {
// GIVEN
const app = new cdk.App();
const app = new cdk.App({ context: { '@aws-cdk/aws-rds:lowercaseDbIdentifier': false } });
const stack = testStack(app);
const clusterIdentifier = 'TestClusterIdentifier';
const vpc = ec2.Vpc.fromLookup(stack, 'VPC', { isDefault: true });
Expand Down
16 changes: 8 additions & 8 deletions packages/@aws-cdk/core/test/stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ describe('stack', () => {

test('cross stack references and dependencies work within child stacks (non-nested)', () => {
// GIVEN
const app = new App();
const app = new App({ context: { '@aws-cdk/core:stackRelativeExports': true } });
const parent = new Stack(app, 'Parent');
const child1 = new Stack(parent, 'Child1');
const child2 = new Stack(parent, 'Child2');
Expand Down Expand Up @@ -520,7 +520,7 @@ describe('stack', () => {
Outputs: {
ExportsOutputRefResourceA461B4EF9: {
Value: { Ref: 'ResourceA' },
Export: { Name: 'ParentChild18FAEF419:Child1ExportsOutputRefResourceA7BF20B37' },
Export: { Name: 'ParentChild18FAEF419:ExportsOutputRefResourceA461B4EF9' },
},
},
});
Expand All @@ -529,7 +529,7 @@ describe('stack', () => {
Resource1: {
Type: 'R2',
Properties: {
RefToResource1: { 'Fn::ImportValue': 'ParentChild18FAEF419:Child1ExportsOutputRefResourceA7BF20B37' },
RefToResource1: { 'Fn::ImportValue': 'ParentChild18FAEF419:ExportsOutputRefResourceA461B4EF9' },
},
},
},
Expand All @@ -541,7 +541,7 @@ describe('stack', () => {

test('automatic cross-stack references and manual exports look the same', () => {
// GIVEN: automatic
const appA = new App();
const appA = new App({ context: { '@aws-cdk/core:stackRelativeExports': true } });
const producerA = new Stack(appA, 'Producer');
const consumerA = new Stack(appA, 'Consumer');
const resourceA = new CfnResource(producerA, 'Resource', { type: 'AWS::Resource' });
Expand Down Expand Up @@ -704,7 +704,7 @@ describe('stack', () => {

test('cross-stack reference (parent stack references substack)', () => {
// GIVEN
const app = new App();
const app = new App({ context: { '@aws-cdk/core:stackRelativeExports': true } });
const parentStack = new Stack(app, 'parent');
const childStack = new Stack(parentStack, 'child');

Expand All @@ -724,7 +724,7 @@ describe('stack', () => {
MyParentResource: {
Type: 'Resource::Parent',
Properties: {
ParentProp: { 'Fn::ImportValue': 'parentchild13F9359B:childExportsOutputFnGetAttMyChildResourceAttributeOfChildResource420052FC' },
ParentProp: { 'Fn::ImportValue': 'parentchild13F9359B:ExportsOutputFnGetAttMyChildResourceAttributeOfChildResource52813264' },
},
},
},
Expand All @@ -735,7 +735,7 @@ describe('stack', () => {
Outputs: {
ExportsOutputFnGetAttMyChildResourceAttributeOfChildResource52813264: {
Value: { 'Fn::GetAtt': ['MyChildResource', 'AttributeOfChildResource'] },
Export: { Name: 'parentchild13F9359B:childExportsOutputFnGetAttMyChildResourceAttributeOfChildResource420052FC' },
Export: { Name: 'parentchild13F9359B:ExportsOutputFnGetAttMyChildResourceAttributeOfChildResource52813264' },
},
},
});
Expand Down Expand Up @@ -1181,4 +1181,4 @@ class StackWithPostProcessor extends Stack {

return template;
}
}
}

0 comments on commit 2edf199

Please sign in to comment.