Skip to content

Commit 09426e1

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

File tree

16 files changed

+1168
-87
lines changed

16 files changed

+1168
-87
lines changed

build/int.cloudbuild.yaml

Lines changed: 70 additions & 76 deletions
Large diffs are not rendered by default.

test/fixtures/deploy_service/example.tf

Lines changed: 6 additions & 3 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.
@@ -13,17 +13,20 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
locals {
17+
cluster_index = 2
18+
}
1619

1720
module "example" {
1821
source = "../../../examples/deploy_service"
1922

20-
project_id = var.project_ids[0]
23+
project_id = var.project_ids[local.cluster_index]
2124
cluster_name_suffix = "-${random_string.suffix.result}"
2225
region = var.region
2326
network = google_compute_network.main.name
2427
subnetwork = google_compute_subnetwork.main.name
2528
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
2629
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
27-
compute_engine_service_account = var.compute_engine_service_accounts[0]
30+
compute_engine_service_account = var.compute_engine_service_accounts[local.cluster_index]
2831
}
2932

test/fixtures/deploy_service/network.tf

Lines changed: 2 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.
@@ -21,7 +21,7 @@ resource "random_string" "suffix" {
2121
}
2222

2323
provider "google" {
24-
project = var.project_ids[0]
24+
project = var.project_ids[local.cluster_index]
2525
}
2626

2727
resource "google_compute_network" "main" {

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+
}

0 commit comments

Comments
 (0)