Skip to content

Commit

Permalink
Merge pull request #5149 from terraform-providers/p-kube-test-refactor
Browse files Browse the repository at this point in the history
`azurerm_kubernetes_*` - Move tests under a single
  • Loading branch information
tombuildsstuff authored Dec 13, 2019
2 parents 4f9071f + 3c434db commit 93141f3
Show file tree
Hide file tree
Showing 9 changed files with 400 additions and 287 deletions.
160 changes: 80 additions & 80 deletions azurerm/data_source_kubernetes_cluster_test.go

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions azurerm/resource_arm_kubernetes_cluster_addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
)

func TestAccAzureRMKubernetesCluster_addonProfileAciConnectorLinux(t *testing.T) {
func testAccAzureRMKubernetesCluster_addonProfileAciConnectorLinux(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
clientId := os.Getenv("ARM_CLIENT_ID")
Expand All @@ -22,7 +22,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileAciConnectorLinux(t *testing.T)
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_addonProfileAciConnectorLinux(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_addonProfileAciConnectorLinuxConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "addon_profile.0.http_application_routing.#", "0"),
Expand All @@ -41,7 +41,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileAciConnectorLinux(t *testing.T)
})
}

func TestAccAzureRMKubernetesCluster_addonProfileAciConnectorLinuxDisabled(t *testing.T) {
func testAccAzureRMKubernetesCluster_addonProfileAciConnectorLinuxDisabled(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
clientId := os.Getenv("ARM_CLIENT_ID")
Expand All @@ -54,7 +54,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileAciConnectorLinuxDisabled(t *te
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_addonProfileAciConnectorLinuxDisabled(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_addonProfileAciConnectorLinuxDisabledConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "addon_profile.0.http_application_routing.#", "0"),
Expand All @@ -74,7 +74,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileAciConnectorLinuxDisabled(t *te
})
}

func TestAccAzureRMKubernetesCluster_addonProfileAzurePolicy(t *testing.T) {
func testAccAzureRMKubernetesCluster_addonProfileAzurePolicy(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
clientId := os.Getenv("ARM_CLIENT_ID")
Expand All @@ -87,7 +87,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileAzurePolicy(t *testing.T) {
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_addonProfileAzurePolicy(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_addonProfileAzurePolicyConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "addon_profile.0.azure_policy.#", "1"),
Expand All @@ -104,7 +104,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileAzurePolicy(t *testing.T) {
})
}

func TestAccAzureRMKubernetesCluster_addonProfileKubeDashboard(t *testing.T) {
func testAccAzureRMKubernetesCluster_addonProfileKubeDashboard(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
clientId := os.Getenv("ARM_CLIENT_ID")
Expand All @@ -117,7 +117,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileKubeDashboard(t *testing.T) {
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_addonProfileKubeDashboard(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_addonProfileKubeDashboardConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "addon_profile.0.kube_dashboard.#", "1"),
Expand All @@ -134,7 +134,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileKubeDashboard(t *testing.T) {
})
}

func TestAccAzureRMKubernetesCluster_addonProfileOMS(t *testing.T) {
func testAccAzureRMKubernetesCluster_addonProfileOMS(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
clientId := os.Getenv("ARM_CLIENT_ID")
Expand All @@ -147,7 +147,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileOMS(t *testing.T) {
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_addonProfileOMS(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_addonProfileOMSConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "addon_profile.0.http_application_routing.#", "0"),
Expand All @@ -166,7 +166,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileOMS(t *testing.T) {
})
}

func TestAccAzureRMKubernetesCluster_addonProfileOMSToggle(t *testing.T) {
func testAccAzureRMKubernetesCluster_addonProfileOMSToggle(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
clientId := os.Getenv("ARM_CLIENT_ID")
Expand All @@ -179,7 +179,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileOMSToggle(t *testing.T) {
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_addonProfileOMS(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_addonProfileOMSConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "addon_profile.0.http_application_routing.#", "0"),
Expand All @@ -196,7 +196,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileOMSToggle(t *testing.T) {
ImportStateVerifyIgnore: []string{"service_principal.0.client_secret"},
},
{
Config: testAccAzureRMKubernetesCluster_addonProfileOMSDisabled(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_addonProfileOMSDisabledConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "addon_profile.0.http_application_routing.#", "0"),
Expand All @@ -213,7 +213,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileOMSToggle(t *testing.T) {
ImportStateVerifyIgnore: []string{"service_principal.0.client_secret"},
},
{
Config: testAccAzureRMKubernetesCluster_addonProfileOMSScaleWithoutBlock(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_addonProfileOMSScaleWithoutBlockConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "addon_profile.0.http_application_routing.#", "0"),
Expand All @@ -233,7 +233,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileOMSToggle(t *testing.T) {
})
}

func TestAccAzureRMKubernetesCluster_addonProfileRouting(t *testing.T) {
func testAccAzureRMKubernetesCluster_addonProfileRouting(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
clientId := os.Getenv("ARM_CLIENT_ID")
Expand All @@ -246,7 +246,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileRouting(t *testing.T) {
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_addonProfileRouting(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_addonProfileRoutingConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "addon_profile.0.http_application_routing.#", "1"),
Expand All @@ -265,7 +265,7 @@ func TestAccAzureRMKubernetesCluster_addonProfileRouting(t *testing.T) {
})
}

func testAccAzureRMKubernetesCluster_addonProfileAciConnectorLinux(rInt int, clientId string, clientSecret string, location string) string {
func testAccAzureRMKubernetesCluster_addonProfileAciConnectorLinuxConfig(rInt int, clientId string, clientSecret string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -342,7 +342,7 @@ resource "azurerm_kubernetes_cluster" "test" {
`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, clientId, clientSecret)
}

func testAccAzureRMKubernetesCluster_addonProfileAciConnectorLinuxDisabled(rInt int, clientId string, clientSecret string, location string) string {
func testAccAzureRMKubernetesCluster_addonProfileAciConnectorLinuxDisabledConfig(rInt int, clientId string, clientSecret string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -402,7 +402,7 @@ resource "azurerm_kubernetes_cluster" "test" {
`, rInt, location, rInt, rInt, rInt, rInt, rInt, clientId, clientSecret)
}

func testAccAzureRMKubernetesCluster_addonProfileAzurePolicy(rInt int, clientId string, clientSecret string, location string) string {
func testAccAzureRMKubernetesCluster_addonProfileAzurePolicyConfig(rInt int, clientId string, clientSecret string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -443,7 +443,7 @@ resource "azurerm_kubernetes_cluster" "test" {
`, rInt, location, rInt, rInt, rInt, clientId, clientSecret)
}

func testAccAzureRMKubernetesCluster_addonProfileKubeDashboard(rInt int, clientId string, clientSecret string, location string) string {
func testAccAzureRMKubernetesCluster_addonProfileKubeDashboardConfig(rInt int, clientId string, clientSecret string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -484,7 +484,7 @@ resource "azurerm_kubernetes_cluster" "test" {
`, rInt, location, rInt, rInt, rInt, clientId, clientSecret)
}

func testAccAzureRMKubernetesCluster_addonProfileOMS(rInt int, clientId string, clientSecret string, location string) string {
func testAccAzureRMKubernetesCluster_addonProfileOMSConfig(rInt int, clientId string, clientSecret string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -546,7 +546,7 @@ resource "azurerm_kubernetes_cluster" "test" {
`, rInt, location, rInt, rInt, rInt, rInt, clientId, clientSecret)
}

func testAccAzureRMKubernetesCluster_addonProfileOMSDisabled(rInt int, clientId string, clientSecret string, location string) string {
func testAccAzureRMKubernetesCluster_addonProfileOMSDisabledConfig(rInt int, clientId string, clientSecret string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -587,7 +587,7 @@ resource "azurerm_kubernetes_cluster" "test" {
`, rInt, location, rInt, rInt, rInt, clientId, clientSecret)
}

func testAccAzureRMKubernetesCluster_addonProfileOMSScaleWithoutBlock(rInt int, clientId string, clientSecret string, location string) string {
func testAccAzureRMKubernetesCluster_addonProfileOMSScaleWithoutBlockConfig(rInt int, clientId string, clientSecret string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -622,7 +622,7 @@ resource "azurerm_kubernetes_cluster" "test" {
`, rInt, location, rInt, rInt, rInt, clientId, clientSecret)
}

func testAccAzureRMKubernetesCluster_addonProfileRouting(rInt int, clientId string, clientSecret string, location string) string {
func testAccAzureRMKubernetesCluster_addonProfileRoutingConfig(rInt int, clientId string, clientSecret string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down
26 changes: 13 additions & 13 deletions azurerm/resource_arm_kubernetes_cluster_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
)

func TestAccAzureRMKubernetesCluster_apiServerAuthorizedIPRanges(t *testing.T) {
func testAccAzureRMKubernetesCluster_apiServerAuthorizedIPRanges(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
clientId := os.Getenv("ARM_CLIENT_ID")
Expand All @@ -22,7 +22,7 @@ func TestAccAzureRMKubernetesCluster_apiServerAuthorizedIPRanges(t *testing.T) {
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_apiServerAuthorizedIPRanges(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_apiServerAuthorizedIPRangesConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "role_based_access_control.#", "1"),
Expand Down Expand Up @@ -50,7 +50,7 @@ func TestAccAzureRMKubernetesCluster_apiServerAuthorizedIPRanges(t *testing.T) {
})
}

func TestAccAzureRMKubernetesCluster_enablePodSecurityPolicy(t *testing.T) {
func testAccAzureRMKubernetesCluster_enablePodSecurityPolicy(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
clientId := os.Getenv("ARM_CLIENT_ID")
Expand All @@ -63,7 +63,7 @@ func TestAccAzureRMKubernetesCluster_enablePodSecurityPolicy(t *testing.T) {
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_enablePodSecurityPolicy(ri, clientId, clientSecret, location),
Config: testAccAzureRMKubernetesCluster_enablePodSecurityPolicyConfig(ri, clientId, clientSecret, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enable_pod_security_policy", "true"),
Expand All @@ -79,7 +79,7 @@ func TestAccAzureRMKubernetesCluster_enablePodSecurityPolicy(t *testing.T) {
})
}

func TestAccAzureRMKubernetesCluster_roleBasedAccessControl(t *testing.T) {
func testAccAzureRMKubernetesCluster_roleBasedAccessControl(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
location := testLocation()
Expand All @@ -92,7 +92,7 @@ func TestAccAzureRMKubernetesCluster_roleBasedAccessControl(t *testing.T) {
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_roleBasedAccessControl(ri, location, clientId, clientSecret),
Config: testAccAzureRMKubernetesCluster_roleBasedAccessControlConfig(ri, location, clientId, clientSecret),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "role_based_access_control.#", "1"),
Expand All @@ -112,7 +112,7 @@ func TestAccAzureRMKubernetesCluster_roleBasedAccessControl(t *testing.T) {
})
}

func TestAccAzureRMKubernetesCluster_roleBasedAccessControlAAD(t *testing.T) {
func testAccAzureRMKubernetesCluster_roleBasedAccessControlAAD(t *testing.T) {
resourceName := "azurerm_kubernetes_cluster.test"
ri := tf.AccRandTimeInt()
location := testLocation()
Expand All @@ -126,7 +126,7 @@ func TestAccAzureRMKubernetesCluster_roleBasedAccessControlAAD(t *testing.T) {
CheckDestroy: testCheckAzureRMKubernetesClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMKubernetesCluster_roleBasedAccessControlAAD(ri, location, clientId, clientSecret, ""),
Config: testAccAzureRMKubernetesCluster_roleBasedAccessControlAADConfig(ri, location, clientId, clientSecret, ""),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "role_based_access_control.#", "1"),
Expand All @@ -151,7 +151,7 @@ func TestAccAzureRMKubernetesCluster_roleBasedAccessControlAAD(t *testing.T) {
},
{
// should be no changes since the default for Tenant ID comes from the Provider block
Config: testAccAzureRMKubernetesCluster_roleBasedAccessControlAAD(ri, location, clientId, clientSecret, tenantId),
Config: testAccAzureRMKubernetesCluster_roleBasedAccessControlAADConfig(ri, location, clientId, clientSecret, tenantId),
PlanOnly: true,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(resourceName),
Expand All @@ -170,7 +170,7 @@ func TestAccAzureRMKubernetesCluster_roleBasedAccessControlAAD(t *testing.T) {
})
}

func testAccAzureRMKubernetesCluster_apiServerAuthorizedIPRanges(rInt int, clientId string, clientSecret string, location string) string {
func testAccAzureRMKubernetesCluster_apiServerAuthorizedIPRangesConfig(rInt int, clientId string, clientSecret string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -223,7 +223,7 @@ resource "azurerm_kubernetes_cluster" "test" {
`, rInt, location, rInt, rInt, rInt, rInt, clientId, clientSecret)
}

func testAccAzureRMKubernetesCluster_enablePodSecurityPolicy(rInt int, clientId string, clientSecret string, location string) string {
func testAccAzureRMKubernetesCluster_enablePodSecurityPolicyConfig(rInt int, clientId string, clientSecret string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -255,7 +255,7 @@ resource "azurerm_kubernetes_cluster" "test" {
`, rInt, location, rInt, rInt, clientId, clientSecret)
}

func testAccAzureRMKubernetesCluster_roleBasedAccessControl(rInt int, location, clientId, clientSecret string) string {
func testAccAzureRMKubernetesCluster_roleBasedAccessControlConfig(rInt int, location, clientId, clientSecret string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -294,7 +294,7 @@ resource "azurerm_kubernetes_cluster" "test" {
`, rInt, location, rInt, rInt, rInt, clientId, clientSecret)
}

func testAccAzureRMKubernetesCluster_roleBasedAccessControlAAD(rInt int, location, clientId, clientSecret, tenantId string) string {
func testAccAzureRMKubernetesCluster_roleBasedAccessControlAADConfig(rInt int, location, clientId, clientSecret, tenantId string) string {
return fmt.Sprintf(`
variable "tenant_id" {
default = "%s"
Expand Down
Loading

0 comments on commit 93141f3

Please sign in to comment.