Skip to content

Commit

Permalink
Add an acceptance test for cluster upgrades with version aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
weisdd committed Jun 22, 2022
1 parent 8323e66 commit b21488e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import (
type KubernetesClusterResource struct{}

var (
olderKubernetesVersion = "1.21.7"
currentKubernetesVersion = "1.22.4"
olderKubernetesVersion = "1.21.7"
currentKubernetesVersion = "1.22.4"
olderKubernetesVersionAlias = "1.22"
currentKubernetesVersionAlias = "1.23"
)

func TestAccKubernetesCluster_hostEncryption(t *testing.T) {
Expand Down
31 changes: 31 additions & 0 deletions internal/services/containers/kubernetes_cluster_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,37 @@ func TestAccKubernetesCluster_upgradeCustomNodePoolBeforeControlPlaneFails(t *te
})
}

func TestAccKubernetesCluster_upgradeControlPlaneAndAllPoolsTogetherVersionAlias(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test")
r := KubernetesClusterResource{}
nodePoolName := "azurerm_kubernetes_cluster_node_pool.test"

data.ResourceTest(t, r, []acceptance.TestStep{
{
// all on the older version
Config: r.upgradeVersionsConfig(data, olderKubernetesVersionAlias, olderKubernetesVersionAlias, olderKubernetesVersionAlias),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("kubernetes_version").HasValue(olderKubernetesVersionAlias),
check.That(data.ResourceName).Key("default_node_pool.0.orchestrator_version").HasValue(olderKubernetesVersionAlias),
acceptance.TestCheckResourceAttr(nodePoolName, "orchestrator_version", olderKubernetesVersionAlias),
),
},
data.ImportStep(),
{
// upgrade control plane, default and custom node pools
Config: r.upgradeVersionsConfig(data, currentKubernetesVersionAlias, currentKubernetesVersionAlias, currentKubernetesVersionAlias),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("kubernetes_version").HasValue(currentKubernetesVersionAlias),
check.That(data.ResourceName).Key("default_node_pool.0.orchestrator_version").HasValue(currentKubernetesVersionAlias),
acceptance.TestCheckResourceAttr(nodePoolName, "orchestrator_version", currentKubernetesVersionAlias),
),
},
data.ImportStep(),
})
}

func TestAccKubernetesCluster_upgradeSettings(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test")
r := KubernetesClusterResource{}
Expand Down

0 comments on commit b21488e

Please sign in to comment.