diff --git a/.github/workflows/acceptance_tests_aks.yaml b/.github/workflows/acceptance_tests_aks.yaml index 625a2be13f..017007c109 100644 --- a/.github/workflows/acceptance_tests_aks.yaml +++ b/.github/workflows/acceptance_tests_aks.yaml @@ -5,13 +5,13 @@ on: inputs: location: description: 'Location' - default: "West Europe" + default: "West US 3" nodeCount: description: 'Number of nodes to provision' default: 2 vmSize: description: 'The azure machine size for nodes' - default: "Standard_A4_v2" + default: "Standard_A2_v2" clusterVersion: description: 'The version of kubernetes' default: "1.27" diff --git a/kubernetes/data_source_kubernetes_mutating_webhook_configuration_v1_test.go b/kubernetes/data_source_kubernetes_mutating_webhook_configuration_v1_test.go index 3798f58f0d..6b3c4c769f 100644 --- a/kubernetes/data_source_kubernetes_mutating_webhook_configuration_v1_test.go +++ b/kubernetes/data_source_kubernetes_mutating_webhook_configuration_v1_test.go @@ -16,7 +16,11 @@ func TestAccKubernetesDataSourceMutatingWebhookConfigurationV1_basic(t *testing. dataSourceName := fmt.Sprintf("data.%s", resourceName) name := fmt.Sprintf("acc-test-%v.terraform.io", acctest.RandString(10)) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccPreCheck(t) + // AKS sets up some namespaceSelectors and thus we have to skip these tests + skipIfRunningInAks(t) + }, ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { diff --git a/kubernetes/provider_test.go b/kubernetes/provider_test.go index 9a069965e3..836d0b604f 100644 --- a/kubernetes/provider_test.go +++ b/kubernetes/provider_test.go @@ -295,6 +295,16 @@ func skipIfNotRunningInEks(t *testing.T) { } } +func skipIfRunningInAks(t *testing.T) { + isInAks, err := isRunningInAks() + if err != nil { + t.Fatal(err) + } + if isInAks { + t.Skip("This test cannot be run in AKS cluster") + } +} + func skipIfRunningInEks(t *testing.T) { isInEks, err := isRunningInEks() if err != nil { diff --git a/kubernetes/resource_kubernetes_mutating_webhook_configuration_test.go b/kubernetes/resource_kubernetes_mutating_webhook_configuration_test.go index 6904983c3f..bab9adcf01 100644 --- a/kubernetes/resource_kubernetes_mutating_webhook_configuration_test.go +++ b/kubernetes/resource_kubernetes_mutating_webhook_configuration_test.go @@ -21,7 +21,11 @@ func TestAccKubernetesMutatingWebhookConfiguration_basic(t *testing.T) { resourceName := "kubernetes_mutating_webhook_configuration.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccPreCheck(t) + // AKS sets up some namespaceSelectors and thus we have to skip these tests + skipIfRunningInAks(t) + }, IDRefreshName: resourceName, IDRefreshIgnore: []string{"metadata.0.resource_version"}, ProviderFactories: testAccProviderFactories, diff --git a/kubernetes/resource_kubernetes_mutating_webhook_configuration_v1_test.go b/kubernetes/resource_kubernetes_mutating_webhook_configuration_v1_test.go index 0ebcc894e8..435005823b 100644 --- a/kubernetes/resource_kubernetes_mutating_webhook_configuration_v1_test.go +++ b/kubernetes/resource_kubernetes_mutating_webhook_configuration_v1_test.go @@ -21,7 +21,11 @@ func TestAccKubernetesMutatingWebhookConfigurationV1_basic(t *testing.T) { resourceName := "kubernetes_mutating_webhook_configuration_v1.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccPreCheck(t) + // AKS sets up some namespaceSelectors and thus we have to skip these tests + skipIfRunningInAks(t) + }, IDRefreshName: resourceName, IDRefreshIgnore: []string{"metadata.0.resource_version"}, ProviderFactories: testAccProviderFactories, @@ -193,8 +197,7 @@ func testAccCheckKubernetesMutatingWebhookConfigurationV1Exists(n string) resour } func testAccKubernetesMutatingWebhookConfigurationV1Config_basic(name string) string { - return fmt.Sprintf(` -resource "kubernetes_mutating_webhook_configuration_v1" "test" { + return fmt.Sprintf(`resource "kubernetes_mutating_webhook_configuration_v1" "test" { metadata { name = %q } @@ -231,8 +234,7 @@ resource "kubernetes_mutating_webhook_configuration_v1" "test" { } func testAccKubernetesMutatingWebhookConfigurationV1Config_modified(name string) string { - return fmt.Sprintf(` -resource "kubernetes_mutating_webhook_configuration_v1" "test" { + return fmt.Sprintf(`resource "kubernetes_mutating_webhook_configuration_v1" "test" { metadata { name = %q } @@ -283,8 +285,7 @@ resource "kubernetes_mutating_webhook_configuration_v1" "test" { } func testAccKubernetesMutatingWebhookConfigurationV1Config_without_rules(name string) string { - return fmt.Sprintf(` -resource "kubernetes_mutating_webhook_configuration_v1" "test" { + return fmt.Sprintf(`resource "kubernetes_mutating_webhook_configuration_v1" "test" { metadata { name = %q } diff --git a/kubernetes/resource_kubernetes_persistent_volume_v1_test.go b/kubernetes/resource_kubernetes_persistent_volume_v1_test.go index f823b28cab..18d4ddf066 100644 --- a/kubernetes/resource_kubernetes_persistent_volume_v1_test.go +++ b/kubernetes/resource_kubernetes_persistent_volume_v1_test.go @@ -54,7 +54,6 @@ func TestAccKubernetesPersistentVolumeV1_azure_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInAks(t) }, - IDRefreshName: resourceName, IDRefreshIgnore: []string{"metadata.0.resource_version"}, ProviderFactories: testAccProviderFactories, ExternalProviders: testAccExternalProviders, @@ -121,7 +120,6 @@ func TestAccKubernetesPersistentVolumeV1_azure_blobStorageDisk(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInAks(t) }, - IDRefreshName: resourceName, IDRefreshIgnore: []string{"metadata.0.resource_version"}, ProviderFactories: testAccProviderFactories, ExternalProviders: testAccExternalProviders, @@ -179,7 +177,6 @@ func TestAccKubernetesPersistentVolumeV1_azure_file(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInAks(t) }, - IDRefreshName: resourceName, IDRefreshIgnore: []string{"metadata.0.resource_version"}, ProviderFactories: testAccProviderFactories, ExternalProviders: testAccExternalProviders, @@ -987,7 +984,7 @@ func testAccCheckKubernetesPersistentVolumeV1Destroy(s *terraform.State) error { poll := 1 * time.Second for _, rs := range s.RootModule().Resources { - if rs.Type != "kubernetes_persistent_volume.test" { + if rs.Type != "kubernetes_persistent_volume_v1.test" { continue } name := rs.Primary.ID @@ -1286,6 +1283,7 @@ func testAccKubernetesPersistentVolumeV1Config_azure_managedDisk(name, location return fmt.Sprintf(`provider "azurerm" { features {} } + resource "azurerm_resource_group" "test" { name = %[1]q location = %[2]q @@ -1293,6 +1291,7 @@ resource "azurerm_resource_group" "test" { environment = "terraform-provider-kubernetes-test" } } + resource "azurerm_managed_disk" "test" { name = %[1]q location = azurerm_resource_group.test.location @@ -1351,6 +1350,7 @@ func testAccKubernetesPersistentVolumeV1Config_azure_blobStorage(name, location return fmt.Sprintf(`provider "azurerm" { features {} } + resource "azurerm_resource_group" "test" { name = "%s" location = "%s" @@ -1358,6 +1358,7 @@ resource "azurerm_resource_group" "test" { environment = "terraform-provider-kubernetes-test" } } + resource "azurerm_storage_account" "test" { name = %[1]q resource_group_name = azurerm_resource_group.test.name @@ -1369,6 +1370,7 @@ resource "azurerm_storage_account" "test" { environment = "terraform-provider-kubernetes-test" } } + resource "azurerm_storage_container" "test" { name = %[1]q storage_account_name = azurerm_storage_account.test.name @@ -1442,6 +1444,7 @@ func testAccKubernetesPersistentVolumeV1Config_azure_file(name, location string) return fmt.Sprintf(`provider "azurerm" { features {} } + resource "azurerm_resource_group" "test" { name = "%s" location = "%s" @@ -1449,6 +1452,7 @@ resource "azurerm_resource_group" "test" { environment = "terraform-provider-kubernetes-test" } } + resource "azurerm_storage_account" "test" { name = %[1]q resource_group_name = azurerm_resource_group.test.name @@ -1462,6 +1466,7 @@ resource "azurerm_storage_account" "test" { environment = "terraform-provider-kubernetes-test" } } + resource "azurerm_storage_share" "test" { name = %[1]q storage_account_name = azurerm_storage_account.test.name diff --git a/kubernetes/resource_kubernetes_pod_v1_test.go b/kubernetes/resource_kubernetes_pod_v1_test.go index e7b8395ff2..7fca89db64 100644 --- a/kubernetes/resource_kubernetes_pod_v1_test.go +++ b/kubernetes/resource_kubernetes_pod_v1_test.go @@ -117,6 +117,7 @@ func TestAccKubernetesPodV1_scheduler(t *testing.T) { PreCheck: func() { testAccPreCheck(t) skipIfClusterVersionLessThan(t, "1.22.0") + skipIfRunningInAks(t) setClusterVersionVar(t, "TF_VAR_scheduler_cluster_version") // should be in format 'vX.Y.Z' }, ProviderFactories: testAccProviderFactories, diff --git a/kubernetes/resource_kubernetes_validating_webhook_configuration_v1_test.go b/kubernetes/resource_kubernetes_validating_webhook_configuration_v1_test.go index b7636d2fd9..f1d76eb4fe 100644 --- a/kubernetes/resource_kubernetes_validating_webhook_configuration_v1_test.go +++ b/kubernetes/resource_kubernetes_validating_webhook_configuration_v1_test.go @@ -21,7 +21,11 @@ func TestAccKubernetesValidatingWebhookConfigurationV1_basic(t *testing.T) { resourceName := "kubernetes_validating_webhook_configuration_v1.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccPreCheck(t) + // AKS sets up some namespaceSelectors and thus we have to skip these tests + skipIfRunningInAks(t) + }, IDRefreshName: resourceName, IDRefreshIgnore: []string{"metadata.0.resource_version"}, ProviderFactories: testAccProviderFactories,