Skip to content

Commit 7e6d2fa

Browse files
committed
merge
1 parent 6289501 commit 7e6d2fa

File tree

4 files changed

+19
-101
lines changed

4 files changed

+19
-101
lines changed

test/integration/node_pool/node_pool_test.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ import (
1818
"testing"
1919
"time"
2020

21+
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/cai"
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"
2425
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/utils"
2526
"github.com/gruntwork-io/terratest/modules/k8s"
2627
"github.com/stretchr/testify/assert"
2728
"github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils"
28-
gkeutils "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/utils"
29+
"golang.org/x/sync/errgroup"
2930
)
3031

3132
func TestNodePool(t *testing.T) {
@@ -36,15 +37,15 @@ func TestNodePool(t *testing.T) {
3637
bpt.DefineVerify(func(assert *assert.Assertions) {
3738
// Skipping Default Verify as the Verify Stage fails due to change in Client Cert Token
3839
// bpt.DefaultVerify(assert)
39-
gkeutils.TGKEVerify(t, bpt, assert) // Verify Resources
40+
testutils.TGKEVerify(t, bpt, assert) // Verify Resources
4041

4142
projectId := bpt.GetStringOutput("project_id")
4243
location := bpt.GetStringOutput("location")
4344
clusterName := bpt.GetStringOutput("cluster_name")
4445

4546
// CAI
4647
clusterResourceName := fmt.Sprintf("//container.googleapis.com/projects/%s/locations/%s/clusters/%s", projectId, location, clusterName)
47-
cluster := gkeutils.GetProjectResources(t, projectId, gkeutils.WithAssetTypes([]string{"container.googleapis.com/Cluster"})).Get("#(name=\"" + clusterResourceName + "\").resource.data")
48+
cluster := cai.GetProjectResources(t, projectId, cai.WithAssetTypes([]string{"container.googleapis.com/Cluster"})).Get("#(name=\"" + clusterResourceName + "\").resource.data")
4849

4950
// Equivalent gcloud describe command
5051
// cluster := gcloud.Runf(t, "container clusters describe %s --zone %s --project %s", clusterName, location, projectId)
@@ -101,19 +102,20 @@ func TestNodePool(t *testing.T) {
101102

102103
fmt.Println("START all paths 1")
103104
// 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)
105+
jsonPaths := utils.GetTerminalJSONPaths(cluster)
106+
syncGroup := new(errgroup.Group)
107+
syncGroup.SetLimit(24)
108+
t.Logf("Checking %d JSON paths with max %d goroutines", len(jsonPaths), 24)
109109
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)
110+
jsonPath := jsonPath
111+
syncGroup.Go(func() error {
112+
g.JSONEq(assert, cluster, jsonPath)
113+
return nil
114+
})
115+
}
116+
if err := syncGroup.Wait(); err != nil {
117+
t.Fatal(err)
115118
}
116-
//wg.Wait()
117119
fmt.Println("END all paths 1")
118120

119121
//fmt.Println("all paths 2")
@@ -186,7 +188,7 @@ func TestNodePool(t *testing.T) {
186188
k8sOpts := k8s.KubectlOptions{}
187189
clusterNodesOp, err := k8s.RunKubectlAndGetOutputE(t, &k8sOpts, "get", "nodes", "-o", "json")
188190
assert.NoError(err)
189-
clusterNodes := testutils.ParseKubectlJSONResult(t, clusterNodesOp)
191+
clusterNodes := utils.ParseKubectlJSONResult(t, clusterNodesOp)
190192
assert.JSONEq(`[
191193
{
192194
"effect": "PreferNoSchedule",

test/integration/safer_cluster_iap_bastion/safer_cluster_iap_bastion_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
2424
"github.com/stretchr/testify/assert"
2525
"github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils"
26-
gkeutils "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/utils"
2726
)
2827

2928
func TestSaferClusterIapBastion(t *testing.T) {
@@ -34,7 +33,7 @@ func TestSaferClusterIapBastion(t *testing.T) {
3433
bpt.DefineVerify(func(assert *assert.Assertions) {
3534
// Skipping Default Verify as the Verify Stage fails due to change in Client Cert Token
3635
// bpt.DefaultVerify(assert)
37-
gkeutils.TGKEVerify(t, bpt, assert) // Verify Resources
36+
testutils.TGKEVerify(t, bpt, assert) // Verify Resources
3837

3938
test_command, _ := strings.CutPrefix(bpt.GetStringOutput("test_command"), "gcloud ")
4039

test/integration/testutils/cai.go

Lines changed: 0 additions & 82 deletions
This file was deleted.

test/integration/workload_identity/workload_identity_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
2323
"github.com/stretchr/testify/assert"
2424
"github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils"
25-
gkeutils "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/utils"
2625
)
2726

2827
func TestWorkloadIdentity(t *testing.T) {
@@ -33,7 +32,7 @@ func TestWorkloadIdentity(t *testing.T) {
3332
bpt.DefineVerify(func(assert *assert.Assertions) {
3433
// Skipping Default Verify as the Verify Stage fails due to change in Client Cert Token
3534
// bpt.DefaultVerify(assert)
36-
gkeutils.TGKEVerify(t, bpt, assert) // Verify Resources
35+
testutils.TGKEVerify(t, bpt, assert) // Verify Resources
3736

3837
projectId := bpt.GetStringOutput("project_id")
3938
location := bpt.GetStringOutput("location")

0 commit comments

Comments
 (0)