Skip to content

Commit

Permalink
test: add base component tests (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Miradorn committed Feb 5, 2021
1 parent bded87f commit c683657
Showing 1 changed file with 66 additions and 15 deletions.
81 changes: 66 additions & 15 deletions test/constructs/super-eks.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect as expectCDK, haveResource, ResourcePart, stringLike, arrayWith, haveResourceLike, ABSENT } from '@aws-cdk/assert';
import '@aws-cdk/assert/jest';
import { ABSENT, arrayWith, ResourcePart, stringLike } from '@aws-cdk/assert';
import * as route53 from '@aws-cdk/aws-route53';
import * as cdk from '@aws-cdk/core';

Expand All @@ -15,7 +16,7 @@ test('Empty Cluster', () => {
});

// THEN
expectCDK(stack).to(haveResource('Custom::AWSCDK-EKS-Cluster'));
expect(stack).toHaveResource('Custom::AWSCDK-EKS-Cluster');
});

test('It installs managed VPC CNI Addon', () => {
Expand All @@ -29,26 +30,76 @@ test('It installs managed VPC CNI Addon', () => {
});

// THEN
expectCDK(stack).to(haveResourceLike('Custom::AWS', {
expect(stack).toHaveResourceLike('Custom::AWS', {
Create: {
service: 'EKS',
action: 'createAddon',
parameters: {
addonName: 'vpc-cni',
},
},
}));
});

// Default NodeGroup can be found by specifying abscense of `NodegroupName`
expectCDK(stack).to(
haveResourceLike('AWS::EKS::Nodegroup', {
Properties: { NodegroupName: ABSENT },
DependsOn: arrayWith(stringLike('*VpcCniAddonManagedAddon*')),
}, ResourcePart.CompleteDefinition));

expectCDK(stack).to(
haveResourceLike('AWS::EKS::Nodegroup', {
Properties: { NodegroupName: 'super-eks' },
DependsOn: arrayWith(stringLike('*VpcCniAddonManagedAddon*')),
}, ResourcePart.CompleteDefinition));

expect(stack).toHaveResourceLike('AWS::EKS::Nodegroup', {
Properties: { NodegroupName: ABSENT },
DependsOn: arrayWith(stringLike('*VpcCniAddonManagedAddon*')),
}, ResourcePart.CompleteDefinition);

expect(stack).toHaveResourceLike('AWS::EKS::Nodegroup', {
Properties: { NodegroupName: 'super-eks' },
DependsOn: arrayWith(stringLike('*VpcCniAddonManagedAddon*')),
}, ResourcePart.CompleteDefinition);
});

test('It installs fluent-bit', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack', {
env: { region: 'eu-central-1', account: '1234567891011' },
});
// WHEN
new SuperEks(stack, 'TestCluster', {
hostedZone: route53.HostedZone.fromHostedZoneId(stack, 'HostedZone', '123'),
});

// THEN
expect(stack).toHaveResource('Custom::AWSCDK-EKS-HelmChart', {
Namespace: 'logging',
Chart: 'aws-for-fluent-bit',
});
});

test('It installs aws-load-balancer-controller', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack', {
env: { region: 'eu-central-1', account: '1234567891011' },
});
// WHEN
new SuperEks(stack, 'TestCluster', {
hostedZone: route53.HostedZone.fromHostedZoneId(stack, 'HostedZone', '123'),
});

// THEN
expect(stack).toHaveResource('Custom::AWSCDK-EKS-HelmChart', {
Namespace: 'ingress',
Chart: 'aws-load-balancer-controller',
});
});

test('It installs external-dns', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack', {
env: { region: 'eu-central-1', account: '1234567891011' },
});
// WHEN
new SuperEks(stack, 'TestCluster', {
hostedZone: route53.HostedZone.fromHostedZoneId(stack, 'HostedZone', '123'),
});

// THEN
expect(stack).toHaveResource('Custom::AWSCDK-EKS-HelmChart', {
Namespace: 'dns',
Chart: 'external-dns',
});
});

0 comments on commit c683657

Please sign in to comment.