Skip to content

Commit

Permalink
chore: Adding test Upgrade for 4 tests (#1561)
Browse files Browse the repository at this point in the history
Co-authored-by: Akshay Bathija <akshaybathija@google.com>
Co-authored-by: Bharath KKB <bharathkrishnakb@gmail.com>
  • Loading branch information
3 people committed Feb 16, 2023
1 parent b03ea84 commit b96eda3
Show file tree
Hide file tree
Showing 16 changed files with 1,134 additions and 503 deletions.
64 changes: 42 additions & 22 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,26 @@ steps:
- verify disable-client-cert
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestDisableClientCert --stage teardown --verbose --test-dir test/integration']
- id: converge shared-vpc-local
- id: init shared-vpc-local
waitFor:
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge shared-vpc-local']
args: ['/bin/bash', '-c', 'cft test run TestSharedVPC --stage init --verbose --test-dir test/integration']
- id: apply shared-vpc-local
waitFor:
- init shared-vpc-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestSharedVPC --stage apply --verbose --test-dir test/integration']
- id: verify shared-vpc-local
waitFor:
- converge shared-vpc-local
- apply shared-vpc-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify shared-vpc-local']
args: ['/bin/bash', '-c', 'cft test run TestSharedVPC --stage verify --verbose --test-dir test/integration']
- id: destroy shared-vpc-local
waitFor:
- verify shared-vpc-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy shared-vpc-local']
args: ['/bin/bash', '-c', 'cft test run TestSharedVPC --stage teardown --verbose --test-dir test/integration']
- id: init safer-cluster-local
waitFor:
- create all
Expand All @@ -81,21 +86,26 @@ steps:
- verify safer-cluster-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestSaferCluster --stage destroy --verbose']
- id: converge simple-regional-local
- id: init simple-regional-local
waitFor:
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-regional-local']
args: ['/bin/bash', '-c', 'cft test run TestSimpleRegional --stage init --verbose']
- id: apply simple-regional-local
waitFor:
- init simple-regional-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestSimpleRegional --stage apply --verbose']
- id: verify simple-regional-local
waitFor:
- converge simple-regional-local
- apply simple-regional-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-regional-local']
args: ['/bin/bash', '-c', 'cft test run TestSimpleRegional --stage verify --verbose']
- id: destroy simple-regional-local
waitFor:
- verify simple-regional-local
- apply simple-regional-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-local']
args: ['/bin/bash', '-c', 'cft test run TestSimpleRegional --stage teardown --verbose']
- id: converge simple-regional-private-local
waitFor:
- create all
Expand Down Expand Up @@ -381,36 +391,46 @@ steps:
- verify simple-zonal-with-asm-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-zonal-with-asm-local']
- id: converge simple-autopilot-private-local
- id: init simple-autopilot-private-local
waitFor:
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-autopilot-private-local']
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPrivate --stage init --verbose']
- id: apply simple-autopilot-private-local
waitFor:
- init simple-autopilot-private-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPrivate --stage apply --verbose']
- id: verify simple-autopilot-private-local
waitFor:
- converge simple-autopilot-private-local
- apply simple-autopilot-private-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-autopilot-private-local']
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPrivate --stage verify --verbose']
- id: destroy simple-autopilot-private-local
waitFor:
- verify simple-autopilot-private-local
- apply simple-autopilot-private-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-autopilot-private-local']
- id: converge simple-autopilot-public-local
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPrivate --stage teardown --verbose']
- id: init simple-autopilot-public-local
waitFor:
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-autopilot-public-local']
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPublic --stage init --verbose']
- id: apply simple-autopilot-public-local
waitFor:
- init simple-autopilot-public-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPublic --stage apply --verbose']
- id: verify simple-autopilot-public-local
waitFor:
- converge simple-autopilot-public-local
- apply simple-autopilot-public-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-autopilot-public-local']
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPublic --stage verify --verbose']
- id: destroy simple-autopilot-public-local
waitFor:
- verify simple-autopilot-public-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-autopilot-public-local']
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPublic --stage teardown --verbose']
- id: init private-zonal-with-networking
waitFor:
- prepare
Expand Down
39 changes: 0 additions & 39 deletions test/integration/shared_vpc/controls/gcloud.rb

This file was deleted.

25 changes: 0 additions & 25 deletions test/integration/shared_vpc/inspec.yml

This file was deleted.

40 changes: 40 additions & 0 deletions test/integration/shared_vpc/shared_vpc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shared_vpc

import (
"testing"

"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/gcloud"
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
"github.com/stretchr/testify/assert"
)

func TestSharedVPC(t *testing.T) {
bpt := tft.NewTFBlueprintTest(t)

bpt.DefineVerify(func(assert *assert.Assertions) {
//Skipping Default Verify as the Verify Stage fails due to change in Client Cert Token
// bpt.DefaultVerify(assert)

projectId := bpt.GetStringOutput("project_id")
location := bpt.GetStringOutput("location")
clusterName := bpt.GetStringOutput("cluster_name")

op := gcloud.Runf(t, "container clusters describe %s --zone %s --project %s", clusterName, location, projectId)
assert.Contains(op.Get("status").String(), "RUNNING", "Cluster is Running")
})

bpt.Test()
}
68 changes: 0 additions & 68 deletions test/integration/simple_autopilot_private/controls/gcloud.rb

This file was deleted.

31 changes: 0 additions & 31 deletions test/integration/simple_autopilot_private/inspec.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package simple_autopilot_private

import (
"testing"

"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/stretchr/testify/assert"
)

func TestSimpleAutopilotPrivate(t *testing.T) {
bpt := tft.NewTFBlueprintTest(t)

bpt.DefineVerify(func(assert *assert.Assertions) {
//Skipping Default Verify as the Verify Stage fails due to change in Client Cert Token
// bpt.DefaultVerify(assert)

projectId := bpt.GetStringOutput("project_id")
location := bpt.GetStringOutput("location")
clusterName := bpt.GetStringOutput("cluster_name")
serviceAccount := bpt.GetStringOutput("service_account")

op := gcloud.Runf(t, "container clusters describe %s --zone %s --project %s", clusterName, location, projectId)
g := golden.NewOrUpdate(t, op.String(),
golden.WithSanitizer(golden.StringSanitizer(serviceAccount, "SERVICE_ACCOUNT")),
golden.WithSanitizer(golden.StringSanitizer(projectId, "PROJECT_ID")),
golden.WithSanitizer(golden.StringSanitizer(clusterName, "CLUSTER_NAME")),
)
validateJSONPaths := []string{
"autopilot.enabled",
"location",
"privateClusterConfig.enablePrivateEndpoint",
"privateClusterConfig.enablePrivateNodes",
"addonsConfig.horizontalPodAutoscaling",
"addonsConfig.httpLoadBalancing",
"addonsConfig.kubernetesDashboard.disabled",
"addonsConfig.networkPolicyConfig.disabled",
}
for _, pth := range validateJSONPaths {
g.JSONEq(assert, op, pth)
}
assert.Contains([]string{"RUNNING", "RECONCILING"}, op.Get("status").String())
})

bpt.Test()
}
Loading

0 comments on commit b96eda3

Please sign in to comment.