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

chore: Upgrades advanced_cluster resource to auto-generated SDK #1947

Merged
merged 53 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b198e50
rename
lantoli Feb 14, 2024
1f96b82
mig.TestStep
lantoli Feb 14, 2024
9464d48
SkipInUnitTest
lantoli Feb 14, 2024
508d117
TEMPORARY skip most acc tests
lantoli Feb 14, 2024
cee2552
CheckDestroyTeamAdvancedCluster with new SDK
lantoli Feb 14, 2024
9ed4f9d
more renames
lantoli Feb 15, 2024
c8a6991
unify CheckDestroy
lantoli Feb 15, 2024
5f09abf
acc.SkipInUnitTest in atlas_user ds
lantoli Feb 15, 2024
387ce06
remove unneeded testAccCheckMongoDBAtlasAdvancedClusterAttributes
lantoli Feb 15, 2024
1c0099d
refactor testAccCheckMongoDBAtlasAdvancedClusterScaling and testAccCh…
lantoli Feb 15, 2024
b558570
refactor checkExists
lantoli Feb 15, 2024
0de9b7e
import
lantoli Feb 15, 2024
8c0dd50
TEMPORARY only run advanced cluster tests
lantoli Feb 15, 2024
bb2c153
add new mig test
lantoli Feb 15, 2024
7940d80
extract resource and ds names in tests
lantoli Feb 15, 2024
f62a76d
read & ds in new sdk still using some old sdk
lantoli Feb 15, 2024
924312b
fix mig test
lantoli Feb 15, 2024
07a8f83
flattenProcessArgs
lantoli Feb 15, 2024
edd5127
TEMPORARY don't run network tests
lantoli Feb 15, 2024
b45ae6b
split cluster and advanced cluster common methods that will diverge
lantoli Feb 15, 2024
d6818e6
run cluster tests
lantoli Feb 15, 2024
2410003
TEMPORARY don't run network tests (fix)
lantoli Feb 15, 2024
8746120
Revert "run cluster tests"
lantoli Feb 15, 2024
60c171a
FlattenTags
lantoli Feb 15, 2024
b1d811d
flattenLabels
lantoli Feb 15, 2024
ad8647b
Merge branch 'master' into CLOUDP-229554_advanced_cluster
lantoli Feb 16, 2024
5b8a27f
cluster and project random names
lantoli Feb 17, 2024
5412441
flattenBiConnectorConfig
lantoli Feb 17, 2024
1ab9b2f
flattenConnectionStrings
lantoli Feb 17, 2024
cb55b01
function reorg
lantoli Feb 17, 2024
50594ec
finish read & ds
lantoli Feb 17, 2024
cc38401
enable more tests
lantoli Feb 17, 2024
22607f2
enable more tests
lantoli Feb 17, 2024
8eb9ebd
revert long tests
lantoli Feb 17, 2024
e1136c4
most of create
lantoli Feb 19, 2024
6a1f37e
TEMPORARY: don't run serverless tests
lantoli Feb 19, 2024
3cb23bc
delete
lantoli Feb 19, 2024
ead12e5
expandProcessArgs in create
lantoli Feb 19, 2024
575fcd6
expandProcessArgs
lantoli Feb 19, 2024
687b62c
split ResourceClusterRefreshFunc
lantoli Feb 19, 2024
5f37936
resourceRefreshFunc
lantoli Feb 19, 2024
6be0170
UpgradeCluster
lantoli Feb 19, 2024
d881453
getUpgradeRequest
lantoli Feb 19, 2024
4938549
revert test skips
lantoli Feb 19, 2024
741c71c
remove old sdk from tests
lantoli Feb 19, 2024
2804312
blanks
lantoli Feb 19, 2024
72f10e1
keep behavior for accept_data_risks_and_force_replica_set_reconfig
lantoli Feb 20, 2024
c371a9a
move out UpgradeCluster from model
lantoli Feb 20, 2024
5df8b25
remove pointer from expandProcessArgs return so it's clear it always …
lantoli Feb 20, 2024
1ab91d8
rename mig.TestStep to TestStepCheckEmptyPlan
lantoli Feb 20, 2024
2d9fd0e
random names functions and mig.TestStepCheckEmptyPlan for tests in te…
lantoli Feb 20, 2024
6732903
revert acc and mig config
lantoli Feb 20, 2024
5db5eee
fix test
lantoli Feb 20, 2024
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
12 changes: 6 additions & 6 deletions .github/workflows/acceptance-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ jobs:
outputs:
cluster_outage_simulation: ${{ steps.filter.outputs.cluster_outage_simulation == 'true' || env.mustTrigger == 'true' }}
advanced_cluster: ${{ steps.filter.outputs.advanced_cluster == 'true' || env.mustTrigger == 'true' }}
cluster: ${{ steps.filter.outputs.cluster == 'true' || env.mustTrigger == 'true' }}
search_deployment: ${{ steps.filter.outputs.search_deployment == 'true' || env.mustTrigger == 'true' }}
cluster: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
search_deployment: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
stream: ${{ steps.filter.outputs.stream == 'true' || env.mustTrigger == 'true' }}
generic: ${{ steps.filter.outputs.generic == 'true' || env.mustTrigger == 'true' }}
backup: ${{ steps.filter.outputs.backup == 'true' || env.mustTrigger == 'true' }}
backup: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
project: ${{ steps.filter.outputs.project == 'true' || env.mustTrigger == 'true' }}
serverless: ${{ steps.filter.outputs.serverless == 'true' || env.mustTrigger == 'true' }}
network: ${{ steps.filter.outputs.network == 'true' || env.mustTrigger == 'true' }}
config: ${{ steps.filter.outputs.config == 'true' || env.mustTrigger == 'true' }}
serverless: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
network: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
config: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
assume_role: ${{ steps.filter.outputs.assume_role == 'true' || env.mustTrigger == 'true' }}
event_trigger: ${{ steps.filter.outputs.event_trigger == 'true' || env.mustTrigger == 'true' }}
search_index: ${{ steps.filter.outputs.search_index == 'true' || env.mustTrigger == 'true' }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/migration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ jobs:
mustTrigger: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.test_group == '') }}
outputs:
project: ${{ steps.filter.outputs.project == 'true' || env.mustTrigger == 'true' }}
config: ${{ steps.filter.outputs.config == 'true' || env.mustTrigger == 'true' }}
config: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
advanced_cluster: ${{ steps.filter.outputs.advanced_cluster == 'true' || env.mustTrigger == 'true' }}
backup: ${{ steps.filter.outputs.backup == 'true' || env.mustTrigger == 'true' }}
backup: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
stream: ${{ steps.filter.outputs.stream == 'true' || env.mustTrigger == 'true' }}
federated: ${{ steps.filter.outputs.federated == 'true' || env.mustTrigger == 'true' }}
search_deployment: ${{ steps.filter.outputs.search_deployment == 'true' || env.mustTrigger == 'true' }}
search_deployment: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
generic: ${{ steps.filter.outputs.generic == 'true' || env.mustTrigger == 'true' }}
network: ${{ steps.filter.outputs.network == 'true' || env.mustTrigger == 'true' }}
network: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
encryption: ${{ steps.filter.outputs.encryption == 'true' || env.mustTrigger == 'true' }}
serverless: ${{ steps.filter.outputs.serverless == 'true' || env.mustTrigger == 'true' }}
serverless: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
data_lake: ${{ steps.filter.outputs.data_lake == 'true' || env.mustTrigger == 'true' }}
cluster_outage_simulation: ${{ steps.filter.outputs.cluster_outage_simulation == 'true' || env.mustTrigger == 'true' }}
cluster: ${{ steps.filter.outputs.cluster == 'true' || env.mustTrigger == 'true' }}
cluster: false # TEMPORARY, WILL BE REVERTED BEFORE MERGE
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd
Expand Down
16 changes: 8 additions & 8 deletions internal/common/conversion/flatten_expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ import (
"go.mongodb.org/atlas-sdk/v20231115006/admin"
)

func FlattenLinks(links []admin.Link) []map[string]any {
ret := make([]map[string]any, len(links))
func FlattenLinks(links []admin.Link) []map[string]string {
ret := make([]map[string]string, len(links))
for i, link := range links {
ret[i] = map[string]any{
ret[i] = map[string]string{
"href": link.GetHref(),
"rel": link.GetRel(),
}
}
return ret
}

func FlattenTags(tags []admin.ResourceTag) []map[string]any {
ret := make([]map[string]any, len(tags))
func FlattenTags(tags []admin.ResourceTag) []map[string]string {
ret := make([]map[string]string, len(tags))
for i, tag := range tags {
ret[i] = map[string]any{
ret[i] = map[string]string{
"key": tag.GetKey(),
"value": tag.GetValue(),
}
}
return ret
}

func ExpandTagsFromSetSchema(d *schema.ResourceData) []admin.ResourceTag {
func ExpandTagsFromSetSchema(d *schema.ResourceData) *[]admin.ResourceTag {
list := d.Get("tags").(*schema.Set)
ret := make([]admin.ResourceTag, list.Len())
for i, item := range list.List() {
Expand All @@ -38,7 +38,7 @@ func ExpandTagsFromSetSchema(d *schema.ResourceData) []admin.ResourceTag {
Value: StringPtr(tag["value"].(string)),
}
}
return ret
return &ret
}

func ExpandStringList(list []any) (res []string) {
Expand Down
6 changes: 6 additions & 0 deletions internal/common/conversion/type_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func TimeToString(t time.Time) string {
return t.UTC().Format(time.RFC3339Nano)
}

// StringToTime is the opposite to TimeToString, returns ok if conversion is possible.
func StringToTime(str string) (time.Time, bool) {
ret, err := time.Parse(time.RFC3339Nano, str)
return ret, err == nil
}

func Int64PtrToIntPtr(i64 *int64) *int {
if i64 == nil {
return nil
Expand Down
27 changes: 19 additions & 8 deletions internal/common/conversion/type_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,39 @@ import (
"time"

"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/stretchr/testify/assert"
)

func TestTimeToStringWithoutNanos(t *testing.T) {
func TestTimeWithoutNanos(t *testing.T) {
inputTime := time.Date(2023, time.July, 18, 16, 12, 23, 0, time.UTC)
expectedOutput := "2023-07-18T16:12:23Z"

result := conversion.TimeToString(inputTime)
assert.Equal(t, expectedOutput, result)

if result != expectedOutput {
t.Errorf("TimeToString(%v) = %v; want %v", inputTime, result, expectedOutput)
}
expectedTime, ok := conversion.StringToTime(result)
assert.True(t, ok)
assert.Equal(t, expectedTime, inputTime)
}

func TestTimeToStringWithNanos(t *testing.T) {
func TestTimeWithNanos(t *testing.T) {
inputTime := time.Date(2023, time.July, 18, 16, 12, 23, 456_000_000, time.UTC)
expectedOutput := "2023-07-18T16:12:23.456Z"

result := conversion.TimeToString(inputTime)
assert.Equal(t, expectedOutput, result)

if result != expectedOutput {
t.Errorf("TimeToString(%v) = %v; want %v", inputTime, result, expectedOutput)
}
expectedTime, ok := conversion.StringToTime(result)
assert.True(t, ok)
assert.Equal(t, expectedTime, inputTime)
}

func TestStringToTimeInvalid(t *testing.T) {
_, ok := conversion.StringToTime("")
assert.False(t, ok)

_, ok = conversion.StringToTime("123")
assert.False(t, ok)
}

func TestIsStringPresent(t *testing.T) {
Expand Down
Loading