@@ -121,13 +121,41 @@ func TestAccContainerCluster_withLegacyAbac(t *testing.T) {
121
121
}
122
122
123
123
func TestAccContainerCluster_withVersion (t * testing.T ) {
124
+ clusterName := fmt .Sprintf ("cluster-test-%s" , acctest .RandString (10 ))
125
+
124
126
resource .Test (t , resource.TestCase {
125
127
PreCheck : func () { testAccPreCheck (t ) },
126
128
Providers : testAccProviders ,
127
129
CheckDestroy : testAccCheckContainerClusterDestroy ,
128
130
Steps : []resource.TestStep {
129
131
{
130
- Config : testAccContainerCluster_withVersion ,
132
+ Config : testAccContainerCluster_withVersion (clusterName ),
133
+ Check : resource .ComposeTestCheckFunc (
134
+ testAccCheckContainerCluster (
135
+ "google_container_cluster.with_version" ),
136
+ ),
137
+ },
138
+ },
139
+ })
140
+ }
141
+
142
+ func TestAccContainerCluster_updateVersion (t * testing.T ) {
143
+ clusterName := fmt .Sprintf ("cluster-test-%s" , acctest .RandString (10 ))
144
+
145
+ resource .Test (t , resource.TestCase {
146
+ PreCheck : func () { testAccPreCheck (t ) },
147
+ Providers : testAccProviders ,
148
+ CheckDestroy : testAccCheckContainerClusterDestroy ,
149
+ Steps : []resource.TestStep {
150
+ {
151
+ Config : testAccContainerCluster_withLowerVersion (clusterName ),
152
+ Check : resource .ComposeTestCheckFunc (
153
+ testAccCheckContainerCluster (
154
+ "google_container_cluster.with_version" ),
155
+ ),
156
+ },
157
+ {
158
+ Config : testAccContainerCluster_withVersion (clusterName ),
131
159
Check : resource .ComposeTestCheckFunc (
132
160
testAccCheckContainerCluster (
133
161
"google_container_cluster.with_version" ),
@@ -586,7 +614,8 @@ resource "google_container_cluster" "with_legacy_abac" {
586
614
}` , clusterName )
587
615
}
588
616
589
- var testAccContainerCluster_withVersion = fmt .Sprintf (`
617
+ func testAccContainerCluster_withVersion (clusterName string ) string {
618
+ return fmt .Sprintf (`
590
619
data "google_container_engine_versions" "central1a" {
591
620
zone = "us-central1-a"
592
621
}
@@ -601,7 +630,27 @@ resource "google_container_cluster" "with_version" {
601
630
username = "mr.yoda"
602
631
password = "adoy.rm"
603
632
}
604
- }` , acctest .RandString (10 ))
633
+ }` , clusterName )
634
+ }
635
+
636
+ func testAccContainerCluster_withLowerVersion (clusterName string ) string {
637
+ return fmt .Sprintf (`
638
+ data "google_container_engine_versions" "central1a" {
639
+ zone = "us-central1-a"
640
+ }
641
+
642
+ resource "google_container_cluster" "with_version" {
643
+ name = "cluster-test-%s"
644
+ zone = "us-central1-a"
645
+ node_version = "${data.google_container_engine_versions.central1a.valid_master_versions.1}"
646
+ initial_node_count = 1
647
+
648
+ master_auth {
649
+ username = "mr.yoda"
650
+ password = "adoy.rm"
651
+ }
652
+ }` , clusterName )
653
+ }
605
654
606
655
var testAccContainerCluster_withNodeConfig = fmt .Sprintf (`
607
656
resource "google_container_cluster" "with_node_config" {
0 commit comments