Skip to content

Commit 015ee6b

Browse files
committed
chore(CI): migrate tests to CFT
1 parent d18755a commit 015ee6b

File tree

4 files changed

+50
-62
lines changed

4 files changed

+50
-62
lines changed

build/int.cloudbuild.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,17 +419,17 @@ steps:
419419
waitFor:
420420
- create-all
421421
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
422-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge safer-cluster-iap-bastion-local']
422+
args: ['/bin/bash', '-c', 'cft test run TestSaferClusterIapBastion --stage apply --verbose']
423423
- id: verify safer-cluster-iap-bastion-local
424424
waitFor:
425425
- converge safer-cluster-iap-bastion-local
426426
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
427-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify safer-cluster-iap-bastion-local']
427+
args: ['/bin/bash', '-c', 'cft test run TestSaferClusterIapBastion --stage verify --verbose']
428428
- id: destroy safer-cluster-iap-bastion-local
429429
waitFor:
430430
- verify safer-cluster-iap-bastion-local
431431
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
432-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy safer-cluster-iap-bastion-local']
432+
args: ['/bin/bash', '-c', 'cft test run TestSaferClusterIapBastion --stage teardown --verbose']
433433
- id: init simple-zonal-with-asm-local
434434
waitFor:
435435
- create-all

test/integration/safer_cluster_iap_bastion/controls/e2e.rb

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

test/integration/safer_cluster_iap_bastion/inspec.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2022-2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
package safer_cluster
15+
16+
import (
17+
"strings"
18+
"testing"
19+
"time"
20+
21+
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/gcloud"
22+
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
23+
"github.com/stretchr/testify/assert"
24+
"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"
26+
)
27+
28+
func TestSaferClusterIapBastion(t *testing.T) {
29+
bpt := tft.NewTFBlueprintTest(t,
30+
tft.WithRetryableTerraformErrors(testutils.RetryableTransientErrors, 3, 2*time.Minute),
31+
)
32+
33+
bpt.DefineVerify(func(assert *assert.Assertions) {
34+
//Skipping Default Verify as the Verify Stage fails due to change in Client Cert Token
35+
// bpt.DefaultVerify(assert)
36+
gkeutils.TGKEVerify(t, bpt, assert) // Verify Resources
37+
38+
test_command, _ := strings.CutPrefix(bpt.GetStringOutput("test_command"), "gcloud ")
39+
cluster_version := bpt.GetStringOutput("cluster_version")
40+
41+
op := gcloud.Runf(t, test_command)
42+
43+
assert.Equal(cluster_version, op.Get("gitVersion").String(), "SSH into VM and verify connectivity to GKE")
44+
})
45+
46+
bpt.Test()
47+
}

0 commit comments

Comments
 (0)