Skip to content

Commit

Permalink
Revision 4: Modify error messages and unit test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthsalot committed Jan 27, 2022
1 parent a00efcd commit 2d0a33a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-fsx/lib/lustre-file-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,18 @@ export class LustreFileSystem extends FileSystemBase {
if (perUnitStorageThroughput === undefined) { return; }

if (deploymentType !== LustreDeploymentType.PERSISTENT_1 && deploymentType !== LustreDeploymentType.PERSISTENT_2) {
throw new Error('perUnitStorageThroughput can only be set for the PERSISTENT_1/PERSISTENT_2 deployment types');
throw new Error('perUnitStorageThroughput can only be set for the PERSISTENT_1/PERSISTENT_2 deployment types, received: ' + deploymentType);
}

if (deploymentType === LustreDeploymentType.PERSISTENT_1) {
if (![50, 100, 200].includes(perUnitStorageThroughput)) {
throw new Error('perUnitStorageThroughput must be 50, 100, or 200 MB/s/TiB');
throw new Error('perUnitStorageThroughput must be 50, 100, or 200 MB/s/TiB for PERSISTENT_1 deployment type, got: ' + perUnitStorageThroughput);
}
}

if (deploymentType === LustreDeploymentType.PERSISTENT_2) {
if (![125, 250, 500, 1000].includes(perUnitStorageThroughput)) {
throw new Error('perUnitStorageThroughput must be 125, 250, 500 or 1000 MB/s/TiB');
throw new Error('perUnitStorageThroughput must be 125, 250, 500 or 1000 MB/s/TiB for PERSISTENT_2 deployment type, got: ' + perUnitStorageThroughput);
}
}
}
Expand Down
40 changes: 18 additions & 22 deletions packages/@aws-cdk/aws-fsx/test/lustre-file-system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,16 @@ describe('FSx for Lustre File System', () => {
});
});

test('invalid perUnitStorageThroughput', () => {
test.each([
1,
125,
250,
500,
1000,
])('invalid perUnitStorageThroughput', (invalidValue: number) => {
lustreConfiguration = {
deploymentType: LustreDeploymentType.PERSISTENT_1,
perUnitStorageThroughput: 1,
perUnitStorageThroughput: invalidValue,
};

expect(() => {
Expand All @@ -449,7 +455,7 @@ describe('FSx for Lustre File System', () => {
vpc,
vpcSubnet,
});
}).toThrowError('perUnitStorageThroughput must be 50, 100, or 200 MB/s/TiB');
}).toThrowError('perUnitStorageThroughput must be 50, 100, or 200 MB/s/TiB for PERSISTENT_1 deployment type, got: ' + invalidValue);
});

test('setting perUnitStorageThroughput on wrong deploymentType', () => {
Expand Down Expand Up @@ -496,26 +502,16 @@ describe('FSx for Lustre File System', () => {
});
});

test('invalid perUnitStorageThroughput', () => {
test.each([
1,
50,
100,
200,
550,
])('invalid perUnitStorageThroughput', (invalidValue: number) => {
lustreConfiguration = {
deploymentType: LustreDeploymentType.PERSISTENT_2,
perUnitStorageThroughput: 1,
};

expect(() => {
new LustreFileSystem(stack, 'FsxFileSystem', {
lustreConfiguration,
storageCapacityGiB: storageCapacity,
vpc,
vpcSubnet,
});
}).toThrowError('perUnitStorageThroughput must be 125, 250, 500 or 1000 MB/s/TiB');
});

test('setting perUnitStorageThroughput on wrong deploymentType', () => {
lustreConfiguration = {
deploymentType: LustreDeploymentType.SCRATCH_2,
perUnitStorageThroughput: 125,
perUnitStorageThroughput: invalidValue,
};

expect(() => {
Expand All @@ -525,7 +521,7 @@ describe('FSx for Lustre File System', () => {
vpc,
vpcSubnet,
});
}).toThrowError('perUnitStorageThroughput can only be set for the PERSISTENT_1/PERSISTENT_2 deployment types');
}).toThrowError('perUnitStorageThroughput must be 125, 250, 500 or 1000 MB/s/TiB for PERSISTENT_2 deployment type, got: ' + invalidValue);
});
});

Expand Down

0 comments on commit 2d0a33a

Please sign in to comment.