Skip to content

Commit

Permalink
validate all paths
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Nov 26, 2024
1 parent e179ac9 commit 6289501
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/fixtures/safer_cluster_iap_bastion/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

locals {
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"
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'"
}

module "example" {
Expand Down
30 changes: 30 additions & 0 deletions test/integration/node_pool/node_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"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"
Expand Down Expand Up @@ -92,6 +93,35 @@ func TestNodePool(t *testing.T) {
g.JSONEq(assert, cluster, pth)
}

fmt.Println("one path")
g.JSONPathEqs(assert, cluster, []string{"autoscaling.autoprovisioningNodePoolDefaults.imageType"})

fmt.Println("multi path")
g.JSONPathEqs(assert, cluster, validateJSONPaths)

fmt.Println("START all paths 1")
// Test validating all Paths
jsonPaths := utils.GetJSONPaths(cluster)
//var wg sync.WaitGroup
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)
}
//wg.Wait()
fmt.Println("END all paths 1")

//fmt.Println("all paths 2")
// Test validating all Paths
//evalPaths := utils.GetJSONPaths(cluster)
//fmt.Println(evalPaths)
//g.JSONPathEqs(assert, cluster, evalPaths)

// Pool-01
assert.Equal("pool-01", cluster.Get("nodePools.#(name==\"pool-01\").name").String(), "pool-1 exists")
assert.Equal("e2-medium", cluster.Get("nodePools.#(name==\"pool-01\").config.machineType").String(), "is the expected machine type")
Expand Down

0 comments on commit 6289501

Please sign in to comment.