@@ -15,12 +15,14 @@ package node_pool
1515
1616import (
1717 "fmt"
18+ "sync"
1819 "testing"
1920 "time"
2021
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"
25+ "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/utils"
2426 "github.com/gruntwork-io/terratest/modules/k8s"
2527 "github.com/stretchr/testify/assert"
2628 "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils"
@@ -92,6 +94,34 @@ func TestNodePool(t *testing.T) {
9294 g .JSONEq (assert , cluster , pth )
9395 }
9496
97+ fmt .Println ("one path" )
98+ g .JSONPathEqs (assert , cluster , []string {"autoscaling.autoprovisioningNodePoolDefaults.imageType" })
99+
100+ fmt .Println ("multi path" )
101+ g .JSONPathEqs (assert , cluster , validateJSONPaths )
102+
103+ fmt .Println ("all paths 1" )
104+ // Test validating all Paths
105+ jsonPaths := utils .GetJSONPaths (cluster )
106+ var wg sync.WaitGroup
107+ numJSONPaths := len (jsonPaths )
108+ t .Logf ("checking %d JSON paths" , numJSONPaths )
109+ wg .Add (numJSONPaths )
110+ for _ , jsonPath := range jsonPaths {
111+ go func (path string ) {
112+ defer wg .Done ()
113+ t .Logf ("checking JSON path: %s" , path )
114+ g .JSONEq (assert , cluster , path )
115+ }(jsonPath )
116+ }
117+ wg .Wait ()
118+
119+ fmt .Println ("all paths 2" )
120+ // Test validating all Paths
121+ evalPaths := utils .GetJSONPaths (cluster )
122+ fmt .Println (evalPaths )
123+ g .JSONPathEqs (assert , cluster , evalPaths )
124+
95125 // Pool-01
96126 assert .Equal ("pool-01" , cluster .Get ("nodePools.#(name==\" pool-01\" ).name" ).String (), "pool-1 exists" )
97127 assert .Equal ("e2-medium" , cluster .Get ("nodePools.#(name==\" pool-01\" ).config.machineType" ).String (), "is the expected machine type" )
0 commit comments