@@ -18,14 +18,15 @@ import (
1818 "testing"
1919 "time"
2020
21+ "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/cai"
2122 "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/gcloud"
2223 "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/golden"
2324 "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
2425 "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/utils"
2526 "github.com/gruntwork-io/terratest/modules/k8s"
2627 "github.com/stretchr/testify/assert"
2728 "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils"
28- gkeutils "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/utils "
29+ "golang.org/x/sync/errgroup "
2930)
3031
3132func TestNodePool (t * testing.T ) {
@@ -36,15 +37,15 @@ func TestNodePool(t *testing.T) {
3637 bpt .DefineVerify (func (assert * assert.Assertions ) {
3738 // Skipping Default Verify as the Verify Stage fails due to change in Client Cert Token
3839 // bpt.DefaultVerify(assert)
39- gkeutils .TGKEVerify (t , bpt , assert ) // Verify Resources
40+ testutils .TGKEVerify (t , bpt , assert ) // Verify Resources
4041
4142 projectId := bpt .GetStringOutput ("project_id" )
4243 location := bpt .GetStringOutput ("location" )
4344 clusterName := bpt .GetStringOutput ("cluster_name" )
4445
4546 // CAI
4647 clusterResourceName := fmt .Sprintf ("//container.googleapis.com/projects/%s/locations/%s/clusters/%s" , projectId , location , clusterName )
47- cluster := gkeutils .GetProjectResources (t , projectId , gkeutils .WithAssetTypes ([]string {"container.googleapis.com/Cluster" })).Get ("#(name=\" " + clusterResourceName + "\" ).resource.data" )
48+ cluster := cai .GetProjectResources (t , projectId , cai .WithAssetTypes ([]string {"container.googleapis.com/Cluster" })).Get ("#(name=\" " + clusterResourceName + "\" ).resource.data" )
4849
4950 // Equivalent gcloud describe command
5051 // cluster := gcloud.Runf(t, "container clusters describe %s --zone %s --project %s", clusterName, location, projectId)
@@ -101,19 +102,23 @@ func TestNodePool(t *testing.T) {
101102
102103 fmt .Println ("START all paths 1" )
103104 // Test validating all Paths
104- jsonPaths := utils .GetJSONPaths (cluster )
105- //var wg sync.WaitGroup
105+ jsonPaths := utils .GetTerminalJSONPaths (cluster )
106+ syncGroup := new (errgroup.Group )
107+ syncGroup .SetLimit (24 )
106108 numJSONPaths := len (jsonPaths )
107109 t .Logf ("checking %d JSON paths" , numJSONPaths )
108- //wg.Add(numJSONPaths)
109110 for _ , jsonPath := range jsonPaths {
110- func (path string ) {
111- //defer wg.Done()
112- t .Logf ("checking JSON path: %s" , path )
113- g .JSONEq (assert , cluster , path )
114- }(jsonPath )
111+ jsonPath := jsonPath
112+ syncGroup .Go (func () error {
113+ t .Logf ("checking JSON path: %s" , jsonPath )
114+ g .JSONEq (assert , cluster , jsonPath )
115+ return nil
116+ })
115117 }
116- //wg.Wait()
118+ if err := syncGroup .Wait (); err != nil {
119+ t .Fatal (err )
120+ }
121+
117122 fmt .Println ("END all paths 1" )
118123
119124 //fmt.Println("all paths 2")
@@ -186,7 +191,7 @@ func TestNodePool(t *testing.T) {
186191 k8sOpts := k8s.KubectlOptions {}
187192 clusterNodesOp , err := k8s .RunKubectlAndGetOutputE (t , & k8sOpts , "get" , "nodes" , "-o" , "json" )
188193 assert .NoError (err )
189- clusterNodes := testutils .ParseKubectlJSONResult (t , clusterNodesOp )
194+ clusterNodes := utils .ParseKubectlJSONResult (t , clusterNodesOp )
190195 assert .JSONEq (`[
191196 {
192197 "effect": "PreferNoSchedule",
0 commit comments