Skip to content

Commit

Permalink
chore(fsx): migrate tests to assertions (#18490)
Browse files Browse the repository at this point in the history
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored Jan 18, 2022
1 parent da5a305 commit 03d388d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-fsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/assert-internal": "0.0.0",
"@aws-cdk/assertions": "0.0.0",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/cdk-integ-tools": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
Expand Down
60 changes: 30 additions & 30 deletions packages/@aws-cdk/aws-fsx/test/lustre-file-system.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { strictEqual } from 'assert';
import { expect as expectCDK, haveResource, ResourcePart } from '@aws-cdk/assert-internal';
import { Template } from '@aws-cdk/assertions';
import { ISubnet, Port, SecurityGroup, Subnet, Vpc } from '@aws-cdk/aws-ec2';
import { Key } from '@aws-cdk/aws-kms';
import { Aws, Stack, Token } from '@aws-cdk/core';
Expand Down Expand Up @@ -35,15 +35,15 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem'));
expectCDK(stack).to(haveResource('AWS::EC2::SecurityGroup'));
Template.fromStack(stack).hasResource('AWS::FSx::FileSystem', {});
Template.fromStack(stack).hasResource('AWS::EC2::SecurityGroup', {});
strictEqual(
fileSystem.dnsName,
`${fileSystem.fileSystemId}.fsx.${stack.region}.${Aws.URL_SUFFIX}`);

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResource('AWS::FSx::FileSystem', {
DeletionPolicy: 'Retain',
}, ResourcePart.CompleteDefinition));
});
});

test('file system is created correctly when security group is provided', () => {
Expand All @@ -63,8 +63,8 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem'));
expectCDK(stack).to(haveResource('AWS::EC2::SecurityGroup'));
Template.fromStack(stack).hasResource('AWS::FSx::FileSystem', {});
Template.fromStack(stack).hasResource('AWS::EC2::SecurityGroup', {});
});

test('encrypted file system is created correctly with custom KMS', () => {
Expand All @@ -88,11 +88,11 @@ describe('FSx for Lustre File System', () => {
* in generated CDK, hence hardcoding the MD5 hash here for assertion. Assumption is that the path of the Key wont
* change in this UT. Checked the unique id by generating the cloud formation stack.
*/
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
KmsKeyId: {
Ref: 'customKeyFSDDB87C6D',
},
}));
});
});

test('file system is created correctly when weekly maintenance time is provided', () => {
Expand All @@ -118,13 +118,13 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
LustreConfiguration: {
DeploymentType: 'SCRATCH_2',
WeeklyMaintenanceStartTime: '7:12:34',
},
}));
expectCDK(stack).to(haveResource('AWS::EC2::SecurityGroup'));
});
Template.fromStack(stack).hasResourceProperties('AWS::EC2::SecurityGroup', {});
});

describe('when validating props', () => {
Expand All @@ -145,13 +145,13 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
LustreConfiguration: {
DeploymentType: LustreDeploymentType.SCRATCH_2,
ExportPath: exportPath,
ImportPath: importPath,
},
}));
});
});

test('export and import paths are Tokens', () => {
Expand All @@ -172,13 +172,13 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
LustreConfiguration: {
DeploymentType: LustreDeploymentType.SCRATCH_2,
ExportPath: exportPathResolved,
ImportPath: importPathResolved,
},
}));
});
});

test('only export path is Token', () => {
Expand Down Expand Up @@ -299,12 +299,12 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
LustreConfiguration: {
DeploymentType: LustreDeploymentType.SCRATCH_2,
ImportedFileChunkSize: size,
},
}));
});
});

test.each([
Expand Down Expand Up @@ -342,12 +342,12 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
LustreConfiguration: {
DeploymentType: LustreDeploymentType.SCRATCH_2,
ImportPath: importPath,
},
}));
});
});

test('import path is Token', () => {
Expand All @@ -364,12 +364,12 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
LustreConfiguration: {
DeploymentType: LustreDeploymentType.SCRATCH_2,
ImportPath: importPathResolved,
},
}));
});
});

test('invalid import path format', () => {
Expand Down Expand Up @@ -428,12 +428,12 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
LustreConfiguration: {
DeploymentType: LustreDeploymentType.PERSISTENT_1,
PerUnitStorageThroughput: throughput,
},
}));
});
});

test('invalid perUnitStorageThroughput', () => {
Expand Down Expand Up @@ -489,12 +489,12 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
LustreConfiguration: {
DeploymentType: deploymentType,
},
StorageCapacity: value,
}));
});
});

test.each([
Expand Down Expand Up @@ -529,12 +529,12 @@ describe('FSx for Lustre File System', () => {
vpcSubnet,
});

expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
LustreConfiguration: {
DeploymentType: LustreDeploymentType.SCRATCH_1,
},
StorageCapacity: validValue,
}));
});
});

test.each([1, 3601])('invalid value of %d for storage capacity with SCRATCH_1', (invalidValue: number) => {
Expand Down Expand Up @@ -566,8 +566,8 @@ describe('FSx for Lustre File System', () => {

fs.connections.allowToAnyIpv4(Port.tcp(443));

expectCDK(stack).to(haveResource('AWS::EC2::SecurityGroupEgress', {
Template.fromStack(stack).hasResourceProperties('AWS::EC2::SecurityGroupEgress', {
GroupId: 'sg-123456789',
}));
});
});
});

0 comments on commit 03d388d

Please sign in to comment.