Skip to content

Commit

Permalink
Adding extra checks for destroyed resources (in tests) and added some…
Browse files Browse the repository at this point in the history
… waitForStatus checks when deleting ACL entities
  • Loading branch information
JohnSharpe committed Nov 7, 2023
1 parent 70ebf8d commit 5fe07a0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions provider/datasource_rediscloud_acl_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestAccDataSourceRedisCloudAclRole_Default(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccAwsPreExistingCloudAccountPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: nil, // test doesn't create a resource at the moment, so don't need to check anything
CheckDestroy: testAccCheckAclRoleDestroy,
Steps: []resource.TestStep{
{
Config: createAndGetRoleTerraform,
Expand Down Expand Up @@ -86,7 +86,7 @@ resource "rediscloud_subscription" "example" {
support_oss_cluster_api=true
throughput_measurement_by = "operations-per-second"
throughput_measurement_value = 1000
modules = ["RedisJSON", "RedisBloom"]
modules = []
}
}
Expand Down
2 changes: 1 addition & 1 deletion provider/datasource_rediscloud_acl_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestAccDataSourceRedisCloudAclUser_Default(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: nil, // test doesn't create a resource at the moment, so don't need to check anything
CheckDestroy: testAccCheckAclUserDestroy,
Steps: []resource.TestStep{
{
Config: createAndGetUserTerraform,
Expand Down
8 changes: 8 additions & 0 deletions provider/resource_rediscloud_acl_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ func resourceRedisCloudAclRoleDelete(ctx context.Context, d *schema.ResourceData
return diag.FromErr(err)
}

// Sometimes ACL Users and Roles flip between Active and Pending a few times after creation/update.
// This delay gives the API a chance to settle
// TODO Ultimately this is an API problem
err = waitForAclRoleToBeActive(ctx, id, api)
if err != nil {
return diag.FromErr(err)
}

err = api.client.Roles.Delete(ctx, id)

if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions provider/resource_rediscloud_acl_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ func resourceRedisCloudAclUserDelete(ctx context.Context, d *schema.ResourceData
return diag.FromErr(err)
}

// Sometimes ACL Users and Roles flip between Active and Pending a few times after creation/update.
// This delay gives the API a chance to settle
// TODO Ultimately this is an API problem
err = waitForAclUserToBeActive(ctx, id, api)
if err != nil {
return diag.FromErr(err)
}

err = api.client.Users.Delete(ctx, id)

if err != nil {
Expand Down

0 comments on commit 5fe07a0

Please sign in to comment.