diff --git a/test/integration/go.mod b/test/integration/go.mod index f12198a..cbcbfc8 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -1,4 +1,4 @@ -module github.com/terraform-google-modules/three-tier-app/test/integration +module github.com/GoogleCloudPlatform/terraform-google-three-tier-web-app/test/integration go 1.22 diff --git a/test/integration/mysql/mysql_test.go b/test/integration/mysql/mysql_test.go index ef65eb9..f0319bb 100644 --- a/test/integration/mysql/mysql_test.go +++ b/test/integration/mysql/mysql_test.go @@ -19,6 +19,7 @@ import ( "time" "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" + test "github.com/GoogleCloudPlatform/terraform-google-three-tier-web-app/test/integration" "github.com/stretchr/testify/assert" ) @@ -36,6 +37,9 @@ func TestMysql(t *testing.T) { // DefaultVerify asserts no resource changes exist after apply. // It helps ensure that a second "terraform apply" wouldn't result in resource deletions/replacements. blueprintTest.DefaultVerify(assert) + + deploymentUrl := blueprintTest.GetStringOutput("endpoint") + test.TestDeploymentUrl(t, deploymentUrl) }) blueprintTest.Test() diff --git a/test/integration/simple_example/simple_example_test.go b/test/integration/simple_example/simple_example_test.go index 667d1ca..5d4893b 100644 --- a/test/integration/simple_example/simple_example_test.go +++ b/test/integration/simple_example/simple_example_test.go @@ -22,6 +22,7 @@ import ( "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" + test "github.com/GoogleCloudPlatform/terraform-google-three-tier-web-app/test/integration" "github.com/stretchr/testify/assert" ) @@ -130,6 +131,9 @@ func TestSimpleExample(t *testing.T) { assert.Equal("ENABLED", match.Get("state").String(), "%s service should be enabled", tc.service) }) } + + deploymentUrl := example.GetStringOutput("endpoint") + test.TestDeploymentUrl(t, deploymentUrl) }) example.Test() } diff --git a/test/integration/test_deployment_url.go b/test/integration/test_deployment_url.go new file mode 100644 index 0000000..5a171ec --- /dev/null +++ b/test/integration/test_deployment_url.go @@ -0,0 +1,35 @@ +// Copyright 2024 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 test + +import ( + "net/http" + "testing" + "time" + + "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/utils" +) + +func TestDeploymentUrl(t *testing.T, url string) error { + httpRequest, err := http.NewRequest("GET", url, nil) + if err != nil { + return err + } + maxRetries := 60 + waitBetweenRetries := 4 * time.Second + assertHttp := utils.NewAssertHTTP(utils.WithHTTPRequestRetries(maxRetries, waitBetweenRetries)) + assertHttp.AssertResponseWithRetry(t, httpRequest, http.StatusOK, "