Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Jan 22, 2025
1 parent 860b855 commit ca300a3
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test/integration/node_pool/node_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestNodePool(t *testing.T) {
)

// Cluster (and listed node pools) Assertions
testutils.TGKEAssertGolden(assert, g, &cluster, []string{"pool-01", "pool-02", "pool-03", "pool-04", "pool-05"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
testutils.TGKEAssertGolden(t, assert, g, &cluster, []string{"pool-01", "pool-02", "pool-03", "pool-04", "pool-05"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL

// K8s Assertions
assert.JSONEq(`[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestSimpleRegionalWithGatewayAPI(t *testing.T) {
)

// Cluster Assertions
testutils.TGKEAssertGolden(assert, g, &cluster, []string{"default-pool"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
testutils.TGKEAssertGolden(t, assert, g, &cluster, []string{"default-pool"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
})
bpt.Test()
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestSimpleRegionalWithGatewayAPI(t *testing.T) {
)

// Cluster Assertions
testutils.TGKEAssertGolden(assert, g, &cluster, []string{"default-pool"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
testutils.TGKEAssertGolden(t, assert, g, &cluster, []string{"default-pool"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
})
bpt.Test()
}
2 changes: 1 addition & 1 deletion test/integration/stub_domains/stub_domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestStubDomains(t *testing.T) {
)

// Cluster Assertions
testutils.TGKEAssertGolden(assert, g, &cluster, []string{}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
testutils.TGKEAssertGolden(t, assert, g, &cluster, []string{}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL

// K8s Assertions
// CAI does not include k8s.io/ConfigMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestStubDomainsPrivate(t *testing.T) {
)

// Cluster Assertions
testutils.TGKEAssertGolden(assert, g, &cluster, []string{}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
testutils.TGKEAssertGolden(t, assert, g, &cluster, []string{}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL

// K8s Assertions
// CAI does not include k8s.io/ConfigMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestStubDomainsUpstreamNameservers(t *testing.T) {
)

// Cluster Assertions
testutils.TGKEAssertGolden(assert, g, &cluster, []string{"default-pool"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
testutils.TGKEAssertGolden(t, assert, g, &cluster, []string{"default-pool"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL

// K8s Assertions
// CAI does not include k8s.io/ConfigMap
Expand Down
12 changes: 8 additions & 4 deletions test/integration/testutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TGKEVerifyExemptResources(t *testing.T, b *tft.TFBlueprintTest, assert *ass
}

// TGKEAssertGolden asserts a cluster and listed node pools against paths in golden image
func TGKEAssertGolden(assert *assert.Assertions, golden *golden.GoldenFile, clusterJson *gjson.Result, nodePools []string, exemptClusterPaths []string) {
func TGKEAssertGolden(t *testing.T, assert *assert.Assertions, golden *golden.GoldenFile, clusterJson *gjson.Result, nodePools []string, exemptClusterPaths []string) {
// Retrieve golden paths
clusterCheckPaths := utils.GetTerminalJSONPaths(golden.GetJSON())

Expand All @@ -92,22 +92,26 @@ func TGKEAssertGolden(assert *assert.Assertions, golden *golden.GoldenFile, clus
})

// Cluster assertions
t.Logf("Found %d cluster paths to check", len(clusterCheckPaths))
golden.JSONPathEqs(assert, *clusterJson, clusterCheckPaths)

// NodePool assertions
for _, nodePool := range nodePools {
assert.Truef(clusterJson.Get(fmt.Sprintf("nodePools.#(name==%s).name", nodePool)).Exists(), "NodePool not found: %s", nodePool)

nodeCheckPaths := utils.GetTerminalJSONPaths(golden.GetJSON().Get(fmt.Sprintf("nodePools.#(name==%s)", nodePool)))
t.Logf("Found %d node %q paths to check", nodePool)

syncGroup := new(errgroup.Group)
syncGroup.SetLimit(24)
for _, nodeCheckPath := range nodeCheckPaths {
nodeCheckPath := nodeCheckPath
for i, nodeCheckPath := range nodeCheckPaths {
i, nodeCheckPath := i, nodeCheckPath // https://golang.org/doc/faq#closures_and_goroutines
nodePool := nodePool
syncGroup.Go(func() error {
t.Logf("Checking path %d: %s", i, nodeCheckPath)
gotData := golden.ApplySanitizers(clusterJson.Get(fmt.Sprintf("nodePools.#(name==%s)", nodePool)).Get(nodeCheckPath).String())
gfData := golden.GetJSON().Get(fmt.Sprintf("nodePools.#(name==%s)", nodePool)).Get(nodeCheckPath).String()
assert.Equalf(gfData, gotData, "For node %s path %q expected %q to match fixture %q", nodePool, nodeCheckPath, gotData, gfData)
assert.Equalf(gfData, gotData, "For node %q path %q expected %q to match fixture %q", nodePool, nodeCheckPath, gotData, gfData)
return nil
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestUpstreamNameservers(t *testing.T) {
)

// Cluster Assertions
testutils.TGKEAssertGolden(assert, g, &cluster, []string{}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
testutils.TGKEAssertGolden(t, assert, g, &cluster, []string{}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL

// K8s Assertions
// CAI does not include k8s.io/ConfigMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestWorkloadMetadataConfig(t *testing.T) {
)

// Cluster Assertions
testutils.TGKEAssertGolden(assert, g, &cluster, []string{"default-pool"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL
testutils.TGKEAssertGolden(t, assert, g, &cluster, []string{"default-pool"}, []string{"monitoringConfig.componentConfig.enableComponents"}) // TODO: enableComponents is UL

// IAM Assertions
// CAI IAM data can be stale
Expand Down

0 comments on commit ca300a3

Please sign in to comment.