From a1cead9db8e1a03987db92660e3ee0ee34d31100 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Thu, 11 Jun 2026 01:06:56 -0700 Subject: [PATCH 1/3] fix(cmd): respect LifecycleSupportEndDate in extended-support check isInExtendedSupport parsed both lifecycle dates but only compared the start date, so engine versions past the official end of extended support stayed classified as in-extended-support and remained excluded from RI count sizing, causing systematic under-purchase for those instance types. Now a version counts as in extended support only when the current time is on or after the start date and before the end date; a zero end date is treated as open-ended. Also replaces the bare lifecycle-name string literal with the SDK enum constant. Adds regression test cases for a past end date (failing before this fix) and for the open-ended zero end date. Closes #1182 --- cmd/multi_service_engine_versions.go | 16 +++++++--- cmd/multi_service_engine_versions_test.go | 37 +++++++++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/cmd/multi_service_engine_versions.go b/cmd/multi_service_engine_versions.go index 22f9d5e08..2f6a80350 100644 --- a/cmd/multi_service_engine_versions.go +++ b/cmd/multi_service_engine_versions.go @@ -399,11 +399,17 @@ func isInExtendedSupport(engine, fullVersion string, versionInfo map[string]Majo // Check if current date falls within extended support period now := time.Now() for _, lifecycle := range info.SupportedEngineLifecycles { - if lifecycle.LifecycleSupportName == "open-source-rds-extended-support" { - // Check if we're past the start date of extended support - if now.After(lifecycle.LifecycleSupportStartDate) || now.Equal(lifecycle.LifecycleSupportStartDate) { - return true - } + if lifecycle.LifecycleSupportName != string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport) { + continue + } + // Not in extended support before its start date + if now.Before(lifecycle.LifecycleSupportStartDate) { + continue + } + // Past the end date means extended support is over; a zero end date + // is open-ended (issue #1182) + if lifecycle.LifecycleSupportEndDate.IsZero() || now.Before(lifecycle.LifecycleSupportEndDate) { + return true } } diff --git a/cmd/multi_service_engine_versions_test.go b/cmd/multi_service_engine_versions_test.go index d4f45fcfa..7b51a6611 100644 --- a/cmd/multi_service_engine_versions_test.go +++ b/cmd/multi_service_engine_versions_test.go @@ -603,6 +603,43 @@ func TestIsInExtendedSupport(t *testing.T) { }, expected: true, }, + { + name: "Extended support already ended", + engine: "mysql", + version: "5.7.44", + versionInfo: map[string]MajorEngineVersionInfo{ + "mysql:5.7": { + Engine: "mysql", + MajorEngineVersion: "5.7", + SupportedEngineLifecycles: []EngineLifecycleInfo{ + { + LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportStartDate: now.AddDate(-3, 0, 0), + LifecycleSupportEndDate: pastDate, + }, + }, + }, + }, + expected: false, + }, + { + name: "Zero end date treated as open-ended", + engine: "mysql", + version: "5.7.44", + versionInfo: map[string]MajorEngineVersionInfo{ + "mysql:5.7": { + Engine: "mysql", + MajorEngineVersion: "5.7", + SupportedEngineLifecycles: []EngineLifecycleInfo{ + { + LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportStartDate: pastDate, + }, + }, + }, + }, + expected: true, + }, { name: "Engine name normalization with spaces", engine: "Aurora MySQL", From a068c3ce6463854f9f8647ef971175353b4a95a6 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Sat, 20 Jun 2026 00:01:48 +0200 Subject: [PATCH 2/3] refactor(cmd): use SDK enum constants for LifecycleSupportName in tests Replace bare string literals with typed rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport and rdstypes.LifecycleSupportNameOpenSourceRdsStandardSupport constants so test data cannot drift from the SDK enum values. --- cmd/multi_service_engine_versions_test.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/multi_service_engine_versions_test.go b/cmd/multi_service_engine_versions_test.go index 7b51a6611..499316d3a 100644 --- a/cmd/multi_service_engine_versions_test.go +++ b/cmd/multi_service_engine_versions_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/LeanerCloud/CUDly/pkg/common" + rdstypes "github.com/aws/aws-sdk-go-v2/service/rds/types" "github.com/stretchr/testify/assert" ) @@ -134,7 +135,7 @@ func TestAdjustRecommendationForExcludedVersions(t *testing.T) { MajorEngineVersion: "5.7", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: time.Now().AddDate(0, -6, 0), LifecycleSupportEndDate: time.Now().AddDate(3, 0, 0), }, @@ -213,7 +214,7 @@ func TestAdjustRecommendationForExcludedVersions_MultipleVersionsInExtendedSuppo MajorEngineVersion: "5.6", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: time.Now().AddDate(0, -12, 0), LifecycleSupportEndDate: time.Now().AddDate(2, 0, 0), }, @@ -224,7 +225,7 @@ func TestAdjustRecommendationForExcludedVersions_MultipleVersionsInExtendedSuppo MajorEngineVersion: "5.7", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: time.Now().AddDate(0, -6, 0), LifecycleSupportEndDate: time.Now().AddDate(3, 0, 0), }, @@ -518,7 +519,7 @@ func TestIsInExtendedSupport(t *testing.T) { MajorEngineVersion: "5.7", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: pastDate, LifecycleSupportEndDate: futureDate, }, @@ -537,7 +538,7 @@ func TestIsInExtendedSupport(t *testing.T) { MajorEngineVersion: "8.0", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-standard-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsStandardSupport), LifecycleSupportStartDate: now.AddDate(-2, 0, 0), LifecycleSupportEndDate: futureDate, }, @@ -575,7 +576,7 @@ func TestIsInExtendedSupport(t *testing.T) { MajorEngineVersion: "5.7", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: futureDate, LifecycleSupportEndDate: futureDate.AddDate(1, 0, 0), }, @@ -594,7 +595,7 @@ func TestIsInExtendedSupport(t *testing.T) { MajorEngineVersion: "11.19", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: now, LifecycleSupportEndDate: futureDate, }, @@ -613,7 +614,7 @@ func TestIsInExtendedSupport(t *testing.T) { MajorEngineVersion: "5.7", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: now.AddDate(-3, 0, 0), LifecycleSupportEndDate: pastDate, }, @@ -632,7 +633,7 @@ func TestIsInExtendedSupport(t *testing.T) { MajorEngineVersion: "5.7", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: pastDate, }, }, @@ -650,7 +651,7 @@ func TestIsInExtendedSupport(t *testing.T) { MajorEngineVersion: "5.7", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: pastDate, LifecycleSupportEndDate: futureDate, }, From 2d1cd0740caa2dcde89560b47b0df6fa697bc2c3 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Fri, 26 Jun 2026 18:47:35 +0200 Subject: [PATCH 3/3] refactor(cmd): use SDK enum constants in remaining lifecycle tests The previous commit migrated multi_service_engine_versions_test.go to use rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport instead of the bare "open-source-rds-extended-support" string literal. Three sibling test files in cmd/ still hard-coded the same strings, so a future SDK enum rename would have left them out of sync. Migrate all remaining occurrences in: - cmd/multi_service_coverage_test.go (3 sites) - cmd/multi_service_test.go (3 sites) - cmd/multi_service_engine_versions_paginate_test.go (1 site, typed directly because the SDK struct exposes the enum type, not string) No production behaviour changes; tests still pass (`go test ./cmd/...`). --- cmd/multi_service_coverage_test.go | 6 +++--- cmd/multi_service_engine_versions_paginate_test.go | 2 +- cmd/multi_service_test.go | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/multi_service_coverage_test.go b/cmd/multi_service_coverage_test.go index 88afdc988..1de248cc4 100644 --- a/cmd/multi_service_coverage_test.go +++ b/cmd/multi_service_coverage_test.go @@ -246,7 +246,7 @@ func TestIsInExtendedSupport_EdgeCases(t *testing.T) { MajorEngineVersion: "5.7", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: pastDate, LifecycleSupportEndDate: futureDate, }, @@ -257,7 +257,7 @@ func TestIsInExtendedSupport_EdgeCases(t *testing.T) { MajorEngineVersion: "8.0", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-standard-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsStandardSupport), LifecycleSupportStartDate: now.AddDate(-2, 0, 0), LifecycleSupportEndDate: futureDate, }, @@ -318,7 +318,7 @@ func TestAdjustRecommendationForExcludedVersions_AdditionalCases(t *testing.T) { MajorEngineVersion: "5.7", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: pastDate, LifecycleSupportEndDate: futureDate, }, diff --git a/cmd/multi_service_engine_versions_paginate_test.go b/cmd/multi_service_engine_versions_paginate_test.go index 9dd6eccec..c8ad2296a 100644 --- a/cmd/multi_service_engine_versions_paginate_test.go +++ b/cmd/multi_service_engine_versions_paginate_test.go @@ -51,7 +51,7 @@ func rdsMajorVersion(engine, major string) rdstypes.DBMajorEngineVersion { //nol MajorEngineVersion: aws.String(major), SupportedEngineLifecycles: []rdstypes.SupportedEngineLifecycle{ { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport, LifecycleSupportStartDate: aws.Time(time.Now().AddDate(-1, 0, 0)), LifecycleSupportEndDate: aws.Time(time.Now().AddDate(2, 0, 0)), }, diff --git a/cmd/multi_service_test.go b/cmd/multi_service_test.go index d487ffe8c..3c5b5257a 100644 --- a/cmd/multi_service_test.go +++ b/cmd/multi_service_test.go @@ -12,6 +12,7 @@ import ( "github.com/LeanerCloud/CUDly/pkg/common" "github.com/aws/aws-sdk-go-v2/aws" + rdstypes "github.com/aws/aws-sdk-go-v2/service/rds/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -1828,12 +1829,12 @@ func createTestVersionInfo() map[string]MajorEngineVersionInfo { MajorEngineVersion: "5.7", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-standard-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsStandardSupport), LifecycleSupportStartDate: now.AddDate(-5, 0, 0), LifecycleSupportEndDate: pastDate, }, { - LifecycleSupportName: "open-source-rds-extended-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsExtendedSupport), LifecycleSupportStartDate: pastDate, LifecycleSupportEndDate: futureDate, }, @@ -1844,7 +1845,7 @@ func createTestVersionInfo() map[string]MajorEngineVersionInfo { MajorEngineVersion: "8.0", SupportedEngineLifecycles: []EngineLifecycleInfo{ { - LifecycleSupportName: "open-source-rds-standard-support", + LifecycleSupportName: string(rdstypes.LifecycleSupportNameOpenSourceRdsStandardSupport), LifecycleSupportStartDate: now.AddDate(-2, 0, 0), LifecycleSupportEndDate: futureDate, },