Skip to content

Commit dbf405f

Browse files
INTMDB-448: custom_db_role error (#1009)
* example fix * log to file add * formating * formatting updates * Add mutex to prevent concurrent API calls datasource simplify count as it picks up other tests Co-authored-by: Zuhair Ahmed <[email protected]>
1 parent cd34000 commit dbf405f

3 files changed

+10
-2
lines changed

mongodbatlas/data_source_mongodbatlas_custom_db_roles_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestAccConfigDSCustomDBRoles_basic(t *testing.T) {
3737

3838
// Test for Data source
3939
resource.TestCheckResourceAttrSet(dataSourceName, "project_id"),
40-
resource.TestCheckResourceAttr(dataSourceName, "results.#", "1"),
40+
resource.TestCheckResourceAttrSet(dataSourceName, "results.#"),
4141
),
4242
},
4343
},

mongodbatlas/resource_mongodbatlas_custom_db_role.go

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/http"
99
"regexp"
1010
"strings"
11+
"sync"
1112
"time"
1213

1314
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -101,7 +102,13 @@ func resourceMongoDBAtlasCustomDBRole() *schema.Resource {
101102
}
102103
}
103104

105+
var (
106+
customRoleLock sync.Mutex
107+
)
108+
104109
func resourceMongoDBAtlasCustomDBRoleCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
110+
customRoleLock.Lock()
111+
defer customRoleLock.Unlock()
105112
conn := meta.(*MongoDBClient).Atlas
106113
projectID := d.Get("project_id").(string)
107114

@@ -180,6 +187,8 @@ func resourceMongoDBAtlasCustomDBRoleRead(ctx context.Context, d *schema.Resourc
180187
}
181188

182189
func resourceMongoDBAtlasCustomDBRoleUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
190+
customRoleLock.Lock()
191+
defer customRoleLock.Unlock()
183192
conn := meta.(*MongoDBClient).Atlas
184193
ids := decodeStateID(d.Id())
185194
projectID := ids["project_id"]

mongodbatlas/resource_mongodbatlas_custom_db_role_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ func TestAccConfigRSCustomDBRoles_MultipleCustomRoles(t *testing.T) {
412412
}
413413

414414
func TestAccConfigRSCustomDBRoles_MultipleResources(t *testing.T) {
415-
t.Skip() // The error seems appear to be similar to whitelist behavior, skip it temporally
416415
var (
417416
resourceName = "mongodbatlas_custom_db_role.test"
418417
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")

0 commit comments

Comments
 (0)