@@ -37,6 +37,45 @@ func TestAccGKE_ResourceNodeConfiguration(t *testing.T) {
3737 resource .TestCheckResourceAttr (resourceName , "eks.#" , "0" ),
3838 resource .TestCheckResourceAttr (resourceName , "kops.#" , "0" ),
3939 resource .TestCheckResourceAttr (resourceName , "gke.0.max_pods_per_node" , "31" ),
40+ resource .TestCheckResourceAttr (resourceName , "gke.0.max_pods_per_node_formula" , "" ),
41+ resource .TestCheckResourceAttr (resourceName , "gke.0.disk_type" , "pd-balanced" ),
42+ resource .TestCheckResourceAttr (resourceName , "gke.0.network_tags.0" , "ab" ),
43+ resource .TestCheckResourceAttr (resourceName , "gke.0.network_tags.1" , "bc" ),
44+ resource .TestCheckResourceAttr (resourceName , "gke.0.zones.#" , "0" ),
45+ resource .TestCheckResourceAttr (resourceName , "gke.0.on_host_maintenance" , "MIGRATE" ),
46+ ),
47+ },
48+ {
49+ Config : testAccGKENodeConfigurationConfigWithoutMaxPods (rName , clusterName , projectID ),
50+ Check : resource .ComposeTestCheckFunc (
51+ resource .TestCheckResourceAttr (resourceName , "name" , rName ),
52+ resource .TestCheckResourceAttr (resourceName , "disk_cpu_ratio" , "35" ),
53+ resource .TestCheckResourceAttr (resourceName , "drain_timeout_sec" , "10" ),
54+ resource .TestCheckResourceAttr (resourceName , "min_disk_size" , "122" ),
55+ resource .TestCheckResourceAttr (resourceName , "aks.#" , "0" ),
56+ resource .TestCheckResourceAttr (resourceName , "eks.#" , "0" ),
57+ resource .TestCheckResourceAttr (resourceName , "kops.#" , "0" ),
58+ resource .TestCheckResourceAttr (resourceName , "gke.0.max_pods_per_node" , "110" ),
59+ resource .TestCheckResourceAttr (resourceName , "gke.0.max_pods_per_node_formula" , "" ),
60+ resource .TestCheckResourceAttr (resourceName , "gke.0.disk_type" , "pd-balanced" ),
61+ resource .TestCheckResourceAttr (resourceName , "gke.0.network_tags.0" , "ab" ),
62+ resource .TestCheckResourceAttr (resourceName , "gke.0.network_tags.1" , "bc" ),
63+ resource .TestCheckResourceAttr (resourceName , "gke.0.zones.#" , "0" ),
64+ resource .TestCheckResourceAttr (resourceName , "gke.0.on_host_maintenance" , "MIGRATE" ),
65+ ),
66+ },
67+ {
68+ Config : testAccGKENodeConfigurationConfigWithMaxPodsFormula (rName , clusterName , projectID ),
69+ Check : resource .ComposeTestCheckFunc (
70+ resource .TestCheckResourceAttr (resourceName , "name" , rName ),
71+ resource .TestCheckResourceAttr (resourceName , "disk_cpu_ratio" , "35" ),
72+ resource .TestCheckResourceAttr (resourceName , "drain_timeout_sec" , "10" ),
73+ resource .TestCheckResourceAttr (resourceName , "min_disk_size" , "122" ),
74+ resource .TestCheckResourceAttr (resourceName , "aks.#" , "0" ),
75+ resource .TestCheckResourceAttr (resourceName , "eks.#" , "0" ),
76+ resource .TestCheckResourceAttr (resourceName , "kops.#" , "0" ),
77+ resource .TestCheckResourceAttr (resourceName , "gke.0.max_pods_per_node" , "0" ),
78+ resource .TestCheckResourceAttr (resourceName , "gke.0.max_pods_per_node_formula" , "NUM_CPU" ),
4079 resource .TestCheckResourceAttr (resourceName , "gke.0.disk_type" , "pd-balanced" ),
4180 resource .TestCheckResourceAttr (resourceName , "gke.0.network_tags.0" , "ab" ),
4281 resource .TestCheckResourceAttr (resourceName , "gke.0.network_tags.1" , "bc" ),
@@ -53,6 +92,7 @@ func TestAccGKE_ResourceNodeConfiguration(t *testing.T) {
5392 resource .TestCheckResourceAttr (resourceName , "eks.#" , "0" ),
5493 resource .TestCheckResourceAttr (resourceName , "kops.#" , "0" ),
5594 resource .TestCheckResourceAttr (resourceName , "gke.0.max_pods_per_node" , "32" ),
95+ resource .TestCheckResourceAttr (resourceName , "gke.0.max_pods_per_node_formula" , "" ),
5696 resource .TestCheckResourceAttr (resourceName , "gke.0.disk_type" , "pd-ssd" ),
5797 resource .TestCheckResourceAttr (resourceName , "gke.0.network_tags.0" , "bb" ),
5898 resource .TestCheckResourceAttr (resourceName , "gke.0.network_tags.1" , "dd" ),
@@ -81,6 +121,35 @@ func TestAccGKE_ResourceNodeConfiguration(t *testing.T) {
81121}
82122
83123func testAccGKENodeConfigurationConfig (rName , clusterName , projectID string ) string {
124+ const gkeParams = `
125+ max_pods_per_node = 31
126+ network_tags = ["ab", "bc"]
127+ disk_type = "pd-balanced"
128+ on_host_maintenance = "MIGRATE"
129+ `
130+ return testAccGKENodeConfigurationConfigWithGKEConfig (rName , clusterName , projectID , gkeParams )
131+ }
132+
133+ func testAccGKENodeConfigurationConfigWithoutMaxPods (rName , clusterName , projectID string ) string {
134+ const gkeParams = `
135+ network_tags = ["ab", "bc"]
136+ disk_type = "pd-balanced"
137+ on_host_maintenance = "MIGRATE"
138+ `
139+ return testAccGKENodeConfigurationConfigWithGKEConfig (rName , clusterName , projectID , gkeParams )
140+ }
141+
142+ func testAccGKENodeConfigurationConfigWithMaxPodsFormula (rName , clusterName , projectID string ) string {
143+ const gkeParams = `
144+ max_pods_per_node_formula = "NUM_CPU"
145+ network_tags = ["ab", "bc"]
146+ disk_type = "pd-balanced"
147+ on_host_maintenance = "MIGRATE"
148+ `
149+ return testAccGKENodeConfigurationConfigWithGKEConfig (rName , clusterName , projectID , gkeParams )
150+ }
151+
152+ func testAccGKENodeConfigurationConfigWithGKEConfig (rName , clusterName , projectID , gkeParams string ) string {
84153 return ConfigCompose (testAccGKEClusterConfig (rName , clusterName , projectID ), fmt .Sprintf (`
85154resource "castai_node_configuration" "test" {
86155 name = %[1]q
@@ -93,18 +162,15 @@ resource "castai_node_configuration" "test" {
93162 env = "development"
94163 }
95164 gke {
96- max_pods_per_node = 31
97- network_tags = ["ab", "bc"]
98- disk_type = "pd-balanced"
99- on_host_maintenance = "MIGRATE"
165+ %s
100166 }
101167}
102168
103169resource "castai_node_configuration_default" "test" {
104170 cluster_id = castai_gke_cluster.test.id
105171 configuration_id = castai_node_configuration.test.id
106172}
107- ` , rName ))
173+ ` , rName , gkeParams ))
108174}
109175
110176func testAccGKENodeConfigurationUpdated (rName , clusterName , projectID string ) string {
0 commit comments