Skip to content

Commit

Permalink
Add acctest for emptydir volume shared across containers
Browse files Browse the repository at this point in the history
  • Loading branch information
hterik committed Sep 21, 2021
1 parent ac8e602 commit f2ddce2
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions internal/services/containers/container_group_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,21 @@ func TestAccContainerGroup_emptyDirVolume(t *testing.T) {
})
}

func TestAccContainerGroup_emptyDirVolumeShared(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_container_group", "test")
r := ContainerGroupResource{}

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

func TestAccContainerGroup_secretVolume(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_container_group", "test")
r := ContainerGroupResource{}
Expand Down Expand Up @@ -1553,6 +1568,66 @@ resource "azurerm_container_group" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (ContainerGroupResource) emptyDirVolumeShared(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_container_group" "test" {
name = "acctestcontainergroupemptyshared-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_address_type = "public"
dns_name_label = "acctestcontainergroup-%d"
os_type = "Linux"
restart_policy = "Never"
container {
name = "writer"
image = "ubuntu:20.04"
cpu = "1"
memory = "1.5"
commands = ["touch", "/sharedempty/file.txt"]
# Dummy port not used, workaround for https://github.com/hashicorp/terraform-provider-azurerm/issues/1697
ports {
port = 80
protocol = "TCP"
}
volume {
name = "logs"
mount_path = "/sharedempty"
read_only = false
empty_dir = true
}
}
container {
name = "reader"
image = "ubuntu:20.04"
cpu = "1"
memory = "1.5"
volume {
name = "logs"
mount_path = "/sharedempty"
read_only = false
empty_dir = true
}
commands = ["/bin/bash", "-c", "timeout 30 watch --interval 1 --errexit \"! cat /sharedempty/file.txt\""]
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (ContainerGroupResource) secretVolume(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down

0 comments on commit f2ddce2

Please sign in to comment.