-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23039 from brenthc/brenthc-rds-version-slice-panic
avoid string slice panic in version check
- Loading branch information
Showing
3 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
resource/aws_rds_cluster: Fix crash when configured `engine_version` string is shorter than the `EngineVersion` string returned from the AWS API | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package rds | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestCompareActualEngineVersion(t *testing.T) { | ||
t.Parallel() | ||
|
||
type testCase struct { | ||
configuredVersion string | ||
actualVersion string | ||
expectedEngineVersion string | ||
expectedEngineVersionActual string | ||
} | ||
tests := map[string]testCase{ | ||
"point version upgrade": { | ||
configuredVersion: "8.0", | ||
actualVersion: "8.0.27", | ||
expectedEngineVersion: "", | ||
expectedEngineVersionActual: "8.0.27", | ||
}, | ||
"minor version upgrade": { | ||
configuredVersion: "8.0", | ||
actualVersion: "8.1.1", | ||
expectedEngineVersion: "8.1.1", | ||
expectedEngineVersionActual: "8.1.1", | ||
}, | ||
"major version upgrade": { | ||
configuredVersion: "8.1", | ||
actualVersion: "9.0.0", | ||
expectedEngineVersion: "9.0.0", | ||
expectedEngineVersionActual: "9.0.0", | ||
}, | ||
"aurora upgrade": { | ||
configuredVersion: "5.7.mysql_aurora.2.07", | ||
actualVersion: "5.7.serverless_mysql_aurora.2.08.3", | ||
expectedEngineVersion: "5.7.serverless_mysql_aurora.2.08.3", | ||
expectedEngineVersionActual: "5.7.serverless_mysql_aurora.2.08.3", | ||
}, | ||
"aurora upgrade - used to crash": { | ||
configuredVersion: "5.7.serverless_mysql_aurora.2.07", | ||
actualVersion: "5.7.mysql_aurora.2.08.3", | ||
expectedEngineVersion: "5.7.mysql_aurora.2.08.3", | ||
expectedEngineVersionActual: "5.7.mysql_aurora.2.08.3", | ||
}, | ||
"oracle": { | ||
configuredVersion: "12.1.0.2.v20", | ||
actualVersion: "19.0.0.0.ru-2021-04.rur-2021-04.r1", | ||
expectedEngineVersion: "19.0.0.0.ru-2021-04.rur-2021-04.r1", | ||
expectedEngineVersionActual: "19.0.0.0.ru-2021-04.rur-2021-04.r1", | ||
}, | ||
"oracle - used to crash": { | ||
configuredVersion: "19.0.0.0.ru-2021-04.rur-2021-04.r1", | ||
actualVersion: "12.1.0.2.v20", | ||
expectedEngineVersion: "12.1.0.2.v20", | ||
expectedEngineVersionActual: "12.1.0.2.v20", | ||
}, | ||
} | ||
|
||
for name, test := range tests { | ||
name, test := name, test | ||
t.Run(name, func(t *testing.T) { | ||
r := ResourceCluster() | ||
d := r.Data(nil) | ||
compareActualEngineVersion(d, test.configuredVersion, test.actualVersion) | ||
|
||
if want, got := test.expectedEngineVersion, d.Get("engine_version"); got != want { | ||
t.Errorf("unexpected engine_version; want: %q, got: %q", want, got) | ||
} | ||
if want, got := test.expectedEngineVersionActual, d.Get("engine_version_actual"); got != want { | ||
t.Errorf("unexpected engine_version_actual; want: %q, got: %q", want, got) | ||
} | ||
}) | ||
} | ||
} |