Skip to content

Commit

Permalink
chore: stabilize Metal organization test (#510)
Browse files Browse the repository at this point in the history
The terraform acceptance test for `metal_organization` creates an
organization and then very quickly updates it. The update step started
failing at some point mid-2023 and was briefly fixed, but it has been
failing consistently for quite a while now.

There is some background processing that happens when an organization is
created, and the API will throw an error if the organization is updated
before that background processing is finished. This adds a delay between
the create and update calls for an organization so that the affected
test can pass.

Fixes #463.
  • Loading branch information
cprivitere authored Jan 11, 2024
2 parents e7d2945 + ad6a7e7 commit 3cee584
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion equinix/resource_metal_organization_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"testing"
"time"

"github.com/equinix/terraform-provider-equinix/internal/config"

Expand Down Expand Up @@ -75,7 +76,8 @@ func TestAccMetalOrganization_create(t *testing.T) {
),
},
{
Config: testAccMetalOrganizationConfig_basicUpdate(rInt),
PreConfig: testAccMetalWaitForOrganization,
Config: testAccMetalOrganizationConfig_basicUpdate(rInt),
Check: resource.ComposeTestCheckFunc(
testAccMetalOrganizationExists("equinix_metal_organization.test", &org2),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -104,6 +106,14 @@ func testAccMetalSameOrganization(t *testing.T, before, after *packngo.Organizat
}
}

func testAccMetalWaitForOrganization() {
// Some aspect of organization creation takes a while
// to propagate; updating an organization too soon after
// create causes test failures and probably doesn't
// reflect real-world usage.
time.Sleep(5 * time.Minute)
}

func TestAccMetalOrganization_importBasic(t *testing.T) {
rInt := acctest.RandInt()
resource.ParallelTest(t, resource.TestCase{
Expand Down

0 comments on commit 3cee584

Please sign in to comment.