Skip to content

Commit

Permalink
Merge pull request #811 from hashicorp/nf/nov23-flaky-policy-sets
Browse files Browse the repository at this point in the history
MAYBE fix flaky `TestPolicySetsCreate/with_vcs_policy_updated`
  • Loading branch information
nfagerlund authored Nov 8, 2023
2 parents 3b62deb + f8b230b commit 59b5f61
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions policy_set_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ func TestPolicySetsCreate(t *testing.T) {
t.Skip("Export a valid GITHUB_POLICY_SET_IDENTIFIER before running this test")
}

oc, ocTestCleanup := createOAuthToken(t, client, orgTest)
defer ocTestCleanup()
// We are deliberately ignoring the cleanup func here, because there's a potential race condition
// against the subsequent subtest -- TFC performs some async cleanup on VCS repos when deleting an
// OAuthClient, and we've seen evidence that it will zero out the next test's NEW VCSRepo values if
// they manage to slip in before the async stuff completes, even though the new values link it to a
// new OAuthToken. Anyway, there's a deferred cleanup for orgTest in the outer scope, so the org's
// dependent: destroy clause on OAuthClients will clean this up when the test as a whole ends.
oc, _ := createOAuthToken(t, client, orgTest)

options := PolicySetCreateOptions{
Name: String("vcs-policy-set"),
Expand Down Expand Up @@ -265,8 +270,13 @@ func TestPolicySetsCreate(t *testing.T) {
t.Skip("Export a valid GITHUB_POLICY_SET_IDENTIFIER before running this test")
}

oc, ocTestCleanup := createOAuthToken(t, client, orgTest)
defer ocTestCleanup()
// We are deliberately ignoring the cleanup func here, because it's not really necessary: there's a
// deferred cleanup for orgTest in the outer scope, so the org's dependent: destroy clause on
// OAuthClients will clean this up when the test as a whole ends. Unlike the one in the previous
// subtest, there's no known race condition here because there aren't any later subtests that modify
// this same policy set. But I'm being consistent with the prior case just to reduce risks from future
// copypasta code.
oc, _ := createOAuthToken(t, client, orgTest)

options := PolicySetUpdateOptions{
Name: String("vcs-policy-set"),
Expand Down

0 comments on commit 59b5f61

Please sign in to comment.