Skip to content

Commit 870cd5c

Browse files
committed
chore(CI): migrate remaining kitchen tests
1 parent 9ad4082 commit 870cd5c

File tree

14 files changed

+1162
-79
lines changed

14 files changed

+1162
-79
lines changed

build/int.cloudbuild.yaml

Lines changed: 72 additions & 73 deletions
Large diffs are not rendered by default.

test/fixtures/simple_regional_with_gateway_api/outputs.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2018-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,3 +83,11 @@ output "service_account" {
8383
output "registry_project_ids" {
8484
value = var.registry_project_ids
8585
}
86+
87+
output "random_string" {
88+
value = random_string.suffix.result
89+
}
90+
91+
output "compute_engine_service_account" {
92+
value = var.compute_engine_service_accounts[local.cluster_index]
93+
}

test/fixtures/simple_regional_with_ipv6/outputs.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2018-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,3 +83,11 @@ output "service_account" {
8383
output "registry_project_ids" {
8484
value = var.registry_project_ids
8585
}
86+
87+
output "random_string" {
88+
value = random_string.suffix.result
89+
}
90+
91+
output "compute_engine_service_account" {
92+
value = var.compute_engine_service_accounts[local.cluster_index]
93+
}

test/fixtures/stub_domains_upstream_nameservers/example.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2018-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,6 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17+
locals {
18+
compute_engine_service_account = var.compute_engine_service_accounts[1]
19+
}
20+
1721
module "example" {
1822
source = "../../../examples/stub_domains_upstream_nameservers"
1923

@@ -24,6 +28,6 @@ module "example" {
2428
subnetwork = google_compute_subnetwork.main.name
2529
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
2630
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
27-
compute_engine_service_account = var.compute_engine_service_accounts[1]
31+
compute_engine_service_account = local.compute_engine_service_account
2832
}
2933

test/fixtures/stub_domains_upstream_nameservers/outputs.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2018-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,3 +56,11 @@ output "service_account" {
5656
description = "The service account to default running nodes as if not overridden in `node_pools`."
5757
value = module.example.service_account
5858
}
59+
60+
output "random_string" {
61+
value = random_string.suffix.result
62+
}
63+
64+
output "compute_engine_service_account" {
65+
value = local.compute_engine_service_account
66+
}

test/fixtures/workload_metadata_config/outputs.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2018-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,3 +56,7 @@ output "service_account" {
5656
description = "The service account to default running nodes as if not overridden in `node_pools`."
5757
value = module.example.service_account
5858
}
59+
60+
output "random_string" {
61+
value = random_string.suffix.result
62+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright 2024-2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
package node_pool
15+
16+
import (
17+
"fmt"
18+
"testing"
19+
"time"
20+
21+
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/cai"
22+
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/golden"
23+
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
24+
"github.com/stretchr/testify/assert"
25+
"github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils"
26+
)
27+
28+
func TestSimpleRegionalWithGatewayAPI(t *testing.T) {
29+
bpt := tft.NewTFBlueprintTest(t,
30+
tft.WithRetryableTerraformErrors(testutils.RetryableTransientErrors, 3, 2*time.Minute),
31+
)
32+
33+
bpt.DefineVerify(func(assert *assert.Assertions) {
34+
// Skipping Default Verify as the Verify Stage fails due to change in Client Cert Token
35+
// bpt.DefaultVerify(assert)
36+
testutils.TGKEVerify(t, bpt, assert) // Verify Resources
37+
38+
projectId := bpt.GetStringOutput("project_id")
39+
location := bpt.GetStringOutput("location")
40+
clusterName := bpt.GetStringOutput("cluster_name")
41+
randomString := bpt.GetStringOutput("random_string")
42+
kubernetesEndpoint := bpt.GetStringOutput("kubernetes_endpoint")
43+
nodeServiceAccount := bpt.GetStringOutput("compute_engine_service_account")
44+
45+
// Retrieve Project CAI
46+
projectCAI := cai.GetProjectResources(t, projectId, cai.WithAssetTypes([]string{"container.googleapis.com/Cluster"}))
47+
48+
// Retrieve Cluster from CAI
49+
// Equivalent gcloud describe command (classic)
50+
// cluster := gcloud.Runf(t, "container clusters describe %s --zone %s --project %s", clusterName, location, projectId)
51+
clusterResourceName := fmt.Sprintf("//container.googleapis.com/projects/%s/locations/%s/clusters/%s", projectId, location, clusterName)
52+
cluster := projectCAI.Get("#(name=\"" + clusterResourceName + "\").resource.data")
53+
54+
// Setup golden image with sanitizers
55+
g := golden.NewOrUpdate(t, cluster.String(),
56+
golden.WithSanitizer(golden.StringSanitizer(nodeServiceAccount, "NODE_SERVICE_ACCOUNT")),
57+
golden.WithSanitizer(golden.StringSanitizer(projectId, "PROJECT_ID")),
58+
golden.WithSanitizer(golden.StringSanitizer(randomString, "RANDOM_STRING")),
59+
golden.WithSanitizer(golden.StringSanitizer(kubernetesEndpoint, "KUBERNETES_ENDPOINT")),
60+
)
61+
62+
// Cluster Assertions
63+
testutils.TGKEAssertGolden(assert, g, &cluster, []string{"default-pool"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
64+
})
65+
bpt.Test()
66+
}
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
{
2+
"addonsConfig": {
3+
"configConnectorConfig": {},
4+
"dnsCacheConfig": {},
5+
"gcePersistentDiskCsiDriverConfig": {
6+
"enabled": true
7+
},
8+
"gcpFilestoreCsiDriverConfig": {},
9+
"gkeBackupAgentConfig": {},
10+
"horizontalPodAutoscaling": {},
11+
"httpLoadBalancing": {},
12+
"kubernetesDashboard": {
13+
"disabled": true
14+
},
15+
"networkPolicyConfig": {
16+
"disabled": true
17+
}
18+
},
19+
"autopilot": {},
20+
"autoscaling": {
21+
"autoscalingProfile": "BALANCED"
22+
},
23+
"binaryAuthorization": {},
24+
"clusterIpv4Cidr": "192.168.0.0/18",
25+
"controlPlaneEndpointsConfig": {
26+
"dnsEndpointConfig": {
27+
"allowExternalTraffic": false
28+
},
29+
"ipEndpointsConfig": {
30+
"authorizedNetworksConfig": {
31+
"gcpPublicCidrsAccessEnabled": true
32+
},
33+
"enablePublicEndpoint": true,
34+
"enabled": true,
35+
"privateEndpoint": "10.0.0.2",
36+
"publicEndpoint": "KUBERNETES_ENDPOINT"
37+
}
38+
},
39+
"currentNodeCount": 3,
40+
"databaseEncryption": {
41+
"currentState": "CURRENT_STATE_DECRYPTED",
42+
"state": "DECRYPTED"
43+
},
44+
"defaultMaxPodsConstraint": {
45+
"maxPodsPerNode": "110"
46+
},
47+
"endpoint": "KUBERNETES_ENDPOINT",
48+
"enterpriseConfig": {
49+
"clusterTier": "STANDARD"
50+
},
51+
"identityServiceConfig": {},
52+
"ipAllocationPolicy": {
53+
"clusterIpv4Cidr": "192.168.0.0/18",
54+
"clusterIpv4CidrBlock": "192.168.0.0/18",
55+
"clusterSecondaryRangeName": "cft-gke-test-pods-RANDOM_STRING",
56+
"defaultPodIpv4RangeUtilization": 0.0469,
57+
"podCidrOverprovisionConfig": {},
58+
"servicesIpv4Cidr": "192.168.64.0/18",
59+
"servicesIpv4CidrBlock": "192.168.64.0/18",
60+
"servicesSecondaryRangeName": "cft-gke-test-services-RANDOM_STRING",
61+
"stackType": "IPV4",
62+
"useIpAliases": true
63+
},
64+
"labelFingerprint": "78cdf2f6",
65+
"legacyAbac": {},
66+
"location": "us-central1",
67+
"loggingConfig": {
68+
"componentConfig": {
69+
"enableComponents": [
70+
"SYSTEM_COMPONENTS",
71+
"WORKLOADS"
72+
]
73+
}
74+
},
75+
"loggingService": "logging.googleapis.com/kubernetes",
76+
"maintenancePolicy": {
77+
"resourceVersion": "ce912209",
78+
"window": {
79+
"dailyMaintenanceWindow": {
80+
"duration": "PT4H0M0S",
81+
"startTime": "05:00"
82+
}
83+
}
84+
},
85+
"masterAuth": {
86+
"clientCertificateConfig": {}
87+
},
88+
"masterAuthorizedNetworksConfig": {
89+
"gcpPublicCidrsAccessEnabled": true
90+
},
91+
"meshCertificates": {
92+
"enableCertificates": false
93+
},
94+
"monitoringConfig": {
95+
"advancedDatapathObservabilityConfig": {},
96+
"componentConfig": {
97+
"enableComponents": [
98+
"SYSTEM_COMPONENTS",
99+
"STORAGE",
100+
"HPA",
101+
"POD",
102+
"DAEMONSET",
103+
"DEPLOYMENT",
104+
"STATEFULSET",
105+
"CADVISOR",
106+
"KUBELET"
107+
]
108+
},
109+
"managedPrometheusConfig": {
110+
"enabled": true
111+
}
112+
},
113+
"monitoringService": "monitoring.googleapis.com/kubernetes",
114+
"name": "stub-domains-cluster-RANDOM_STRING",
115+
"network": "cft-gke-test-RANDOM_STRING",
116+
"networkConfig": {
117+
"defaultSnatStatus": {},
118+
"network": "projects/PROJECT_ID/global/networks/cft-gke-test-RANDOM_STRING",
119+
"serviceExternalIpsConfig": {},
120+
"subnetwork": "projects/PROJECT_ID/regions/us-central1/subnetworks/cft-gke-test-RANDOM_STRING"
121+
},
122+
"nodeConfig": {
123+
"diskSizeGb": 100,
124+
"diskType": "pd-balanced",
125+
"effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V2",
126+
"gcfsConfig": {},
127+
"imageType": "COS_CONTAINERD",
128+
"loggingConfig": {
129+
"variantConfig": {
130+
"variant": "DEFAULT"
131+
}
132+
},
133+
"machineType": "e2-medium",
134+
"metadata": {
135+
"disable-legacy-endpoints": "true"
136+
},
137+
"oauthScopes": [
138+
"https://www.googleapis.com/auth/userinfo.email",
139+
"https://www.googleapis.com/auth/cloud-platform"
140+
],
141+
"shieldedInstanceConfig": {
142+
"enableIntegrityMonitoring": true
143+
},
144+
"tags": [
145+
"gke-stub-domains-cluster-RANDOM_STRING",
146+
"gke-stub-domains-cluster-RANDOM_STRING-default-pool"
147+
],
148+
"windowsNodeConfig": {},
149+
"workloadMetadataConfig": {
150+
"mode": "GKE_METADATA"
151+
}
152+
},
153+
"nodePoolDefaults": {
154+
"nodeConfigDefaults": {
155+
"gcfsConfig": {},
156+
"loggingConfig": {
157+
"variantConfig": {
158+
"variant": "DEFAULT"
159+
}
160+
},
161+
"nodeKubeletConfig": {}
162+
}
163+
},
164+
"notificationConfig": {
165+
"pubsub": {}
166+
},
167+
"privateClusterConfig": {
168+
"privateEndpoint": "10.0.0.2",
169+
"publicEndpoint": "KUBERNETES_ENDPOINT"
170+
},
171+
"rbacBindingConfig": {
172+
"enableInsecureBindingSystemAuthenticated": true,
173+
"enableInsecureBindingSystemUnauthenticated": true
174+
},
175+
"releaseChannel": {
176+
"channel": "REGULAR"
177+
},
178+
"resourceLabels": {
179+
"goog-terraform-provisioned": "true"
180+
},
181+
"securityPostureConfig": {
182+
"mode": "DISABLED",
183+
"vulnerabilityMode": "VULNERABILITY_DISABLED"
184+
},
185+
"selfLink": "https://container.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/clusters/stub-domains-cluster-RANDOM_STRING",
186+
"servicesIpv4Cidr": "192.168.64.0/18",
187+
"shieldedNodes": {
188+
"enabled": true
189+
},
190+
"status": "RUNNING",
191+
"subnetwork": "cft-gke-test-RANDOM_STRING",
192+
"verticalPodAutoscaling": {},
193+
"workloadIdentityConfig": {
194+
"workloadPool": "PROJECT_ID.svc.id.goog"
195+
},
196+
"zone": "us-central1"
197+
}

0 commit comments

Comments
 (0)