Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scheduler-targets-alpha): incorrect validation of maximumEventAge #32284

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-scheduler-targets-alpha/lib/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ export abstract class ScheduleTargetBase {

private renderRetryPolicy(maximumEventAge: Duration | undefined, maximumRetryAttempts: number | undefined): CfnSchedule.RetryPolicyProperty {
const maxMaxAge = Duration.days(1).toSeconds();
const minMaxAge = Duration.minutes(15).toSeconds();
const minMaxAge = Duration.minutes(1).toSeconds();
let maxAge: number = maxMaxAge;
if (maximumEventAge) {
maxAge = maximumEventAge.toSeconds({ integral: true });
if (maxAge > maxMaxAge) {
throw new Error('Maximum event age is 1 day');
}
if (maxAge < minMaxAge) {
throw new Error('Minimum event age is 15 minutes');
throw new Error('Minimum event age is 1 minute');
}
};
let maxAttempts = 185;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,16 @@ describe('codebuild start build', () => {
})).toThrow(/Maximum event age is 1 day/);
});

test('throws when retry policy max age is less than 15 minutes', () => {
test('throws when retry policy max age is less than 1 minute', () => {
const codebuildProjectTarget = new CodeBuildStartBuild(codebuildProject, {
maxEventAge: Duration.minutes(5),
maxEventAge: Duration.seconds(59),
});

expect(() =>
new Schedule(stack, 'MyScheduleDummy', {
schedule: expr,
target: codebuildProjectTarget,
})).toThrow(/Minimum event age is 15 minutes/);
})).toThrow(/Minimum event age is 1 minute/);
});

test('throws when retry policy max retry attempts is out of the allowed limits', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,16 @@ describe('codepipeline start execution', () => {
})).toThrow(/Maximum event age is 1 day/);
});

test('throws when retry policy max age is less than 15 minutes', () => {
test('throws when retry policy max age is less than 1 minute', () => {
const codepipelineTarget = new CodePipelineStartPipelineExecution(codepipeline, {
maxEventAge: Duration.minutes(5),
maxEventAge: Duration.seconds(59),
});

expect(() =>
new Schedule(stack, 'MyScheduleDummy', {
schedule: expr,
target: codepipelineTarget,
})).toThrow(/Minimum event age is 15 minutes/);
})).toThrow(/Minimum event age is 1 minute/);
});

test('throws when retry policy max retry attempts is out of the allowed limits', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,16 +587,16 @@ describe('eventBridge put events', () => {
})).toThrow(/Maximum event age is 1 day/);
});

test('throws when retry policy max age is less than 15 minutes', () => {
test('throws when retry policy max age is less than 1 minute', () => {
const eventBusTarget = new EventBridgePutEvents(eventBusEventEntry, {
maxEventAge: Duration.minutes(5),
maxEventAge: Duration.seconds(59),
});

expect(() =>
new Schedule(stack, 'MyScheduleDummy', {
schedule: expr,
target: eventBusTarget,
})).toThrow(/Minimum event age is 15 minutes/);
})).toThrow(/Minimum event age is 1 minute/);
});

test('throws when retry policy max retry attempts is out of the allowed limits', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,16 +508,16 @@ describe('schedule target', () => {
})).toThrow(/Maximum event age is 1 day/);
});

test('throws when retry policy max age is less than 15 minutes', () => {
test('throws when retry policy max age is less than 1 minute', () => {
const inspectorTarget = new InspectorStartAssessmentRun(template, {
maxEventAge: Duration.minutes(5),
maxEventAge: Duration.seconds(59),
});

expect(() =>
new Schedule(stack, 'MyScheduleDummy', {
schedule: expr,
target: inspectorTarget,
})).toThrow(/Minimum event age is 15 minutes/);
})).toThrow(/Minimum event age is 1 minute/);
});

test('throws when retry policy max retry attempts is out of the allowed limits', () => {
Expand Down
Loading
Loading