Skip to content

Commit

Permalink
update for bpt 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Nov 25, 2024
1 parent 0bff530 commit f1c5d65
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 98 deletions.
29 changes: 17 additions & 12 deletions test/integration/node_pool/node_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import (
"testing"
"time"

"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/cai"
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/gcloud"
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/golden"
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/utils"
"github.com/gruntwork-io/terratest/modules/k8s"
"github.com/stretchr/testify/assert"
"github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils"
gkeutils "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/utils"
"golang.org/x/sync/errgroup"
)

func TestNodePool(t *testing.T) {
Expand All @@ -36,15 +37,15 @@ func TestNodePool(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)
gkeutils.TGKEVerify(t, bpt, assert) // Verify Resources
testutils.TGKEVerify(t, bpt, assert) // Verify Resources

projectId := bpt.GetStringOutput("project_id")
location := bpt.GetStringOutput("location")
clusterName := bpt.GetStringOutput("cluster_name")

// CAI
clusterResourceName := fmt.Sprintf("//container.googleapis.com/projects/%s/locations/%s/clusters/%s", projectId, location, clusterName)
cluster := gkeutils.GetProjectResources(t, projectId, gkeutils.WithAssetTypes([]string{"container.googleapis.com/Cluster"})).Get("#(name=\"" + clusterResourceName + "\").resource.data")
cluster := cai.GetProjectResources(t, projectId, cai.WithAssetTypes([]string{"container.googleapis.com/Cluster"})).Get("#(name=\"" + clusterResourceName + "\").resource.data")

// Equivalent gcloud describe command
// cluster := gcloud.Runf(t, "container clusters describe %s --zone %s --project %s", clusterName, location, projectId)
Expand Down Expand Up @@ -102,18 +103,22 @@ func TestNodePool(t *testing.T) {
fmt.Println("START all paths 1")
// Test validating all Paths
jsonPaths := utils.GetJSONPaths(cluster)
//var wg sync.WaitGroup
syncGroup := new(errgroup.Group)
syncGroup.SetLimit(12)
numJSONPaths := len(jsonPaths)
t.Logf("checking %d JSON paths", numJSONPaths)
//wg.Add(numJSONPaths)
for _, jsonPath := range jsonPaths {
func(path string) {
//defer wg.Done()
t.Logf("checking JSON path: %s", path)
g.JSONEq(assert, cluster, path)
}(jsonPath)
jsonPath := jsonPath
syncGroup.Go(func() error {
t.Logf("checking JSON path: %s", jsonPath)
g.JSONEq(assert, cluster, jsonPath)
return nil
})
}
//wg.Wait()
if err := syncGroup.Wait(); err != nil {
t.Fatal(err)
}

fmt.Println("END all paths 1")

//fmt.Println("all paths 2")
Expand Down Expand Up @@ -186,7 +191,7 @@ func TestNodePool(t *testing.T) {
k8sOpts := k8s.KubectlOptions{}
clusterNodesOp, err := k8s.RunKubectlAndGetOutputE(t, &k8sOpts, "get", "nodes", "-o", "json")
assert.NoError(err)
clusterNodes := testutils.ParseKubectlJSONResult(t, clusterNodesOp)
clusterNodes := utils.ParseKubectlJSONResult(t, clusterNodesOp)
assert.JSONEq(`[
{
"effect": "PreferNoSchedule",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ 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"
gkeutils "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/utils"
)

func TestSaferClusterIapBastion(t *testing.T) {
Expand All @@ -34,7 +33,7 @@ func TestSaferClusterIapBastion(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)
gkeutils.TGKEVerify(t, bpt, assert) // Verify Resources
testutils.TGKEVerify(t, bpt, assert) // Verify Resources

test_command, _ := strings.CutPrefix(bpt.GetStringOutput("test_command"), "gcloud ")

Expand Down
82 changes: 0 additions & 82 deletions test/integration/utils/cai.go

This file was deleted.

3 changes: 1 addition & 2 deletions test/integration/workload_identity/workload_identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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"
gkeutils "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/utils"
)

func TestWorkloadIdentity(t *testing.T) {
Expand All @@ -33,7 +32,7 @@ func TestWorkloadIdentity(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)
gkeutils.TGKEVerify(t, bpt, assert) // Verify Resources
testutils.TGKEVerify(t, bpt, assert) // Verify Resources

projectId := bpt.GetStringOutput("project_id")
location := bpt.GetStringOutput("location")
Expand Down

0 comments on commit f1c5d65

Please sign in to comment.