From 551b69795944c5ae88ec5224ae4a5f1c36e96f8e Mon Sep 17 00:00:00 2001 From: Kaizen Conroy Date: Thu, 27 Oct 2022 14:56:13 -0400 Subject: [PATCH] chore(eks): remove whitespace, fix typos, stylistic updates --- packages/@aws-cdk/aws-eks/README.md | 7 +- packages/@aws-cdk/aws-eks/lib/cluster.ts | 6 +- .../aws-eks/test/alb-controller.test.ts | 6 -- .../@aws-cdk/aws-eks/test/awsauth.test.ts | 15 +--- .../test/cluster-resource-provider.test.ts | 48 +----------- .../@aws-cdk/aws-eks/test/cluster.test.ts | 49 +----------- .../test/fargate-resource-provider.test.ts | 16 ---- .../@aws-cdk/aws-eks/test/fargate.test.ts | 15 ---- .../@aws-cdk/aws-eks/test/helm-chart.test.ts | 15 +++- .../aws-eks/test/k8s-manifest.test.ts | 15 ---- .../aws-eks/test/k8s-object-value.test.ts | 4 - .../@aws-cdk/aws-eks/test/k8s-patch.test.ts | 6 +- .../@aws-cdk/aws-eks/test/nodegroup.test.ts | 75 +++++++------------ .../aws-eks/test/service-account.test.ts | 15 ++-- .../@aws-cdk/aws-eks/test/user-data.test.ts | 11 --- 15 files changed, 67 insertions(+), 236 deletions(-) diff --git a/packages/@aws-cdk/aws-eks/README.md b/packages/@aws-cdk/aws-eks/README.md index 54e63e5e4bd2c..be7aab79647a1 100644 --- a/packages/@aws-cdk/aws-eks/README.md +++ b/packages/@aws-cdk/aws-eks/README.md @@ -676,7 +676,11 @@ The kubectl handler uses `kubectl`, `helm` and the `aws` CLI in order to interact with the cluster. These are bundled into AWS Lambda layers included in the `@aws-cdk/lambda-layer-awscli` and `@aws-cdk/lambda-layer-kubectl` modules. -The version of kubectl used must be compatible wtih the Kubernetes version of the cluster. kubectl is supported within one minor version (older or newer) of Kubernetes (see [Kubernetes version skew policy](https://kubernetes.io/releases/version-skew-policy/#kubectl)). Only version 1.20 of kubectl is available in `aws-cdk-lib`. If you need a different version, you will need to use one of the `@aws-cdk/lambda-layer-kubectlvXY` packages. +The version of kubectl used must be compatible with the Kubernetes version of the +cluster. kubectl is supported within one minor version (older or newer) of Kubernetes +(see [Kubernetes version skew policy](https://kubernetes.io/releases/version-skew-policy/#kubectl)). +Only version 1.20 of kubectl is available in `aws-cdk-lib`. If you need a different +version, you will need to use one of the `@aws-cdk/lambda-layer-kubectlvXY` packages. ```ts import { KubectlV22Layer } from '@aws-cdk/lambda-layer-kubectl-v22'; @@ -685,7 +689,6 @@ const cluster = new eks.Cluster(this, 'hello-eks', { version: eks.KubernetesVersion.V1_22, kubectlLayer: new KubectlV22Layer(this, 'kubectl'), }); - ``` You can also specify a custom `lambda.LayerVersion` if you wish to use a diff --git a/packages/@aws-cdk/aws-eks/lib/cluster.ts b/packages/@aws-cdk/aws-eks/lib/cluster.ts index 21e7c1475c432..10cce065e8082 100644 --- a/packages/@aws-cdk/aws-eks/lib/cluster.ts +++ b/packages/@aws-cdk/aws-eks/lib/cluster.ts @@ -2300,7 +2300,7 @@ export enum CoreDnsComputeType { /** * Deploy CoreDNS on Fargate-managed instances. */ - FARGATE = 'fargate' + FARGATE = 'fargate', } /** @@ -2314,7 +2314,7 @@ export enum DefaultCapacityType { /** * EC2 autoscaling group */ - EC2 + EC2, } /** @@ -2328,7 +2328,7 @@ export enum MachineImageType { /** * Bottlerocket AMI */ - BOTTLEROCKET + BOTTLEROCKET, } function nodeTypeForInstanceType(instanceType: ec2.InstanceType) { diff --git a/packages/@aws-cdk/aws-eks/test/alb-controller.test.ts b/packages/@aws-cdk/aws-eks/test/alb-controller.test.ts index db5403acc4483..8297ad9340e0e 100644 --- a/packages/@aws-cdk/aws-eks/test/alb-controller.test.ts +++ b/packages/@aws-cdk/aws-eks/test/alb-controller.test.ts @@ -6,7 +6,6 @@ import { Cluster, KubernetesVersion, AlbController, AlbControllerVersion, HelmCh import { testFixture } from './util'; test('all vended policies are valid', () => { - const addOnsDir = path.join(__dirname, '..', 'lib', 'addons'); for (const addOn of fs.readdirSync(addOnsDir)) { @@ -23,11 +22,9 @@ test('all vended policies are valid', () => { } } } - }); test('can configure a custom repository', () => { - const { stack } = testFixture(); const cluster = new Cluster(stack, 'Cluster', { @@ -58,11 +55,9 @@ test('can configure a custom repository', () => { ], }, }); - }); test('throws when a policy is not defined for a custom version', () => { - const { stack } = testFixture(); const cluster = new Cluster(stack, 'Cluster', { @@ -73,5 +68,4 @@ test('throws when a policy is not defined for a custom version', () => { cluster, version: AlbControllerVersion.of('custom'), })).toThrowError("'albControllerOptions.policy' is required when using a custom controller version"); - }); diff --git a/packages/@aws-cdk/aws-eks/test/awsauth.test.ts b/packages/@aws-cdk/aws-eks/test/awsauth.test.ts index c141965738084..7ace3fa8d6f97 100644 --- a/packages/@aws-cdk/aws-eks/test/awsauth.test.ts +++ b/packages/@aws-cdk/aws-eks/test/awsauth.test.ts @@ -10,9 +10,7 @@ import { testFixtureNoVpc } from './util'; const CLUSTER_VERSION = KubernetesVersion.V1_16; describe('aws auth', () => { - test('throws when adding a role from a different stack', () => { - const app = new cdk.App(); const clusterStack = new cdk.Stack(app, 'ClusterStack'); const roleStack = new cdk.Stack(app, 'RoleStack'); @@ -26,12 +24,9 @@ describe('aws auth', () => { }).toThrow( 'RoleStack/Role should be defined in the scope of the ClusterStack stack to prevent circular dependencies', ); - - }); test('throws when adding a user from a different stack', () => { - const app = new cdk.App(); const clusterStack = new cdk.Stack(app, 'ClusterStack'); const userStack = new cdk.Stack(app, 'UserStack'); @@ -45,8 +40,6 @@ describe('aws auth', () => { }).toThrow( 'UserStack/User should be defined in the scope of the ClusterStack stack to prevent circular dependencies', ); - - }); test('empty aws-auth', () => { @@ -66,7 +59,6 @@ describe('aws auth', () => { data: { mapRoles: '[]', mapUsers: '[]', mapAccounts: '[]' }, }]), }); - }); test('addRoleMapping and addUserMapping can be used to define the aws-auth ConfigMap', () => { @@ -159,8 +151,6 @@ describe('aws auth', () => { ], }, }); - - }); test('imported users and roles can be also be used', () => { @@ -222,9 +212,8 @@ describe('aws auth', () => { ], }, }); - - }); + test('addMastersRole after addNodegroup correctly', () => { // GIVEN const { stack } = testFixtureNoVpc(); @@ -283,7 +272,5 @@ describe('aws auth', () => { ], }, }); - - }); }); diff --git a/packages/@aws-cdk/aws-eks/test/cluster-resource-provider.test.ts b/packages/@aws-cdk/aws-eks/test/cluster-resource-provider.test.ts index d7d7789bde0a5..5bec15aaed2d8 100644 --- a/packages/@aws-cdk/aws-eks/test/cluster-resource-provider.test.ts +++ b/packages/@aws-cdk/aws-eks/test/cluster-resource-provider.test.ts @@ -4,7 +4,6 @@ import * as mocks from './cluster-resource-handler-mocks'; describe('cluster resource provider', () => { beforeEach(() => { mocks.reset(); - }); describe('create', () => { @@ -25,8 +24,6 @@ describe('cluster resource provider', () => { }, name: 'MyResourceId-fakerequestid', }); - - }); test('generated cluster name does not exceed 100 characters', async () => { @@ -53,7 +50,6 @@ describe('cluster resource provider', () => { // THEN expect(mocks.actualRequest.createClusterRequest?.name.length).toEqual(100); expect(mocks.actualRequest.createClusterRequest?.name).toEqual('hellohellohellohellohellohellohellohellohellohellohellohellohellohe-602c078a6181435296764f00352445aa'); - }); test('onCreate: explicit cluster name', async () => { @@ -64,7 +60,6 @@ describe('cluster resource provider', () => { await handler.onEvent(); expect(mocks.actualRequest.createClusterRequest!.name).toEqual('ExplicitCustomName'); - }); test('with no specific version', async () => { @@ -75,7 +70,6 @@ describe('cluster resource provider', () => { await handler.onEvent(); expect(mocks.actualRequest.createClusterRequest!.version).toEqual('12.34.56'); - }); test('isCreateComplete still not complete if cluster is not ACTIVE', async () => { @@ -84,21 +78,18 @@ describe('cluster resource provider', () => { const resp = await handler.isComplete(); expect(mocks.actualRequest.describeClusterRequest!.name).toEqual('physical-resource-id'); expect(resp).toEqual({ IsComplete: false }); - }); test('isCreateComplete throws if cluster is FAILED', async () => { const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Create')); mocks.simulateResponse.describeClusterResponseMockStatus = 'FAILED'; await expect(handler.isComplete()).rejects.toThrow('Cluster is in a FAILED status'); - }); test('isUpdateComplete throws if cluster is FAILED', async () => { const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Update')); mocks.simulateResponse.describeClusterResponseMockStatus = 'FAILED'; await expect(handler.isComplete()).rejects.toThrow('Cluster is in a FAILED status'); - }); test('isCreateComplete is complete when cluster is ACTIVE', async () => { @@ -118,7 +109,6 @@ describe('cluster resource provider', () => { OpenIdConnectIssuer: '', }, }); - }); test('encryption config', async () => { @@ -138,10 +128,7 @@ describe('cluster resource provider', () => { encryptionConfig: [{ provider: { keyArn: 'aws:kms:key' }, resources: ['secrets'] }], name: 'MyResourceId-fakerequestid', }); - - }); - }); describe('delete', () => { @@ -150,14 +137,12 @@ describe('cluster resource provider', () => { const resp = await handler.onEvent(); expect(mocks.actualRequest.deleteClusterRequest!.name).toEqual('physical-resource-id'); expect(resp).toEqual({ PhysicalResourceId: 'physical-resource-id' }); - }); test('onDelete ignores ResourceNotFoundException', async () => { const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Delete')); mocks.simulateResponse.deleteClusterErrorCode = 'ResourceNotFoundException'; await handler.onEvent(); - }); test('isDeleteComplete returns false as long as describeCluster succeeds', async () => { @@ -165,7 +150,6 @@ describe('cluster resource provider', () => { const resp = await handler.isComplete(); expect(mocks.actualRequest.describeClusterRequest!.name).toEqual('physical-resource-id'); expect(resp.IsComplete).toEqual(false); - }); test('isDeleteComplete returns true when describeCluster throws a ResourceNotFound exception', async () => { @@ -173,7 +157,6 @@ describe('cluster resource provider', () => { mocks.simulateResponse.describeClusterExceptionCode = 'ResourceNotFoundException'; const resp = await handler.isComplete(); expect(resp.IsComplete).toEqual(true); - }); test('isDeleteComplete propagates other errors', async () => { @@ -186,12 +169,10 @@ describe('cluster resource provider', () => { error = e; } expect(error.code).toEqual('OtherException'); - }); }); describe('update', () => { - test('no change', async () => { const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Update', mocks.MOCK_PROPS, mocks.MOCK_PROPS)); const resp = await handler.onEvent(); @@ -199,7 +180,6 @@ describe('cluster resource provider', () => { expect(mocks.actualRequest.createClusterRequest).toEqual(undefined); expect(mocks.actualRequest.updateClusterConfigRequest).toEqual(undefined); expect(mocks.actualRequest.updateClusterVersionRequest).toEqual(undefined); - }); test('isUpdateComplete is not complete when status is not ACTIVE', async () => { @@ -207,7 +187,6 @@ describe('cluster resource provider', () => { mocks.simulateResponse.describeClusterResponseMockStatus = 'UPDATING'; const resp = await handler.isComplete(); expect(resp.IsComplete).toEqual(false); - }); test('isUpdateComplete waits for ACTIVE', async () => { @@ -215,13 +194,10 @@ describe('cluster resource provider', () => { mocks.simulateResponse.describeClusterResponseMockStatus = 'ACTIVE'; const resp = await handler.isComplete(); expect(resp.IsComplete).toEqual(true); - }); describe('requires replacement', () => { - describe('name change', () => { - test('explicit name change', async () => { // GIVEN const req = mocks.newRequest('Update', { @@ -246,7 +222,6 @@ describe('cluster resource provider', () => { }, }); expect(resp).toEqual({ PhysicalResourceId: 'new-cluster-name-1234' }); - }); test('from auto-gen name to explicit name', async () => { @@ -274,9 +249,7 @@ describe('cluster resource provider', () => { }, }); expect(resp).toEqual({ PhysicalResourceId: 'MyResourceId-fakerequestid' }); - }); - }); test('subnets or security groups requires a replacement', async () => { @@ -305,7 +278,6 @@ describe('cluster resource provider', () => { securityGroupIds: ['sg1'], }, }); - }); test('"roleArn" requires a replacement', async () => { @@ -321,7 +293,6 @@ describe('cluster resource provider', () => { name: 'MyResourceId-fakerequestid', roleArn: 'new-arn', }); - }); test('fails if cluster has an explicit "name" that is the same as the old "name"', async () => { @@ -343,7 +314,6 @@ describe('cluster resource provider', () => { } expect(err?.message).toEqual('Cannot replace cluster "explicit-cluster-name" since it has an explicit physical name. Either rename the cluster or remove the "name" configuration'); - }); test('succeeds if cluster had an explicit "name" and now it does not', async () => { @@ -365,7 +335,6 @@ describe('cluster resource provider', () => { name: 'MyResourceId-fakerequestid', roleArn: 'new-arn', }); - }); test('succeeds if cluster had an explicit "name" and now it has a different name', async () => { @@ -387,7 +356,6 @@ describe('cluster resource provider', () => { name: 'new-explicit-cluster-name', roleArn: 'new-arn', }); - }); }); @@ -410,11 +378,9 @@ describe('cluster resource provider', () => { // THEN expect(error).toBeDefined(); expect(error.message).toEqual('Cannot update cluster encryption configuration'); - }); describe('isUpdateComplete with EKS update ID', () => { - test('with "Failed" status', async () => { const event = mocks.newRequest('Update'); const isCompleteHandler = new ClusterResourceHandler(mocks.client, { @@ -442,7 +408,6 @@ describe('cluster resource provider', () => { expect(error).toBeDefined(); expect(mocks.actualRequest.describeUpdateRequest).toEqual({ name: 'physical-resource-id', updateId: 'foobar' }); expect(error.message).toEqual('cluster update id "foobar" failed with errors: [{"errorMessage":"errorMessageMock","errorCode":"errorCodeMock","resourceIds":["foo","bar"]}]'); - }); test('with "InProgress" status, returns IsComplete=false', async () => { @@ -458,7 +423,6 @@ describe('cluster resource provider', () => { expect(mocks.actualRequest.describeUpdateRequest).toEqual({ name: 'physical-resource-id', updateId: 'foobar' }); expect(response.IsComplete).toEqual(false); - }); test('with "Successful" status, returns IsComplete=true with "Data"', async () => { @@ -486,13 +450,10 @@ describe('cluster resource provider', () => { OpenIdConnectIssuer: '', }, }); - }); - }); describe('in-place', () => { - describe('version change', () => { test('from undefined to a specific value', async () => { const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Update', { @@ -507,7 +468,6 @@ describe('cluster resource provider', () => { version: '12.34', }); expect(mocks.actualRequest.createClusterRequest).toEqual(undefined); - }); test('from a specific value to another value', async () => { @@ -524,7 +484,6 @@ describe('cluster resource provider', () => { version: '2.0', }); expect(mocks.actualRequest.createClusterRequest).toEqual(undefined); - }); test('to a new value that is already the current version', async () => { @@ -536,7 +495,6 @@ describe('cluster resource provider', () => { expect(mocks.actualRequest.describeClusterRequest).toEqual({ name: 'physical-resource-id' }); expect(mocks.actualRequest.updateClusterVersionRequest).toEqual(undefined); expect(mocks.actualRequest.createClusterRequest).toEqual(undefined); - }); test('fails from specific value to undefined', async () => { @@ -553,7 +511,6 @@ describe('cluster resource provider', () => { } expect(error.message).toEqual('Cannot remove cluster version configuration. Current version is 1.2'); - }); }); @@ -585,7 +542,6 @@ describe('cluster resource provider', () => { }, }); expect(mocks.actualRequest.createClusterRequest).toEqual(undefined); - }); test('from partial vpc configuration to only private access enabled', async () => { @@ -611,7 +567,6 @@ describe('cluster resource provider', () => { }, }); expect(mocks.actualRequest.createClusterRequest).toEqual(undefined); - }); test('from undefined to both logging and access fully enabled', async () => { @@ -653,9 +608,8 @@ describe('cluster resource provider', () => { }, }); expect(mocks.actualRequest.createClusterRequest).toEqual(undefined); - }); }); }); }); -}); \ No newline at end of file +}); diff --git a/packages/@aws-cdk/aws-eks/test/cluster.test.ts b/packages/@aws-cdk/aws-eks/test/cluster.test.ts index 1bef808c75547..39bc1c1ac9d6f 100644 --- a/packages/@aws-cdk/aws-eks/test/cluster.test.ts +++ b/packages/@aws-cdk/aws-eks/test/cluster.test.ts @@ -21,7 +21,6 @@ import { testFixture, testFixtureNoVpc } from './util'; const CLUSTER_VERSION = eks.KubernetesVersion.V1_21; describe('cluster', () => { - test('can configure and access ALB controller', () => { const { stack } = testFixture(); @@ -39,7 +38,6 @@ describe('cluster', () => { }); test('can specify custom environment to cluster resource handler', () => { - const { stack } = testFixture(); new eks.Cluster(stack, 'Cluster', { @@ -164,7 +162,6 @@ describe('cluster', () => { }); test('throws when accessing cluster security group for imported cluster without cluster security group id', () => { - const { stack } = testFixture(); const cluster = eks.Cluster.fromClusterAttributes(stack, 'Cluster', { @@ -175,7 +172,6 @@ describe('cluster', () => { }); test('can place cluster handlers in the cluster vpc', () => { - const { stack } = testFixture(); new eks.Cluster(stack, 'Cluster', { @@ -202,7 +198,6 @@ describe('cluster', () => { }); test('can access cluster security group for imported cluster with cluster security group id', () => { - const { stack } = testFixture(); const clusterSgId = 'cluster-sg-id'; @@ -218,7 +213,6 @@ describe('cluster', () => { }); test('cluster security group is attached when adding self-managed nodes', () => { - // GIVEN const { stack, vpc } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster', { @@ -242,7 +236,6 @@ describe('cluster', () => { }); test('security group of self-managed asg is not tagged with owned', () => { - // GIVEN const { stack, vpc } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster', { @@ -262,7 +255,6 @@ describe('cluster', () => { }); test('connect autoscaling group with imported cluster', () => { - // GIVEN const { stack, vpc } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster', { @@ -295,7 +287,6 @@ describe('cluster', () => { }); test('cluster security group is attached when connecting self-managed nodes', () => { - // GIVEN const { stack, vpc } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster', { @@ -323,7 +314,6 @@ describe('cluster', () => { }); test('spot interrupt handler is not added if spotInterruptHandler is false when connecting self-managed nodes', () => { - // GIVEN const { stack, vpc } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster', { @@ -347,7 +337,6 @@ describe('cluster', () => { }); test('throws when a non cdk8s chart construct is added as cdk8s chart', () => { - const { stack } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster', { @@ -362,7 +351,6 @@ describe('cluster', () => { }); test('throws when a core construct is added as cdk8s chart', () => { - const { stack } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster', { @@ -377,7 +365,6 @@ describe('cluster', () => { }); test('cdk8s chart can be added to cluster', () => { - const { stack } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster', { @@ -419,7 +406,6 @@ describe('cluster', () => { }); test('cluster connections include both control plane and cluster security group', () => { - const { stack } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster', { @@ -434,7 +420,6 @@ describe('cluster', () => { }); test('can declare a security group from a different stack', () => { - class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; @@ -450,7 +435,6 @@ describe('cluster', () => { } class NetworkStack extends cdk.Stack { - public readonly securityGroup: ec2.ISecurityGroup; public readonly vpc: ec2.IVpc; @@ -459,7 +443,6 @@ describe('cluster', () => { this.vpc = new ec2.Vpc(this, 'Vpc'); this.securityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', { vpc: this.vpc }); } - } const { app } = testFixture(); @@ -471,7 +454,6 @@ describe('cluster', () => { }); test('can declare a manifest with a token from a different stack than the cluster that depends on the cluster stack', () => { - class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; @@ -521,7 +503,6 @@ describe('cluster', () => { }); test('can declare a chart with a token from a different stack than the cluster that depends on the cluster stack', () => { - class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; @@ -562,7 +543,6 @@ describe('cluster', () => { }); test('can declare a HelmChart in a different stack than the cluster', () => { - class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; @@ -594,7 +574,6 @@ describe('cluster', () => { }); test('throws when declaring an ASG role in a different stack than the cluster', () => { - class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; @@ -638,7 +617,6 @@ describe('cluster', () => { }); test('can declare a ServiceAccount in a different stack than the cluster', () => { - class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; @@ -724,7 +702,6 @@ describe('cluster', () => { }); describe('default capacity', () => { - test('x2 m5.large by default', () => { // GIVEN const { stack } = testFixtureNoVpc(); @@ -956,7 +933,6 @@ describe('cluster', () => { }); test('import cluster with existing kubectl provider function', () => { - const { stack } = testFixture(); const handlerRole = iam.Role.fromRoleArn(stack, 'HandlerRole', 'arn:aws:iam::123456789012:role/lambda-role'); @@ -1083,7 +1059,6 @@ describe('cluster', () => { }); test('import cluster with new kubectl private subnets', () => { - const { stack, vpc } = testFixture(); const cluster = eks.Cluster.fromClusterAttributes(stack, 'Cluster', { @@ -1446,7 +1421,6 @@ describe('cluster', () => { }); describe('boostrap user-data', () => { - test('rendered by default for ASGs', () => { // GIVEN const { app, stack } = testFixtureNoVpc(); @@ -1728,7 +1702,6 @@ describe('cluster', () => { Template.fromStack(stack).hasResourceProperties('AWS::EKS::Nodegroup', { AmiType: 'AL2_ARM_64', }); - }); test('addAutoScalingGroupCapacity with C7g instance type comes with nodegroup with correct AmiType', () => { @@ -1751,7 +1724,6 @@ describe('cluster', () => { ([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') && (v as any).Default.includes('amazon-linux-2-arm64/'), )).toEqual(true); - }); test('EKS-Optimized AMI with GPU support when addAutoScalingGroupCapacity', () => { @@ -2069,7 +2041,6 @@ describe('cluster', () => { }); // THEN - const providerStack = stack.node.tryFindChild('@aws-cdk/aws-eks.KubectlProvider') as cdk.NestedStack; Template.fromStack(providerStack).hasResourceProperties('AWS::IAM::Policy', { PolicyDocument: { @@ -2335,7 +2306,6 @@ describe('cluster', () => { }); test('kubectl provider passes security group to provider', () => { - const { stack } = testFixture(); new eks.Cluster(stack, 'Cluster1', { @@ -2357,7 +2327,6 @@ describe('cluster', () => { }); test('kubectl provider passes environment to lambda', () => { - const { stack } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster1', { @@ -2393,7 +2362,6 @@ describe('cluster', () => { describe('kubectl provider passes iam role environment to kube ctl lambda', ()=>{ test('new cluster', () => { - const { stack } = testFixture(); const kubectlRole = new iam.Role(stack, 'KubectlIamRole', { @@ -2429,7 +2397,6 @@ describe('cluster', () => { }); test('imported cluster', ()=> { - const clusterName = 'my-cluster'; const stack = new cdk.Stack(); const kubectlLambdaRole = new iam.Role(stack, 'KubectlLambdaRole', { @@ -2462,8 +2429,8 @@ describe('cluster', () => { }); }); }); - describe('endpoint access', () => { + describe('endpoint access', () => { test('public restricted', () => { expect(() => { eks.EndpointAccess.PUBLIC.onlyFrom('1.2.3.4/32'); @@ -2490,7 +2457,6 @@ describe('cluster', () => { }); test('public non restricted with private subnets', () => { - const { stack } = testFixture(); new eks.Cluster(stack, 'Cluster', { @@ -2522,7 +2488,6 @@ describe('cluster', () => { }); test('private with private subnets', () => { - const { stack } = testFixture(); new eks.Cluster(stack, 'Cluster', { @@ -2605,7 +2570,6 @@ describe('cluster', () => { }); test('private endpoint access selects only private subnets from looked up vpc', () => { - const vpcId = 'vpc-12345'; // can't use the regular fixture because it also adds a VPC to the stack, which prevents // us from setting context. @@ -2663,7 +2627,6 @@ describe('cluster', () => { }); test('private endpoint access selects only private subnets from looked up vpc with concrete subnet selection', () => { - const vpcId = 'vpc-12345'; // can't use the regular fixture because it also adds a VPC to the stack, which prevents // us from setting context. @@ -2673,6 +2636,7 @@ describe('cluster', () => { region: 'us-east-1', }, }); + stack.node.setContext(`vpc-provider:account=${stack.account}:filter.vpc-id=${vpcId}:region=${stack.region}:returnAsymmetricSubnets=true`, { vpcId: vpcId, vpcCidrBlock: '10.0.0.0/16', @@ -2703,6 +2667,7 @@ describe('cluster', () => { }, ], }); + const vpc = ec2.Vpc.fromLookup(stack, 'Vpc', { vpcId: vpcId, }); @@ -2727,7 +2692,6 @@ describe('cluster', () => { }); test('private endpoint access selects only private subnets from managed vpc with concrete subnet selection', () => { - const { stack } = testFixture(); const vpc = new ec2.Vpc(stack, 'Vpc'); @@ -2790,7 +2754,6 @@ describe('cluster', () => { }); test('kubectl provider chooses only private subnets', () => { - const { stack } = testFixture(); const vpc = new ec2.Vpc(stack, 'Vpc', { @@ -2848,7 +2811,6 @@ describe('cluster', () => { }); test('kubectl provider limits number of subnets to 16', () => { - const { stack } = testFixture(); const subnetConfiguration: ec2.SubnetConfiguration[] = []; @@ -2897,7 +2859,6 @@ describe('cluster', () => { }); test('kubectl provider considers vpc subnet selection', () => { - const { stack } = testFixture(); const subnetConfiguration: ec2.SubnetConfiguration[] = []; @@ -2968,7 +2929,6 @@ describe('cluster', () => { }); test('throw when private access is configured without dns support enabled for the VPC', () => { - const { stack } = testFixture(); expect(() => { @@ -2983,7 +2943,6 @@ describe('cluster', () => { }); test('throw when private access is configured without dns hostnames enabled for the VPC', () => { - const { stack } = testFixture(); expect(() => { @@ -2998,7 +2957,6 @@ describe('cluster', () => { }); test('throw when cidrs are configured without public access endpoint', () => { - expect(() => { eks.EndpointAccess.PRIVATE.onlyFrom('1.2.3.4/5'); }).toThrow(/CIDR blocks can only be configured when public access is enabled/); @@ -3006,7 +2964,6 @@ describe('cluster', () => { }); test('getServiceLoadBalancerAddress', () => { - const { stack } = testFixture(); const cluster = new eks.Cluster(stack, 'Cluster1', { version: CLUSTER_VERSION, prune: false }); diff --git a/packages/@aws-cdk/aws-eks/test/fargate-resource-provider.test.ts b/packages/@aws-cdk/aws-eks/test/fargate-resource-provider.test.ts index e0e8b72cfc735..45dcb2c85457e 100644 --- a/packages/@aws-cdk/aws-eks/test/fargate-resource-provider.test.ts +++ b/packages/@aws-cdk/aws-eks/test/fargate-resource-provider.test.ts @@ -27,8 +27,6 @@ describe('fargate resource provider', () => { PhysicalResourceId: 'MockProfileName', Data: { fargateProfileArn: 'MockProfileArn' }, }); - - }); test('respects physical name if provided', async () => { @@ -57,8 +55,6 @@ describe('fargate resource provider', () => { PhysicalResourceId: 'MockProfileName', Data: { fargateProfileArn: 'MockProfileArn' }, }); - - }); test('isComplete returns true if fargate profile is ACTIVE', async () => { @@ -82,7 +78,6 @@ describe('fargate resource provider', () => { }); expect(resp.IsComplete).toEqual(true); - }); test('isComplete returns false as long as fargate profile is CREATING', async () => { @@ -106,7 +101,6 @@ describe('fargate resource provider', () => { }); expect(resp.IsComplete).toEqual(false); - }); test('isComplete throws an exception if the status is CREATE_FAILED', async () => { @@ -136,12 +130,10 @@ describe('fargate resource provider', () => { }); expect(error.message).toEqual('CREATE_FAILED'); - }); }); describe('update', () => { - test('calls createFargateProfile with a new name', async () => { // GIVEN const client = newEksClientMock(); @@ -167,10 +159,7 @@ describe('fargate resource provider', () => { PhysicalResourceId: 'MockProfileName', Data: { fargateProfileArn: 'MockProfileArn' }, }); - - }); - }); describe('delete', () => { @@ -197,7 +186,6 @@ describe('fargate resource provider', () => { }); expect(onEventResponse).toEqual(undefined); - }); test('isComplete returns true when describeFargateProfile throws ResourceNotFoundException', async () => { @@ -223,8 +211,6 @@ describe('fargate resource provider', () => { expect(resp).toEqual({ IsComplete: true, }); - - }); test('isComplete throws an exception if the status is DELETE_FAILED', async () => { @@ -254,9 +240,7 @@ describe('fargate resource provider', () => { }); expect(error.message).toEqual('DELETE_FAILED'); - }); - }); }); diff --git a/packages/@aws-cdk/aws-eks/test/fargate.test.ts b/packages/@aws-cdk/aws-eks/test/fargate.test.ts index e028981ff7bf2..d08b9d0db6a8d 100644 --- a/packages/@aws-cdk/aws-eks/test/fargate.test.ts +++ b/packages/@aws-cdk/aws-eks/test/fargate.test.ts @@ -5,7 +5,6 @@ import * as kms from '@aws-cdk/aws-kms'; import { Stack, Tags } from '@aws-cdk/core'; import * as eks from '../lib'; - const CLUSTER_VERSION = eks.KubernetesVersion.V1_21; describe('fargate', () => { @@ -27,7 +26,6 @@ describe('fargate', () => { selectors: [{ namespace: 'default' }], }, }); - }); test('supports specifying a profile name', () => { @@ -50,7 +48,6 @@ describe('fargate', () => { fargateProfileName: 'MyProfileName', }, }); - }); test('supports custom execution role', () => { @@ -73,7 +70,6 @@ describe('fargate', () => { selectors: [{ namespace: 'default' }], }, }); - }); test('supports tags through aspects', () => { @@ -101,7 +97,6 @@ describe('fargate', () => { }, }, }); - }); test('supports specifying vpc', () => { @@ -129,7 +124,6 @@ describe('fargate', () => { subnets: ['priv1'], }, }); - }); test('fails if there are no selectors or if there are more than 5', () => { @@ -149,7 +143,6 @@ describe('fargate', () => { { namespace: '6' }, ], })); - }); test('FargateCluster creates an EKS cluster fully managed by Fargate', () => { @@ -187,7 +180,6 @@ describe('fargate', () => { ], }, }); - }); test('can create FargateCluster with a custom profile', () => { @@ -221,7 +213,6 @@ describe('fargate', () => { ], }, }); - }); test('custom profile name is "custom" if no custom profile name is provided', () => { @@ -254,7 +245,6 @@ describe('fargate', () => { ], }, }); - }); test('multiple Fargate profiles added to a cluster are processed sequentially', () => { @@ -298,8 +288,6 @@ describe('fargate', () => { 'MyClusterfargateprofileMyProfile1879D501A', ], }); - - }); test('fargate role is added to RBAC', () => { @@ -341,7 +329,6 @@ describe('fargate', () => { ], }, }); - }); test('allow cluster creation role to iam:PassRole on fargate pod execution role', () => { @@ -426,7 +413,6 @@ describe('fargate', () => { ], }, }); - }); test('supports passing secretsEncryptionKey with FargateCluster', () => { @@ -456,7 +442,6 @@ describe('fargate', () => { }], }, }); - }); test('supports cluster logging with FargateCluster', () => { diff --git a/packages/@aws-cdk/aws-eks/test/helm-chart.test.ts b/packages/@aws-cdk/aws-eks/test/helm-chart.test.ts index e9542f9c14484..29fafa7c83866 100644 --- a/packages/@aws-cdk/aws-eks/test/helm-chart.test.ts +++ b/packages/@aws-cdk/aws-eks/test/helm-chart.test.ts @@ -19,6 +19,7 @@ describe('helm chart', () => { // THEN Template.fromStack(stack).hasResourceProperties(eks.HelmChart.RESOURCE_TYPE, { Namespace: 'default' }); }); + test('should have a lowercase default release name', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -31,6 +32,7 @@ describe('helm chart', () => { Release: 'stackmychartff398361', }); }); + test('should throw when chart and chartAsset not specified', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -43,6 +45,7 @@ describe('helm chart', () => { // THEN expect(t).toThrowError(); }); + test('should throw when chart and repository specified', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -62,6 +65,7 @@ describe('helm chart', () => { // THEN expect(t).toThrowError(); }); + test('should throw when chartAsset and version specified', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -81,6 +85,7 @@ describe('helm chart', () => { // THEN expect(t).toThrowError(); }); + test('should handle chart from S3 asset', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -99,6 +104,7 @@ describe('helm chart', () => { }, }); }); + test('should use the last 53 of the default release name', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -114,6 +120,7 @@ describe('helm chart', () => { Release: 'hismostprobablylongerthanfiftythreecharacterscaf15d09', }); }); + test('with values', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -124,6 +131,7 @@ describe('helm chart', () => { // THEN Template.fromStack(stack).hasResourceProperties(eks.HelmChart.RESOURCE_TYPE, { Values: '{"foo":123}' }); }); + test('should support create namespaces by default', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -134,6 +142,7 @@ describe('helm chart', () => { // THEN Template.fromStack(stack).hasResourceProperties(eks.HelmChart.RESOURCE_TYPE, { CreateNamespace: true }); }); + test('should support create namespaces when explicitly specified', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -144,6 +153,7 @@ describe('helm chart', () => { // THEN Template.fromStack(stack).hasResourceProperties(eks.HelmChart.RESOURCE_TYPE, { CreateNamespace: true }); }); + test('should not create namespaces when disabled', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -155,6 +165,7 @@ describe('helm chart', () => { const charts = Template.fromStack(stack).findResources(eks.HelmChart.RESOURCE_TYPE, { CreateNamespace: true }); expect(Object.keys(charts).length).toEqual(0); }); + test('should support waiting until everything is completed before marking release as successful', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -165,6 +176,7 @@ describe('helm chart', () => { // THEN Template.fromStack(stack).hasResourceProperties(eks.HelmChart.RESOURCE_TYPE, { Wait: true }); }); + test('should default to not waiting before marking release as successful', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -175,8 +187,8 @@ describe('helm chart', () => { // THEN const charts = Template.fromStack(stack).findResources(eks.HelmChart.RESOURCE_TYPE, { Wait: true }); expect(Object.keys(charts).length).toEqual(0); - }); + test('should enable waiting when specified', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -187,6 +199,7 @@ describe('helm chart', () => { // THEN Template.fromStack(stack).hasResourceProperties(eks.HelmChart.RESOURCE_TYPE, { Wait: true }); }); + test('should disable waiting when specified as false', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); diff --git a/packages/@aws-cdk/aws-eks/test/k8s-manifest.test.ts b/packages/@aws-cdk/aws-eks/test/k8s-manifest.test.ts index 34b2a47cc6d14..9a62495274d1c 100644 --- a/packages/@aws-cdk/aws-eks/test/k8s-manifest.test.ts +++ b/packages/@aws-cdk/aws-eks/test/k8s-manifest.test.ts @@ -74,7 +74,6 @@ describe('k8s manifest', () => { Template.fromStack(stack).hasResourceProperties(KubernetesManifest.RESOURCE_TYPE, { Manifest: JSON.stringify(manifest), }); - }); test('can be added to an imported cluster with minimal config', () => { @@ -104,8 +103,6 @@ describe('k8s manifest', () => { Namespace: 'default', CreateNamespace: true, }); - - }); test('default child is a CfnResource', () => { @@ -120,7 +117,6 @@ describe('k8s manifest', () => { }); describe('prune labels', () => { - test('base case', () => { // GIVEN const { stack } = testFixtureNoVpc(); @@ -151,8 +147,6 @@ describe('k8s manifest', () => { }]), PruneLabel: 'aws.cdk.eks/prune-c89a5983505f58231ac2a9a86fd82735ccf2308eac', }); - - }); test('multiple resources in the same manifest', () => { @@ -214,8 +208,6 @@ describe('k8s manifest', () => { ]), PruneLabel: 'aws.cdk.eks/prune-c89a5983505f58231ac2a9a86fd82735ccf2308eac', }); - - }); test('different KubernetesManifest resource use different prune labels', () => { @@ -282,8 +274,6 @@ describe('k8s manifest', () => { ]), PruneLabel: 'aws.cdk.eks/prune-c8aff6ac817006dd4d644e9d99b2cdbb8c8cd036d9', }); - - }); test('ignores resources without "kind"', () => { @@ -300,8 +290,6 @@ describe('k8s manifest', () => { Manifest: JSON.stringify([{ malformed: { resource: 'yes' } }]), PruneLabel: 'aws.cdk.eks/prune-c89a5983505f58231ac2a9a86fd82735ccf2308eac', }); - - }); test('ignores entries that are not objects (invalid type)', () => { @@ -317,8 +305,6 @@ describe('k8s manifest', () => { Manifest: JSON.stringify([['foo']]), PruneLabel: 'aws.cdk.eks/prune-c89a5983505f58231ac2a9a86fd82735ccf2308eac', }); - - }); test('no prune labels when "prune" is disabled', () => { @@ -368,7 +354,6 @@ describe('k8s manifest', () => { expect(m1.PruneLabel).toBeFalsy(); expect(m2.PruneLabel).toBeFalsy(); expect(m3.PruneLabel).toEqual('aws.cdk.eks/prune-c8971972440c5bb3661e468e4cb8069f7ee549414c'); - }); }); }); diff --git a/packages/@aws-cdk/aws-eks/test/k8s-object-value.test.ts b/packages/@aws-cdk/aws-eks/test/k8s-object-value.test.ts index 8d29fa19d6471..4e92a07db79a2 100644 --- a/packages/@aws-cdk/aws-eks/test/k8s-object-value.test.ts +++ b/packages/@aws-cdk/aws-eks/test/k8s-object-value.test.ts @@ -5,7 +5,6 @@ import { KubernetesObjectValue } from '../lib/k8s-object-value'; const CLUSTER_VERSION = eks.KubernetesVersion.V1_16; describe('k8s object value', () => { - test('creates the correct custom resource with explicit values for all properties', () => { // GIVEN const stack = new Stack(); @@ -48,7 +47,6 @@ describe('k8s object value', () => { }); expect(stack.resolve(attribute.value)).toEqual({ 'Fn::GetAtt': [expectedCustomResourceId, 'Value'] }); - }); test('creates the correct custom resource with defaults', () => { @@ -90,7 +88,5 @@ describe('k8s object value', () => { }); expect(stack.resolve(attribute.value)).toEqual({ 'Fn::GetAtt': [expectedCustomResourceId, 'Value'] }); - }); - }); diff --git a/packages/@aws-cdk/aws-eks/test/k8s-patch.test.ts b/packages/@aws-cdk/aws-eks/test/k8s-patch.test.ts index f973ce6bb3e38..e10039c0f6f13 100644 --- a/packages/@aws-cdk/aws-eks/test/k8s-patch.test.ts +++ b/packages/@aws-cdk/aws-eks/test/k8s-patch.test.ts @@ -44,9 +44,8 @@ describe('k8s patch', () => { // also make sure a dependency on the barrier is added to the patch construct. expect(patch.node.dependencies.map(d => Names.nodeUniqueId(d.node))).toEqual(['MyClusterKubectlReadyBarrier7547948A']); - - }); + test('defaults to "strategic" patch type if no patchType is specified', () => { // GIVEN const stack = new Stack(); @@ -62,8 +61,8 @@ describe('k8s patch', () => { Template.fromStack(stack).hasResourceProperties('Custom::AWSCDK-EKS-KubernetesPatch', { PatchType: 'strategic', }); - }); + test('uses specified to patch type if specified', () => { // GIVEN const stack = new Stack(); @@ -104,6 +103,5 @@ describe('k8s patch', () => { ResourceName: 'strategicPatchResource', PatchType: 'strategic', }); - }); }); diff --git a/packages/@aws-cdk/aws-eks/test/nodegroup.test.ts b/packages/@aws-cdk/aws-eks/test/nodegroup.test.ts index dd8d0aa1274cd..d77ead9ad8b47 100644 --- a/packages/@aws-cdk/aws-eks/test/nodegroup.test.ts +++ b/packages/@aws-cdk/aws-eks/test/nodegroup.test.ts @@ -11,9 +11,7 @@ import { testFixture } from './util'; const CLUSTER_VERSION = eks.KubernetesVersion.V1_21; describe('node group', () => { - test('default ami type is not applied when launch template is configured', () => { - // GIVEN const { stack, vpc } = testFixture(); @@ -42,11 +40,9 @@ describe('node group', () => { const root = stack.node.root as cdk.App; const stackArtifact = root.synth().getStackByName(stack.stackName); expect(stackArtifact.template.Resources.Nodegroup62B4B2C1.Properties.AmiType).toBeUndefined(); - }); test('explicit ami type is applied even when launch template is configured', () => { - // GIVEN const { stack, vpc } = testFixture(); @@ -75,11 +71,9 @@ describe('node group', () => { const root = stack.node.root as cdk.App; const stackArtifact = root.synth().getStackByName(stack.stackName); expect(stackArtifact.template.Resources.Nodegroup62B4B2C1.Properties.AmiType).toEqual('AL2_x86_64'); - }); test('ami type is taken as is when no instance types are configured', () => { - // GIVEN const { stack, vpc } = testFixture(); @@ -98,7 +92,6 @@ describe('node group', () => { Template.fromStack(stack).hasResourceProperties('AWS::EKS::Nodegroup', { AmiType: 'AL2_x86_64_GPU', }); - }); test('create a default nodegroup correctly', () => { @@ -139,8 +132,6 @@ describe('node group', () => { MinSize: 1, }, }); - - }); test('create a x86_64 bottlerocket nodegroup correctly', () => { @@ -185,9 +176,8 @@ describe('node group', () => { MinSize: 1, }, }); - - }); + test('create a ARM_64 bottlerocket nodegroup correctly', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -231,6 +221,7 @@ describe('node group', () => { }, }); }); + /** * When LaunchTemplate and amiType are undefined and instanceTypes are x86_64 instances, * the amiType should be implicitly set as AL2_x86_64. @@ -258,6 +249,7 @@ describe('node group', () => { AmiType: 'AL2_x86_64', }); }); + /** * When LaunchTemplate and amiType are both undefined and instanceTypes are ARM64 instances, * the amiType should be implicitly set as AL2_ARM_64. @@ -313,6 +305,7 @@ describe('node group', () => { AmiType: 'AL2_x86_64_GPU', }); }); + /** * When LaunchTemplate is undefined, amiType is AL2_x86_64 and instanceTypes are not x86_64, * we should throw an error. @@ -334,6 +327,7 @@ describe('node group', () => { ], })).toThrow(/The specified AMI does not match the instance types architecture, either specify one of AL2_x86_64_GPU or don't specify any/); }); + /** * When LaunchTemplate is undefined, amiType is AL2_ARM_64 and instanceTypes are not ARM_64, * we should throw an error. @@ -377,6 +371,7 @@ describe('node group', () => { ], })).toThrow(/The specified AMI does not match the instance types architecture, either specify one of AL2_x86_64,BOTTLEROCKET_x86_64 or don't specify any/); }); + /** * When LaunchTemplate is defined, amiType is undefined and instanceTypes are GPU instances, * we should deploy correctly. @@ -405,6 +400,7 @@ describe('node group', () => { // THEN expect(ng).not.toHaveProperty('AmiType'); }); + /** * When LaunchTemplate is defined, amiType is undefined and instanceTypes are x86_64 instances, * we should deploy correctly. @@ -433,6 +429,7 @@ describe('node group', () => { // THEN expect(ng).not.toHaveProperty('AmiType'); }); + /** * When LaunchTemplate is defined, amiType is undefined and instanceTypes are ARM_64 instances, * we should deploy correctly. @@ -486,8 +483,8 @@ describe('node group', () => { }); /** - * BOTTLEROCKET_ARM_64 with defined instance types w/o launchTemplateSpec should deploy correctly. - */ + * BOTTLEROCKET_ARM_64 with defined instance types w/o launchTemplateSpec should deploy correctly. + */ test('BOTTLEROCKET_ARM_64 with defined instance types w/o launchTemplateSpec should deploy correctly', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -562,8 +559,8 @@ describe('node group', () => { }, PruneLabel: 'aws.cdk.eks/prune-c82ececabf77e03e3590f2ebe02adba8641d1b3e76', }); - }); + test('create nodegroup correctly with security groups provided', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -595,9 +592,8 @@ describe('node group', () => { ], }, }); - - }); + test('create nodegroup with forceUpdate disabled', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -614,9 +610,8 @@ describe('node group', () => { Template.fromStack(stack).hasResourceProperties('AWS::EKS::Nodegroup', { ForceUpdateEnabled: false, }); - - }); + test('create nodegroup with instanceTypes provided', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -638,9 +633,8 @@ describe('node group', () => { 'm5.large', ], }); - - }); + test('create nodegroup with on-demand capacity type', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -664,9 +658,8 @@ describe('node group', () => { ], CapacityType: 'ON_DEMAND', }); - - }); + test('create nodegroup with spot capacity type', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -695,9 +688,8 @@ describe('node group', () => { ], CapacityType: 'SPOT', }); - - }); + test('create nodegroup with on-demand capacity type and multiple instance types', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -726,9 +718,8 @@ describe('node group', () => { ], CapacityType: 'ON_DEMAND', }); - - }); + testDeprecated('throws when both instanceTypes and instanceType defined', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -749,8 +740,8 @@ describe('node group', () => { ], capacityType: eks.CapacityType.SPOT, })).toThrow(/"instanceType is deprecated, please use "instanceTypes" only/); - }); + test('create nodegroup with neither instanceTypes nor instanceType defined', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -768,9 +759,8 @@ describe('node group', () => { Template.fromStack(stack).hasResourceProperties('AWS::EKS::Nodegroup', { CapacityType: 'SPOT', }); - - }); + test('throws when instanceTypes provided with different CPU architrcture', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -789,8 +779,8 @@ describe('node group', () => { new ec2.InstanceType('m6g.large'), ], })).toThrow(/instanceTypes of different architectures is not allowed/); - }); + test('throws when amiType provided is incorrect', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -809,7 +799,6 @@ describe('node group', () => { // incorrect amiType amiType: eks.NodegroupAmiType.AL2_ARM_64, })).toThrow(/The specified AMI does not match the instance types architecture/); - }); test('remoteAccess without security group provided', () => { @@ -835,8 +824,6 @@ describe('node group', () => { Ec2SshKey: 'foo', }, }); - - }); test('import nodegroup correctly', () => { @@ -865,8 +852,8 @@ describe('node group', () => { }, }, }); - }); + test('addNodegroup correctly', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -905,9 +892,8 @@ describe('node group', () => { MinSize: 1, }, }); - - }); + test('add node group with taints', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -941,9 +927,8 @@ describe('node group', () => { }, ], }); - - }); + test('throws when desiredSize > maxSize', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -954,8 +939,8 @@ describe('node group', () => { }); // THEN expect(() => cluster.addNodegroupCapacity('ng', { desiredSize: 3, maxSize: 2 })).toThrow(/Desired capacity 3 can't be greater than max size 2/); - }); + test('throws when desiredSize < minSize', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -966,8 +951,8 @@ describe('node group', () => { }); // THEN expect(() => cluster.addNodegroupCapacity('ng', { desiredSize: 2, minSize: 3 })).toThrow(/Minimum capacity 3 can't be greater than desired size 2/); - }); + test('can set minSize , maxSize and DesiredSize', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -991,9 +976,8 @@ describe('node group', () => { DesiredSize: 4, }, }); - - }); + test('validation is not performed when using Tokens', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -1017,9 +1001,8 @@ describe('node group', () => { DesiredSize: 20, }, }); - - }); + test('create nodegroup correctly with launch template', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -1063,9 +1046,8 @@ describe('node group', () => { }, }, }); - - }); + test('throws when both diskSize and launch template specified', () => { // GIVEN const { stack, vpc } = testFixture(); @@ -1097,6 +1079,5 @@ describe('node group', () => { version: lt.attrDefaultVersionNumber, }, })).toThrow(/diskSize must be specified within the launch template/); - }); }); diff --git a/packages/@aws-cdk/aws-eks/test/service-account.test.ts b/packages/@aws-cdk/aws-eks/test/service-account.test.ts index eef2a25b9ab79..d64469553ecc3 100644 --- a/packages/@aws-cdk/aws-eks/test/service-account.test.ts +++ b/packages/@aws-cdk/aws-eks/test/service-account.test.ts @@ -62,8 +62,8 @@ describe('service account', () => { Version: '2012-10-17', }, }); - }); + test('it is possible to add annotations and labels', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -127,8 +127,8 @@ describe('service account', () => { Version: '2012-10-17', }, }); - }); + test('should have allow multiple services accounts', () => { // GIVEN const { stack, cluster } = testFixtureCluster(); @@ -161,8 +161,8 @@ describe('service account', () => { ], }, }); - }); + test('should have unique resource name', () => { // GIVEN const { cluster } = testFixtureCluster(); @@ -172,8 +172,8 @@ describe('service account', () => { // THEN expect(() => cluster.addServiceAccount('MyServiceAccount')).toThrow(); - }); + test('addServiceAccount for imported cluster', () => { const { stack } = testFixture(); const oidcProvider = new iam.OpenIdConnectProvider(stack, 'ClusterOpenIdConnectProvider', { @@ -236,7 +236,6 @@ describe('service account', () => { Version: '2012-10-17', }, }); - }); }); @@ -252,6 +251,7 @@ describe('service account', () => { // THEN .toThrowError(RangeError); }); + test('throw error if ends with dot', () => { // GIVEN const { cluster } = testFixtureCluster(); @@ -263,6 +263,7 @@ describe('service account', () => { // THEN .toThrowError(RangeError); }); + test('dot in the name is allowed', () => { // GIVEN const { cluster } = testFixtureCluster(); @@ -276,6 +277,7 @@ describe('service account', () => { // THEN expect(sa.serviceAccountName).toEqual(valueWithDot); }); + test('throw error if name is too long', () => { // GIVEN const { cluster } = testFixtureCluster(); @@ -301,6 +303,7 @@ describe('service account', () => { // THEN .toThrowError(RangeError); }); + test('throw error if ends with dot', () => { // GIVEN const { cluster } = testFixtureCluster(); @@ -312,6 +315,7 @@ describe('service account', () => { // THEN .toThrowError(RangeError); }); + test('throw error if dot is in the name', () => { // GIVEN const { cluster } = testFixtureCluster(); @@ -324,6 +328,7 @@ describe('service account', () => { // THEN .toThrowError(RangeError); }); + test('throw error if name is too long', () => { // GIVEN const { cluster } = testFixtureCluster(); diff --git a/packages/@aws-cdk/aws-eks/test/user-data.test.ts b/packages/@aws-cdk/aws-eks/test/user-data.test.ts index 2e808ed723bca..ddcb2fcd3f647 100644 --- a/packages/@aws-cdk/aws-eks/test/user-data.test.ts +++ b/packages/@aws-cdk/aws-eks/test/user-data.test.ts @@ -125,8 +125,6 @@ describe('user data', () => { ], ], }); - - }); test('--use-max-pods=false', () => { @@ -159,7 +157,6 @@ describe('user data', () => { ], }, ); - }); test('--aws-api-retry-attempts', () => { @@ -192,7 +189,6 @@ describe('user data', () => { ], }, ); - }); test('--dns-cluster-ip', () => { @@ -225,7 +221,6 @@ describe('user data', () => { ], }, ); - }); test('--docker-config-json', () => { @@ -258,7 +253,6 @@ describe('user data', () => { ], }, ); - }); test('--enable-docker-bridge=true', () => { @@ -291,7 +285,6 @@ describe('user data', () => { ], }, ); - }); test('--enable-docker-bridge=false', () => { @@ -324,7 +317,6 @@ describe('user data', () => { ], }, ); - }); test('--kubelet-extra-args', () => { @@ -357,7 +349,6 @@ describe('user data', () => { ], }, ); - }); test('arbitrary additional bootstrap arguments can be passed through "additionalArgs"', () => { @@ -391,7 +382,6 @@ describe('user data', () => { ], }, ); - }); test('if asg has spot instances, the correct label and taint is used', () => { @@ -424,7 +414,6 @@ describe('user data', () => { ], }, ); - }); });