Skip to content

chore(CI): add new verify (DO NOT MERGE) #2060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/simple_autopilot_public/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ locals {
cluster_type = "simple-autopilot-public"
network_name = "simple-autopilot-public-network"
subnet_name = "simple-autopilot-public-subnet"
master_auth_subnetwork = "simple-autopilot-public-master-subnet"
pods_range_name = "ip-range-pods-simple-autopilot-public"
svc_range_name = "ip-range-svc-simple-autopilot-public"
subnet_names = [for subnet_self_link in module.gcp-network.subnets_self_links : split("/", subnet_self_link)[length(split("/", subnet_self_link)) - 1]]
Expand Down Expand Up @@ -52,6 +51,7 @@ module "gke" {
gcs_fuse_csi_driver = true
stateful_ha = false
gke_backup_agent_config = false
enable_gcfs = true
ray_operator_config = {
enabled = true
logging_enabled = true
Expand Down
12 changes: 4 additions & 8 deletions examples/simple_autopilot_public/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ module "gcp-network" {

subnets = [
{
subnet_name = local.subnet_name
subnet_ip = "10.0.0.0/17"
subnet_region = var.region
},
{
subnet_name = local.master_auth_subnetwork
subnet_ip = "10.60.0.0/17"
subnet_region = var.region
subnet_name = local.subnet_name
subnet_ip = "10.0.0.0/17"
subnet_region = var.region
subnet_private_access = true
},
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
"github.com/stretchr/testify/assert"
"github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils"
"github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/utils"
)

func TestSimpleAutopilotPublic(t *testing.T) {
Expand All @@ -32,6 +33,8 @@ func TestSimpleAutopilotPublic(t *testing.T) {
bpt.DefineVerify(func(assert *assert.Assertions) {
//Skipping Default Verify as the Verify Stage fails due to change in Client Cert Token
// bpt.DefaultVerify(assert)
utils.TGKEVerify(t, bpt, assert)
bpt.DefaultVerify(assert)

projectId := bpt.GetStringOutput("project_id")
location := bpt.GetStringOutput("location")
Expand Down
19 changes: 19 additions & 0 deletions test/integration/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
package utils

import (
"slices"
"testing"
"time"

"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
tfjson "github.com/hashicorp/terraform-json"
"github.com/stretchr/testify/assert"
"github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils"
)

Expand All @@ -32,3 +35,19 @@ func GetTestProjectFromSetup(t *testing.T, idx int) string {
}
return projectIDs[idx]
}

var (
// TGKEVerify Exempt Resources. e.g. google_container_cluster.primary
verifyExemptResources = []string{}
)

func TGKEVerify(t *testing.T, b *tft.TFBlueprintTest, assert *assert.Assertions) {
_, ps := b.PlanAndShow()
for _, r := range ps.ResourceChangesMap {
if slices.Contains(verifyExemptResources, r.Address) {
t.Logf("Exempt plan address: %s", r.Address)
continue
}
assert.Equal(tfjson.Actions{tfjson.ActionNoop}, r.Change.Actions, "plan must be no-op for resource: %s", r.Address)
}
}
Loading