1
1
import { strictEqual } from 'assert' ;
2
- import { expect as expectCDK , haveResource , ResourcePart } from '@aws-cdk/assert-internal ' ;
2
+ import { Template } from '@aws-cdk/assertions ' ;
3
3
import { ISubnet , Port , SecurityGroup , Subnet , Vpc } from '@aws-cdk/aws-ec2' ;
4
4
import { Key } from '@aws-cdk/aws-kms' ;
5
5
import { Aws , Stack , Token } from '@aws-cdk/core' ;
@@ -35,15 +35,15 @@ describe('FSx for Lustre File System', () => {
35
35
vpcSubnet,
36
36
} ) ;
37
37
38
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' ) ) ;
39
- expectCDK ( stack ) . to ( haveResource ( 'AWS::EC2::SecurityGroup' ) ) ;
38
+ Template . fromStack ( stack ) . hasResource ( 'AWS::FSx::FileSystem' , { } ) ;
39
+ Template . fromStack ( stack ) . hasResource ( 'AWS::EC2::SecurityGroup' , { } ) ;
40
40
strictEqual (
41
41
fileSystem . dnsName ,
42
42
`${ fileSystem . fileSystemId } .fsx.${ stack . region } .${ Aws . URL_SUFFIX } ` ) ;
43
43
44
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
44
+ Template . fromStack ( stack ) . hasResource ( 'AWS::FSx::FileSystem' , {
45
45
DeletionPolicy : 'Retain' ,
46
- } , ResourcePart . CompleteDefinition ) ) ;
46
+ } ) ;
47
47
} ) ;
48
48
49
49
test ( 'file system is created correctly when security group is provided' , ( ) => {
@@ -63,8 +63,8 @@ describe('FSx for Lustre File System', () => {
63
63
vpcSubnet,
64
64
} ) ;
65
65
66
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' ) ) ;
67
- expectCDK ( stack ) . to ( haveResource ( 'AWS::EC2::SecurityGroup' ) ) ;
66
+ Template . fromStack ( stack ) . hasResource ( 'AWS::FSx::FileSystem' , { } ) ;
67
+ Template . fromStack ( stack ) . hasResource ( 'AWS::EC2::SecurityGroup' , { } ) ;
68
68
} ) ;
69
69
70
70
test ( 'encrypted file system is created correctly with custom KMS' , ( ) => {
@@ -88,11 +88,11 @@ describe('FSx for Lustre File System', () => {
88
88
* in generated CDK, hence hardcoding the MD5 hash here for assertion. Assumption is that the path of the Key wont
89
89
* change in this UT. Checked the unique id by generating the cloud formation stack.
90
90
*/
91
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
91
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::FSx::FileSystem' , {
92
92
KmsKeyId : {
93
93
Ref : 'customKeyFSDDB87C6D' ,
94
94
} ,
95
- } ) ) ;
95
+ } ) ;
96
96
} ) ;
97
97
98
98
test ( 'file system is created correctly when weekly maintenance time is provided' , ( ) => {
@@ -118,13 +118,13 @@ describe('FSx for Lustre File System', () => {
118
118
vpcSubnet,
119
119
} ) ;
120
120
121
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
121
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::FSx::FileSystem' , {
122
122
LustreConfiguration : {
123
123
DeploymentType : 'SCRATCH_2' ,
124
124
WeeklyMaintenanceStartTime : '7:12:34' ,
125
125
} ,
126
- } ) ) ;
127
- expectCDK ( stack ) . to ( haveResource ( 'AWS::EC2::SecurityGroup' ) ) ;
126
+ } ) ;
127
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::EC2::SecurityGroup' , { } ) ;
128
128
} ) ;
129
129
130
130
describe ( 'when validating props' , ( ) => {
@@ -145,13 +145,13 @@ describe('FSx for Lustre File System', () => {
145
145
vpcSubnet,
146
146
} ) ;
147
147
148
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
148
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::FSx::FileSystem' , {
149
149
LustreConfiguration : {
150
150
DeploymentType : LustreDeploymentType . SCRATCH_2 ,
151
151
ExportPath : exportPath ,
152
152
ImportPath : importPath ,
153
153
} ,
154
- } ) ) ;
154
+ } ) ;
155
155
} ) ;
156
156
157
157
test ( 'export and import paths are Tokens' , ( ) => {
@@ -172,13 +172,13 @@ describe('FSx for Lustre File System', () => {
172
172
vpcSubnet,
173
173
} ) ;
174
174
175
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
175
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::FSx::FileSystem' , {
176
176
LustreConfiguration : {
177
177
DeploymentType : LustreDeploymentType . SCRATCH_2 ,
178
178
ExportPath : exportPathResolved ,
179
179
ImportPath : importPathResolved ,
180
180
} ,
181
- } ) ) ;
181
+ } ) ;
182
182
} ) ;
183
183
184
184
test ( 'only export path is Token' , ( ) => {
@@ -299,12 +299,12 @@ describe('FSx for Lustre File System', () => {
299
299
vpcSubnet,
300
300
} ) ;
301
301
302
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
302
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::FSx::FileSystem' , {
303
303
LustreConfiguration : {
304
304
DeploymentType : LustreDeploymentType . SCRATCH_2 ,
305
305
ImportedFileChunkSize : size ,
306
306
} ,
307
- } ) ) ;
307
+ } ) ;
308
308
} ) ;
309
309
310
310
test . each ( [
@@ -342,12 +342,12 @@ describe('FSx for Lustre File System', () => {
342
342
vpcSubnet,
343
343
} ) ;
344
344
345
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
345
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::FSx::FileSystem' , {
346
346
LustreConfiguration : {
347
347
DeploymentType : LustreDeploymentType . SCRATCH_2 ,
348
348
ImportPath : importPath ,
349
349
} ,
350
- } ) ) ;
350
+ } ) ;
351
351
} ) ;
352
352
353
353
test ( 'import path is Token' , ( ) => {
@@ -364,12 +364,12 @@ describe('FSx for Lustre File System', () => {
364
364
vpcSubnet,
365
365
} ) ;
366
366
367
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
367
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::FSx::FileSystem' , {
368
368
LustreConfiguration : {
369
369
DeploymentType : LustreDeploymentType . SCRATCH_2 ,
370
370
ImportPath : importPathResolved ,
371
371
} ,
372
- } ) ) ;
372
+ } ) ;
373
373
} ) ;
374
374
375
375
test ( 'invalid import path format' , ( ) => {
@@ -428,12 +428,12 @@ describe('FSx for Lustre File System', () => {
428
428
vpcSubnet,
429
429
} ) ;
430
430
431
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
431
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::FSx::FileSystem' , {
432
432
LustreConfiguration : {
433
433
DeploymentType : LustreDeploymentType . PERSISTENT_1 ,
434
434
PerUnitStorageThroughput : throughput ,
435
435
} ,
436
- } ) ) ;
436
+ } ) ;
437
437
} ) ;
438
438
439
439
test ( 'invalid perUnitStorageThroughput' , ( ) => {
@@ -489,12 +489,12 @@ describe('FSx for Lustre File System', () => {
489
489
vpcSubnet,
490
490
} ) ;
491
491
492
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
492
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::FSx::FileSystem' , {
493
493
LustreConfiguration : {
494
494
DeploymentType : deploymentType ,
495
495
} ,
496
496
StorageCapacity : value ,
497
- } ) ) ;
497
+ } ) ;
498
498
} ) ;
499
499
500
500
test . each ( [
@@ -529,12 +529,12 @@ describe('FSx for Lustre File System', () => {
529
529
vpcSubnet,
530
530
} ) ;
531
531
532
- expectCDK ( stack ) . to ( haveResource ( 'AWS::FSx::FileSystem' , {
532
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::FSx::FileSystem' , {
533
533
LustreConfiguration : {
534
534
DeploymentType : LustreDeploymentType . SCRATCH_1 ,
535
535
} ,
536
536
StorageCapacity : validValue ,
537
- } ) ) ;
537
+ } ) ;
538
538
} ) ;
539
539
540
540
test . each ( [ 1 , 3601 ] ) ( 'invalid value of %d for storage capacity with SCRATCH_1' , ( invalidValue : number ) => {
@@ -566,8 +566,8 @@ describe('FSx for Lustre File System', () => {
566
566
567
567
fs . connections . allowToAnyIpv4 ( Port . tcp ( 443 ) ) ;
568
568
569
- expectCDK ( stack ) . to ( haveResource ( 'AWS::EC2::SecurityGroupEgress' , {
569
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::EC2::SecurityGroupEgress' , {
570
570
GroupId : 'sg-123456789' ,
571
- } ) ) ;
571
+ } ) ;
572
572
} ) ;
573
573
} ) ;
0 commit comments