Skip to content

Commit 6289501

Browse files
committed
validate all paths
1 parent e179ac9 commit 6289501

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

test/fixtures/safer_cluster_iap_bastion/example.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
locals {
18-
test_command = "gcloud beta compute ssh ${module.example.bastion_name} --tunnel-through-iap --verbosity=error --project ${var.project_ids[1]} --zone ${module.example.bastion_zone} -q -- curl -sS https://${module.example.endpoint}/version -k"
18+
test_command = "gcloud beta compute ssh ${module.example.bastion_name} --tunnel-through-iap --verbosity=error --project ${var.project_ids[1]} --zone ${module.example.bastion_zone} -q --command='curl -sS https://${module.example.endpoint}/version -k'"
1919
}
2020

2121
module "example" {

test/integration/node_pool/node_pool_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/gcloud"
2222
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/golden"
2323
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
24+
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/utils"
2425
"github.com/gruntwork-io/terratest/modules/k8s"
2526
"github.com/stretchr/testify/assert"
2627
"github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils"
@@ -92,6 +93,35 @@ func TestNodePool(t *testing.T) {
9293
g.JSONEq(assert, cluster, pth)
9394
}
9495

96+
fmt.Println("one path")
97+
g.JSONPathEqs(assert, cluster, []string{"autoscaling.autoprovisioningNodePoolDefaults.imageType"})
98+
99+
fmt.Println("multi path")
100+
g.JSONPathEqs(assert, cluster, validateJSONPaths)
101+
102+
fmt.Println("START all paths 1")
103+
// Test validating all Paths
104+
jsonPaths := utils.GetJSONPaths(cluster)
105+
//var wg sync.WaitGroup
106+
numJSONPaths := len(jsonPaths)
107+
t.Logf("checking %d JSON paths", numJSONPaths)
108+
//wg.Add(numJSONPaths)
109+
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)
115+
}
116+
//wg.Wait()
117+
fmt.Println("END all paths 1")
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

Comments
 (0)