Skip to content

Commit

Permalink
chore(CI): add new verify
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Aug 24, 2024
1 parent f67f416 commit cf16272
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
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
38 changes: 38 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,38 @@ func GetTestProjectFromSetup(t *testing.T, idx int) string {
}
return projectIDs[idx]
}

var (
verifySkipJSONPaths = []string{
"status",
"location",
"locations",
"privateClusterConfig.enablePrivateEndpoint",
"privateClusterConfig.enablePrivateNodes",
"addonsConfig.horizontalPodAutoscaling",
"addonsConfig.httpLoadBalancing",
"addonsConfig.kubernetesDashboard.disabled",
"addonsConfig.networkPolicyConfig.disabled",
"nodePools.name",
"nodePools.initialNodeCount",
"nodePools.autoscaling.enabled",
"nodePools.autoscaling.minNodeCount",
"nodePools.autoscaling.maxNodeCount",
"nodePools.config.machineType",
"nodePools.config.diskSizeGb",
"nodePools.config.labels",
"nodePools.config.tags",
"nodePools.management.autoRepair",
}
)

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

0 comments on commit cf16272

Please sign in to comment.