Skip to content

Commit

Permalink
chore(deadline): address PR feedback
Browse files Browse the repository at this point in the history
- flatten jest test heirarchies
- fix typos
- clarify test name
  • Loading branch information
jusiskin committed Oct 8, 2021
1 parent c2be47e commit 5565a47
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -996,73 +996,65 @@ describe('ConfigureSpotEventPlugin', () => {
groupName = 'group_name1';
});

describe('a fleet without vpcSunbets', () => {
beforeEach(() => {
// GIVEN
fleet = new SpotEventPluginFleet(stack, 'SpotFleet', {
vpc,
renderQueue: renderQueue,
deadlineGroups: [
groupName,
],
instanceTypes: [
InstanceType.of(InstanceClass.T2, InstanceSize.SMALL),
],
workerMachineImage,
maxCapacity: 1,
});

// WHEN
new ConfigureSpotEventPlugin(stack, 'ConfigureSpotEventPlugin', {
renderQueue,
vpc,
spotFleets: [fleet],
});
test('a fleet without vpcSubnets specified => warns about dedicated subnets', () => {
// GIVEN
fleet = new SpotEventPluginFleet(stack, 'SpotFleet', {
vpc,
renderQueue: renderQueue,
deadlineGroups: [
groupName,
],
instanceTypes: [
InstanceType.of(InstanceClass.T2, InstanceSize.SMALL),
],
workerMachineImage,
maxCapacity: 1,
});

test('warns about dedicated subnets', () => {
// THEN
expect(fleet.node.metadataEntry).toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: 'Deadline Secrets Management is enabled on the Repository and VPC subnets have not been supplied. Using dedicated subnets is recommended. See https://github.com/aws/aws-rfdk/blobs/release/packages/aws-rfdk/lib/deadline/README.md#using-dedicated-subnets-for-deadline-components',
}));
// WHEN
new ConfigureSpotEventPlugin(stack, 'ConfigureSpotEventPlugin', {
renderQueue,
vpc,
spotFleets: [fleet],
});

// THEN
expect(fleet.node.metadataEntry).toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: 'Deadline Secrets Management is enabled on the Repository and VPC subnets have not been supplied. Using dedicated subnets is recommended. See https://github.com/aws/aws-rfdk/blobs/release/packages/aws-rfdk/lib/deadline/README.md#using-dedicated-subnets-for-deadline-components',
}));
});

describe('a fleet with subnets specified', () => {
beforeEach(() => {
// GIVEN
fleet = new SpotEventPluginFleet(stack, 'SpotFleetWithSubnets', {
vpc,
vpcSubnets: {
subnetType: SubnetType.PRIVATE,
},
renderQueue: renderQueue,
deadlineGroups: [
groupName,
],
instanceTypes: [
InstanceType.of(InstanceClass.T2, InstanceSize.SMALL),
],
workerMachineImage,
maxCapacity: 1,
});
test('a fleet with vpcSubnets specified => does not warn about dedicated subnets', () => {
// GIVEN
fleet = new SpotEventPluginFleet(stack, 'SpotFleetWithSubnets', {
vpc,
vpcSubnets: {
subnetType: SubnetType.PRIVATE,
},
renderQueue: renderQueue,
deadlineGroups: [
groupName,
],
instanceTypes: [
InstanceType.of(InstanceClass.T2, InstanceSize.SMALL),
],
workerMachineImage,
maxCapacity: 1,
});

// WHEN
new ConfigureSpotEventPlugin(stack, 'ConfigureSpotEventPlugin', {
renderQueue,
vpc,
spotFleets: [fleet],
});
// WHEN
new ConfigureSpotEventPlugin(stack, 'ConfigureSpotEventPlugin', {
renderQueue,
vpc,
spotFleets: [fleet],
});

// THEN
test('does not warn about dedicated subnets', () => {
expect(fleet.node.metadataEntry).not.toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: expect.stringMatching(/dedicated subnet/i),
}));
});
expect(fleet.node.metadataEntry).not.toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: expect.stringMatching(/dedicated subnet/i),
}));
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ describe('SecretsManagementIdentityRegistration', () => {
expect(resolvedCalls).toContainEqual(expectedCall);
});

test('warns about dedicated subnets when ALB and source subnets match', () => {
test('warns about dedicated subnets when render queue ALB and source subnets match', () => {
// GIVEN
createTarget();
const dependent = new Construct(stack, 'Dependent');
Expand Down
54 changes: 22 additions & 32 deletions packages/aws-rfdk/lib/deadline/test/usage-based-licensing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,43 +121,33 @@ describe('UsageBasedLicensing', () => {
});
}

describe('vpcSubnets', () => {
describe('specified', () => {
let ubl: UsageBasedLicensing;

// WHEN
beforeEach(() => {
ubl = createUbl({
vpcSubnets: {
subnetType: SubnetType.PRIVATE,
},
});
});
test('vpcSubnets specified => does not emit warnings', () => {
// GIVEN
const vpcSubnets: SubnetSelection = {
subnetType: SubnetType.PRIVATE,
};

// THEN
test('does not emit warnings', () => {
expect(ubl.node.metadataEntry).not.toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
}));
});
// WHEN
const ubl = createUbl({
vpcSubnets,
});

describe('not specified', () => {
let ubl: UsageBasedLicensing;
// THEN
expect(ubl.node.metadataEntry).not.toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: expect.stringMatching(/dedicated subnet/i),
}));
});

// WHEN
beforeEach(() => {
ubl = createUbl();
});
test('vpcSubnets not specified => emits warning about dedicated subnets', () => {
// WHEN
const ubl = createUbl();

// THEN
test('emits warning about dedicated subnets', () => {
expect(ubl.node.metadataEntry).toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: 'Deadline Secrets Management is enabled on the Repository and VPC subnets have not been supplied. Using dedicated subnets is recommended. See https://github.com/aws/aws-rfdk/blobs/release/packages/aws-rfdk/lib/deadline/README.md#using-dedicated-subnets-for-deadline-components',
}));
});
});
// THEN
expect(ubl.node.metadataEntry).toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: 'Deadline Secrets Management is enabled on the Repository and VPC subnets have not been supplied. Using dedicated subnets is recommended. See https://github.com/aws/aws-rfdk/blobs/release/packages/aws-rfdk/lib/deadline/README.md#using-dedicated-subnets-for-deadline-components',
}));
});

describe('configures auto registration', () => {
Expand Down
47 changes: 17 additions & 30 deletions packages/aws-rfdk/lib/deadline/test/worker-fleet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1968,47 +1968,34 @@ describe('secrets management enabled', () => {
props = {
renderQueue,
vpc,
workerMachineImage: new GenericWindowsImage({
}),
workerMachineImage: new GenericWindowsImage({}),
};
});

describe('vpc subnets not specified', () => {
let workerInstanceFleet: WorkerInstanceFleet;

test('vpc subnets not specified => warns about dedicated subnets', () => {
// WHEN
beforeEach(() => {
workerInstanceFleet = new WorkerInstanceFleet(wfstack, 'WorkerInstanceFleet', props);
});
const workerInstanceFleet = new WorkerInstanceFleet(wfstack, 'WorkerInstanceFleet', props);

// THEN
test('warns about dedicated subnets', () => {
expect(workerInstanceFleet.node.metadataEntry).toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: 'Deadline Secrets Management is enabled on the Repository and VPC subnets have not been supplied. Using dedicated subnets is recommended. See https://github.com/aws/aws-rfdk/blobs/release/packages/aws-rfdk/lib/deadline/README.md#using-dedicated-subnets-for-deadline-components',
}));
});
expect(workerInstanceFleet.node.metadataEntry).toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: 'Deadline Secrets Management is enabled on the Repository and VPC subnets have not been supplied. Using dedicated subnets is recommended. See https://github.com/aws/aws-rfdk/blobs/release/packages/aws-rfdk/lib/deadline/README.md#using-dedicated-subnets-for-deadline-components',
}));
});

describe('vpc subnets specified', () => {
let workerInstanceFleet: WorkerInstanceFleet;

test('vpc subnets specified => does not emit dedicated subnets warning', () => {
// WHEN
beforeEach(() => {
workerInstanceFleet = new WorkerInstanceFleet(wfstack, 'WorkerInstanceFleet', {
...props,
vpcSubnets: {
subnetType: SubnetType.PRIVATE,
},
});
const workerInstanceFleet = new WorkerInstanceFleet(wfstack, 'WorkerInstanceFleet', {
...props,
vpcSubnets: {
subnetType: SubnetType.PRIVATE,
},
});

// THEN
test('does not emit dedicated subnets warning', () => {
expect(workerInstanceFleet.node.metadataEntry).not.toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: expect.stringMatching(/dedicated subnet/i),
}));
});
expect(workerInstanceFleet.node.metadataEntry).not.toContainEqual(expect.objectContaining({
type: 'aws:cdk:warning',
data: expect.stringMatching(/dedicated subnet/i),
}));
});
});

0 comments on commit 5565a47

Please sign in to comment.