-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #607 from hashicorp/uk1288-fix-plan-failure-with-e…
…xec-mode-change Fix ability to detect and apply agent_pool_id and execution_mode changes
- Loading branch information
Showing
3 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1624,6 +1624,54 @@ func TestAccTFEWorkspace_operationsAndExecutionModeInteroperability(t *testing.T | |
}) | ||
} | ||
|
||
func TestAccTFEWorkspace_unsetExecutionMode(t *testing.T) { | ||
skipIfEnterprise(t) | ||
|
||
tfeClient, err := getClientUsingEnv() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
org, orgCleanup := createBusinessOrganization(t, tfeClient) | ||
t.Cleanup(orgCleanup) | ||
|
||
workspace := &tfe.Workspace{} | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckTFEWorkspaceDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccTFEWorkspace_executionModeAgent(org.Name), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckTFEWorkspaceExists( | ||
"tfe_workspace.foobar", workspace), | ||
resource.TestCheckResourceAttr( | ||
"tfe_workspace.foobar", "operations", "true"), | ||
resource.TestCheckResourceAttr( | ||
"tfe_workspace.foobar", "execution_mode", "agent"), | ||
resource.TestCheckResourceAttrSet( | ||
"tfe_workspace.foobar", "agent_pool_id"), | ||
), | ||
}, | ||
{ | ||
Config: testAccTFEWorkspace_executionModeNull(org.Name), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckTFEWorkspaceExists( | ||
"tfe_workspace.foobar", workspace), | ||
resource.TestCheckResourceAttr( | ||
"tfe_workspace.foobar", "operations", "true"), | ||
resource.TestCheckResourceAttr( | ||
"tfe_workspace.foobar", "execution_mode", "remote"), | ||
resource.TestCheckResourceAttr( | ||
"tfe_workspace.foobar", "agent_pool_id", ""), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccTFEWorkspace_globalRemoteState(t *testing.T) { | ||
workspace := &tfe.Workspace{} | ||
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() | ||
|
@@ -2249,6 +2297,22 @@ resource "tfe_workspace" "foobar" { | |
}`, organization, organization) | ||
} | ||
|
||
// while testing the flow of unsetting execution mode as in TestAccTFEWorkspace_unsetExecutionMode | ||
// the resource "tfe_agent_pool" has been kept in both configs(testAccTFEWorkspace_executionModeAgent & testAccTFEWorkspace_executionModeNull) | ||
// this prevents an attempt to destroy the agent pool before dissasociating it from the workspace | ||
func testAccTFEWorkspace_executionModeNull(organization string) string { | ||
return fmt.Sprintf(` | ||
resource "tfe_agent_pool" "foobar" { | ||
name = "agent-pool-test" | ||
organization = "%s" | ||
} | ||
resource "tfe_workspace" "foobar" { | ||
name = "workspace-test" | ||
organization = "%s" | ||
}`, organization, organization) | ||
} | ||
|
||
func testAccTFEWorkspace_basicSpeculativeOff(rInt int) string { | ||
return fmt.Sprintf(` | ||
resource "tfe_organization" "foobar" { | ||
|
@@ -2702,15 +2766,15 @@ func testAccTFEWorkspace_updateRemoveVCSBlockFromTagsRegex(rInt int) string { | |
name = "tst-tf-%d-git-tag-ff-on" | ||
email = "[email protected]" | ||
} | ||
resource "tfe_oauth_client" "test" { | ||
organization = tfe_organization.foobar.id | ||
api_url = "https://api.github.com" | ||
http_url = "https://github.com" | ||
oauth_token = "%s" | ||
service_provider = "github" | ||
} | ||
resource "tfe_workspace" "foobar" { | ||
name = "workspace-test" | ||
description = "workspace-test-update-vcs-repo-tags-regex" | ||
|