From 6375b3e73ceab1ed6872022e5f27dc37f679db66 Mon Sep 17 00:00:00 2001 From: Michael Sambol Date: Fri, 8 Mar 2024 09:56:02 -0600 Subject: [PATCH] add edge case test --- .../test/alb/target-group.test.ts | 20 +++++++++++++++++++ .../test/nlb/target-group.test.ts | 20 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/target-group.test.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/target-group.test.ts index 518b3b6808bf6..7e30c3db10ecb 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/target-group.test.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/target-group.test.ts @@ -568,6 +568,26 @@ describe('tests', () => { }).toThrow('Health check interval must be greater than or equal to the timeout; received interval 10, timeout 20.'); }); + // for backwards compatibility these can be equal, see discussion in https://github.com/aws/aws-cdk/pull/26031 + test('Throws error for health check interval less than timeout', () => { + const app = new cdk.App(); + const stack = new cdk.Stack(app, 'Stack'); + const vpc = new ec2.Vpc(stack, 'Vpc'); + + new elbv2.ApplicationTargetGroup(stack, 'TargetGroup', { + vpc, + port: 80, + healthCheck: { + interval: cdk.Duration.seconds(10), + timeout: cdk.Duration.seconds(20), + }, + }); + + expect(() => { + app.synth(); + }).toThrow('Health check interval must be greater than or equal to the timeout; received interval 10, timeout 20.'); + }); + test('imported targetGroup has targetGroupName', () => { // GIVEN const app = new cdk.App(); diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/nlb/target-group.test.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/nlb/target-group.test.ts index 930d5a98e82d3..786b13b6c9302 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/nlb/target-group.test.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/nlb/target-group.test.ts @@ -163,6 +163,26 @@ describe('tests', () => { }).toThrow('Health check interval must be greater than or equal to the timeout; received interval 10, timeout 20.'); }); + // for backwards compatibility these can be equal, see discussion in https://github.com/aws/aws-cdk/pull/26031 + test('No error for health check interval == timeout', () => { + const app = new cdk.App(); + const stack = new cdk.Stack(app, 'Stack'); + const vpc = new ec2.Vpc(stack, 'Vpc'); + + new elbv2.NetworkTargetGroup(stack, 'Group', { + vpc, + port: 80, + healthCheck: { + interval: cdk.Duration.seconds(10), + timeout: cdk.Duration.seconds(10), + }, + }); + + expect(() => { + app.synth(); + }).not.toThrow(); + }); + test('targetGroupName unallowed: more than 32 characters', () => { // GIVEN const app = new cdk.App();