Skip to content

Commit

Permalink
fix: add test for cloud-run v2 with gmp container
Browse files Browse the repository at this point in the history
  • Loading branch information
q2w committed Jan 22, 2025
1 parent 2459ef3 commit 6588cc3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
44 changes: 44 additions & 0 deletions test/integration/v2_with_gmp/v2_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2025 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 v2_with_gmp

import (
"fmt"
"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/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/utils"
"github.com/stretchr/testify/assert"
)

func TestV2WithGMP(t *testing.T) {
runV2GMP := tft.NewTFBlueprintTest(t)

runV2GMP.DefineVerify(func(assert *assert.Assertions) {
runV2GMP.DefaultVerify(assert)

projectID := runV2GMP.GetTFSetupStringOutput("project_id")
serviceName := runV2GMP.GetStringOutput("service_name")
serviceLocation := runV2GMP.GetStringOutput("service_location")

run_cmd := gcloud.Run(t, "run services describe", gcloud.WithCommonArgs([]string{serviceName, "--project", projectID, "--region", serviceLocation, "--format", "json"}))

// Verify the Cloud Run Service deployed is in ready state.
readyCondition := utils.GetFirstMatchResult(t, run_cmd.Get("status").Get("conditions").Array(), "type", "Ready")
assert.Equal("True", readyCondition.Get("status").String(), fmt.Sprintf("Should be in ready status"))
})
runV2GMP.Test()
}
3 changes: 2 additions & 1 deletion test/setup/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ locals {
"roles/artifactregistry.admin",
"roles/iam.serviceAccountUser",
"roles/serviceusage.serviceUsageViewer",
"roles/cloudkms.admin"
"roles/cloudkms.admin",
"roles/resourcemanager.projectIamAdmin"
]

folder_required_roles = [
Expand Down

0 comments on commit 6588cc3

Please sign in to comment.