Skip to content

Commit 0d32a5f

Browse files
committed
update for bpt 1.17
1 parent 0bff530 commit 0d32a5f

File tree

4 files changed

+20
-99
lines changed

4 files changed

+20
-99
lines changed

test/integration/node_pool/node_pool_test.go

Lines changed: 18 additions & 13 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,23 @@ 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
105+
jsonPaths := utils.GetTerminalJSONPaths(cluster)
106+
syncGroup := new(errgroup.Group)
107+
syncGroup.SetLimit(24)
106108
numJSONPaths := len(jsonPaths)
107109
t.Logf("checking %d JSON paths", numJSONPaths)
108-
//wg.Add(numJSONPaths)
109110
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)
111+
jsonPath := jsonPath
112+
syncGroup.Go(func() error {
113+
t.Logf("checking JSON path: %s", jsonPath)
114+
g.JSONEq(assert, cluster, jsonPath)
115+
return nil
116+
})
115117
}
116-
//wg.Wait()
118+
if err := syncGroup.Wait(); err != nil {
119+
t.Fatal(err)
120+
}
121+
117122
fmt.Println("END all paths 1")
118123

119124
//fmt.Println("all paths 2")
@@ -186,7 +191,7 @@ func TestNodePool(t *testing.T) {
186191
k8sOpts := k8s.KubectlOptions{}
187192
clusterNodesOp, err := k8s.RunKubectlAndGetOutputE(t, &k8sOpts, "get", "nodes", "-o", "json")
188193
assert.NoError(err)
189-
clusterNodes := testutils.ParseKubectlJSONResult(t, clusterNodesOp)
194+
clusterNodes := utils.ParseKubectlJSONResult(t, clusterNodesOp)
190195
assert.JSONEq(`[
191196
{
192197
"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/utils/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)