Skip to content

Commit 3fe9be2

Browse files
lantoliCopilot
andauthored
chore: Fix TestMigCloudUserProjectAssignmentRS_basic (#3692)
Co-authored-by: Copilot <[email protected]>
1 parent 995cc16 commit 3fe9be2

File tree

7 files changed

+22
-23
lines changed

7 files changed

+22
-23
lines changed

internal/service/cloudbackupsnapshot/resource.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func Resource() *schema.Resource {
133133
}
134134

135135
const (
136-
oneMinute = 1 * time.Minute
136+
timeout = 1 * time.Minute
137137
)
138138

139139
func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
@@ -165,9 +165,9 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
165165
Pending: []string{"queued", "inProgress"},
166166
Target: []string{"completed", "failed"},
167167
Refresh: resourceRefreshFunc(ctx, requestParams, connV2),
168-
Timeout: d.Timeout(schema.TimeoutCreate) - time.Minute,
169-
MinTimeout: oneMinute,
170-
Delay: oneMinute,
168+
Timeout: d.Timeout(schema.TimeoutCreate),
169+
MinTimeout: timeout,
170+
Delay: timeout,
171171
}
172172
_, errWait := stateConf.WaitForStateContext(ctx)
173173
deleteOnCreateTimeout := true // default value when not set

internal/service/clouduserprojectassignment/resource_migration_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ import (
1414

1515
const (
1616
resourceInvitationName = "mongodbatlas_project_invitation.mig_test"
17-
resourceProjectName = "mongodbatlas_project.mig_test"
1817
resourceUserProjectAssignmentName = "mongodbatlas_cloud_user_project_assignment.user_mig_test"
1918
)
2019

2120
func TestMigCloudUserProjectAssignmentRS_basic(t *testing.T) {
2221
mig.SkipIfVersionBelow(t, "2.0.0") // when resource 1st released
23-
mig.CreateAndRunTest(t, basicTestCase(t))
22+
mig.CreateAndRunTestNonParallel(t, basicTestCase(t))
2423
}
2524

2625
func TestMigCloudUserProjectAssignmentRS_migrationJourney(t *testing.T) {

internal/service/clouduserprojectassignment/resource_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ var DSNameUsername = "data.mongodbatlas_cloud_user_project_assignment.test_usern
1919
var DSNameUserID = "data.mongodbatlas_cloud_user_project_assignment.test_user_id"
2020

2121
func TestAccCloudUserProjectAssignment_basic(t *testing.T) {
22-
resource.ParallelTest(t, *basicTestCase(t))
22+
resource.Test(t, *basicTestCase(t))
2323
}
2424

2525
func TestAccCloudUserProjectAssignmentDS_error(t *testing.T) {
2626
resource.ParallelTest(t, *errorTestCase(t))
2727
}
2828

29+
// basicTestCase must be called in serial to avoid multiple tests to use the same Atlas resources and interfere with each other.
2930
func basicTestCase(t *testing.T) *resource.TestCase {
3031
t.Helper()
3132

@@ -39,7 +40,7 @@ func basicTestCase(t *testing.T) *resource.TestCase {
3940
updatedRoles := []string{"GROUP_OWNER", "GROUP_SEARCH_INDEX_EDITOR", "GROUP_READ_ONLY"}
4041

4142
return &resource.TestCase{
42-
PreCheck: func() { acc.PreCheckBasic(t); acc.PreCheckAtlasUsernames(t) },
43+
PreCheck: func() { acc.PreCheckAtlasUsernames(t) },
4344
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
4445
CheckDestroy: checkDestroy,
4546
Steps: []resource.TestStep{

internal/service/clusteroutagesimulation/resource.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
errorClusterOutageSimulationDelete = "error ending MongoDB Atlas Cluster Outage Simulation for Project (%s), Cluster (%s): %s"
2323
errorClusterOutageSimulationSetting = "error setting `%s` for MongoDB Atlas Cluster Outage Simulation: %s"
2424
defaultOutageFilterType = "REGION"
25-
oneMinute = 1 * time.Minute
25+
timeout = 1 * time.Minute
2626
)
2727

2828
func Resource() *schema.Resource {
@@ -106,8 +106,8 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
106106
Target: []string{"SIMULATING"},
107107
Refresh: resourceRefreshFunc(ctx, clusterName, projectID, connV2),
108108
Timeout: d.Timeout(schema.TimeoutCreate),
109-
MinTimeout: oneMinute,
110-
Delay: oneMinute,
109+
MinTimeout: timeout,
110+
Delay: timeout,
111111
}
112112

113113
_, errWait := stateConf.WaitForStateContext(ctx)
@@ -187,8 +187,8 @@ func waitForDeletableState(ctx context.Context, connV2 *admin.APIClient, project
187187
Target: []string{"SIMULATING", "FAILED", "DELETED"},
188188
Refresh: resourceRefreshFunc(ctx, clusterName, projectID, connV2),
189189
Timeout: timeout,
190-
MinTimeout: oneMinute,
191-
Delay: oneMinute,
190+
MinTimeout: timeout,
191+
Delay: timeout,
192192
}
193193

194194
result, err := stateConf.WaitForStateContext(ctx)
@@ -236,8 +236,8 @@ func endOutageSimulationAndWait(ctx context.Context, connV2 *admin.APIClient, pr
236236
Target: []string{"DELETED"},
237237
Refresh: resourceRefreshFunc(ctx, clusterName, projectID, connV2),
238238
Timeout: timeout,
239-
MinTimeout: oneMinute,
240-
Delay: oneMinute,
239+
MinTimeout: timeout,
240+
Delay: timeout,
241241
}
242242

243243
_, err = stateConf.WaitForStateContext(ctx)

internal/service/networkpeering/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
261261
Pending: []string{"INITIATING", "FINALIZING", "ADDING_PEER", "WAITING_FOR_USER"},
262262
Target: []string{"FAILED", "AVAILABLE", "PENDING_ACCEPTANCE"},
263263
Refresh: resourceRefreshFunc(ctx, peerID, projectID, peerRequest.GetContainerId(), conn.NetworkPeeringApi),
264-
Timeout: d.Timeout(schema.TimeoutCreate) - time.Minute, // When using a CRUD function with a timeout, any StateChangeConf timeouts must be configured below that duration to avoid returning the SDK context: deadline exceeded error instead of the retry logic error.
264+
Timeout: d.Timeout(schema.TimeoutCreate),
265265
MinTimeout: minTimeout,
266266
Delay: minTimeout,
267267
}

internal/service/onlinearchive/resource.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
errorOnlineArchivesCreate = "error creating MongoDB Atlas Online Archive:: %s"
2424
errorOnlineArchivesDelete = "error deleting MongoDB Atlas Online Archive: %s archive_id (%s)"
2525
scheduleTypeDefault = "DEFAULT"
26-
oneMinute = 1 * time.Minute
26+
timeout = 1 * time.Minute
2727
)
2828

2929
func Resource() *schema.Resource {
@@ -250,9 +250,9 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
250250
Pending: []string{"PENDING", "ARCHIVING", "PAUSING", "PAUSED", "ORPHANED", "REPEATING"},
251251
Target: []string{"IDLE", "ACTIVE"},
252252
Refresh: resourceOnlineRefreshFunc(ctx, projectID, clusterName, archiveID, connV2),
253-
Timeout: d.Timeout(schema.TimeoutCreate) - oneMinute, // When using a CRUD function with a timeout, any StateChangeConf timeouts must be configured below that duration to avoid returning the SDK context: deadline exceeded error instead of the retry logic error.
254-
MinTimeout: oneMinute,
255-
Delay: oneMinute,
253+
Timeout: d.Timeout(schema.TimeoutCreate),
254+
MinTimeout: timeout,
255+
Delay: timeout,
256256
}
257257

258258
// Wait, catching any errors

internal/service/privatelinkendpointservice/resource.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const (
2626
ErrorServiceEndpointRead = "error reading MongoDB Private Service Endpoint Connection(%s): %s"
2727
errorEndpointDelete = "error deleting MongoDB Private Service Endpoint Connection(%s): %s"
2828
ErrorEndpointSetting = "error setting `%s` for MongoDB Private Service Endpoint Connection(%s): %s"
29-
oneMinute = 1 * time.Minute
3029
delayAndMinTimeout = 10 * time.Second
3130
)
3231

@@ -183,7 +182,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
183182
Pending: []string{"NONE", "INITIATING", "PENDING_ACCEPTANCE", "PENDING", "DELETING", "VERIFIED"},
184183
Target: []string{"AVAILABLE", "REJECTED", "DELETED", "FAILED"},
185184
Refresh: resourceRefreshFunc(ctx, connV2, projectID, providerName, privateLinkID, endpointServiceID),
186-
Timeout: d.Timeout(schema.TimeoutCreate) - oneMinute, // When using a CRUD function with a timeout, any StateChangeConf timeouts must be configured below that duration to avoid returning the SDK context: deadline exceeded error instead of the retry logic error.
185+
Timeout: d.Timeout(schema.TimeoutCreate),
187186
MinTimeout: delayAndMinTimeout,
188187
Delay: delayAndMinTimeout,
189188
}
@@ -205,7 +204,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
205204
Pending: []string{"REPEATING", "PENDING"},
206205
Target: []string{"IDLE", "DELETED"},
207206
Refresh: advancedcluster.ResourceClusterListAdvancedRefreshFunc(ctx, projectID, connV2.ClustersApi),
208-
Timeout: d.Timeout(schema.TimeoutCreate) - oneMinute, // When using a CRUD function with a timeout, any StateChangeConf timeouts must be configured below that duration to avoid returning the SDK context: deadline exceeded error instead of the retry logic error.
207+
Timeout: d.Timeout(schema.TimeoutCreate),
209208
MinTimeout: delayAndMinTimeout,
210209
Delay: delayAndMinTimeout,
211210
}

0 commit comments

Comments
 (0)