Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_container_app_environment - update tests to remove ForceNew elements in update stages #25235

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,45 +64,36 @@ func TestAccContainerAppEnvironment_complete(t *testing.T) {
})
}

func TestAccContainerAppEnvironment_withWorkloadProfile(t *testing.T) {
func TestAccContainerAppEnvironment_updateWorkloadProfile(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_container_app_environment", "test")
r := ContainerAppEnvironmentResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.completeWithWorkloadProfile(data),
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("log_analytics_workspace_id"),
})
}

func TestAccContainerAppEnvironment_updateWorkloadProfile(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_container_app_environment", "test")
r := ContainerAppEnvironmentResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complete(data),
Config: r.completeUpdate(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("log_analytics_workspace_id"),
{
Config: r.completeWithWorkloadProfile(data),
Config: r.completeMultipleWorkloadProfiles(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("log_analytics_workspace_id"),
{
Config: r.completeUpdate(data),
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("workload_profile.0.maximum_count").HasValue("3"),
),
},
data.ImportStep("log_analytics_workspace_id"),
Expand Down Expand Up @@ -214,10 +205,17 @@ resource "azurerm_container_app_environment" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
log_analytics_workspace_id = azurerm_log_analytics_workspace.test.id

infrastructure_subnet_id = azurerm_subnet.control.id
infrastructure_subnet_id = azurerm_subnet.control.id

internal_load_balancer_enabled = true
zone_redundancy_enabled = true

workload_profile {
maximum_count = 3
minimum_count = 0
name = "D4-01"
workload_profile_type = "D4"
}

tags = {
Foo = "Bar"
Expand All @@ -227,110 +225,79 @@ resource "azurerm_container_app_environment" "test" {
`, r.templateVNet(data), data.RandomInteger)
}

func (r ContainerAppEnvironmentResource) completeWithWorkloadProfile(data acceptance.TestData) string {
func (r ContainerAppEnvironmentResource) completeUpdate(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

%[1]s

resource "azurerm_virtual_network" "test" {
name = "acctestvirtnet%[2]d"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}

resource "azurerm_subnet" "control" {
name = "control-plane"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.0.0/23"]
delegation {
name = "acctestdelegation%[2]d"
service_delegation {
actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
name = "Microsoft.App/environments"
}
}
}

resource "azurerm_container_app_environment" "test" {
name = "acctest-CAEnv%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
infrastructure_subnet_id = azurerm_subnet.control.id
name = "acctest-CAEnv%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
log_analytics_workspace_id = azurerm_log_analytics_workspace.test.id
infrastructure_subnet_id = azurerm_subnet.control.id

internal_load_balancer_enabled = true
zone_redundancy_enabled = true

workload_profile {
maximum_count = 2
minimum_count = 0
name = "My-GP-01"
workload_profile_type = "D4"
name = "E4-01"
workload_profile_type = "E4"
}

zone_redundancy_enabled = true

tags = {
Foo = "Bar"
secret = "sauce"
}
}
`, r.template(data), data.RandomInteger)
`, r.templateVNet(data), data.RandomInteger)

}

func (r ContainerAppEnvironmentResource) completeUpdate(data acceptance.TestData) string {
func (r ContainerAppEnvironmentResource) completeMultipleWorkloadProfiles(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

%[1]s

resource "azurerm_virtual_network" "test" {
name = "acctestvirtnet%[2]d"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}

resource "azurerm_subnet" "control" {
name = "control-plane"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.0.0/23"]
delegation {
name = "acctestdelegation%[2]d"
service_delegation {
actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
name = "Microsoft.App/environments"
}
}
}

resource "azurerm_container_app_environment" "test" {
name = "acctest-CAEnv%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
log_analytics_workspace_id = azurerm_log_analytics_workspace.test.id

infrastructure_subnet_id = azurerm_subnet.control.id
infrastructure_subnet_id = azurerm_subnet.control.id

internal_load_balancer_enabled = true
zone_redundancy_enabled = true

workload_profile {
maximum_count = 3
maximum_count = 2
minimum_count = 0
name = "E4-01"
workload_profile_type = "E4"
}

workload_profile {
maximum_count = 2
minimum_count = 0
name = "My-GP-01"
name = "D4-01"
workload_profile_type = "D4"
}

tags = {
Foo = "test"
Foo = "Bar"
secret = "sauce"
}
}
`, r.template(data), data.RandomInteger)
`, r.templateVNet(data), data.RandomInteger)

}

func (r ContainerAppEnvironmentResource) completeZoneRedundant(data acceptance.TestData) string {
Expand Down Expand Up @@ -403,6 +370,7 @@ resource "azurerm_log_analytics_workspace" "test" {
func (r ContainerAppEnvironmentResource) templateVNet(data acceptance.TestData) string {
return fmt.Sprintf(`


%[1]s

resource "azurerm_virtual_network" "test" {
Expand All @@ -417,8 +385,17 @@ resource "azurerm_subnet" "control" {
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.0.0/23"]

delegation {
name = "acctestdelegation%[2]d"
service_delegation {
actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
name = "Microsoft.App/environments"
}
}
}


`, r.template(data), data.RandomInteger)
}

Expand All @@ -430,27 +407,6 @@ provider "azurerm" {

%[1]s

resource "azurerm_virtual_network" "test" {
name = "acctestvirtnet%[2]d"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}

resource "azurerm_subnet" "control" {
name = "control-plane"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.0.0/23"]
delegation {
name = "acctestdelegation%[2]d"
service_delegation {
actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
name = "Microsoft.App/environments"
}
}
}

resource "azurerm_container_app_environment" "test" {
name = "acctest-CAEnv%[2]d"
resource_group_name = azurerm_resource_group.test.name
Expand All @@ -462,7 +418,7 @@ resource "azurerm_container_app_environment" "test" {
workload_profile {
maximum_count = 2
minimum_count = 0
name = "My-GP-01"
name = "D4-01"
workload_profile_type = "D4"
}

Expand All @@ -473,5 +429,5 @@ resource "azurerm_container_app_environment" "test" {
secret = "sauce"
}
}
`, r.template(data), data.RandomInteger)
`, r.templateVNet(data), data.RandomInteger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ func (ContainerAppResource) template(data acceptance.TestData) string {
}

func (ContainerAppResource) templateWorkloadProfile(data acceptance.TestData) string {
return ContainerAppEnvironmentResource{}.completeWithWorkloadProfile(data)
return ContainerAppEnvironmentResource{}.complete(data)
}

func (ContainerAppResource) templateWithVnet(data acceptance.TestData) string {
Expand Down
Loading