Skip to content

Commit 4e2345d

Browse files
committed
validate all paths
1 parent a6bc99e commit 4e2345d

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
@@ -15,12 +15,14 @@ package node_pool
1515

1616
import (
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

Comments
 (0)