Skip to content

Commit

Permalink
Fix e2d tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amandakarina committed Nov 14, 2024
1 parent 7d1dea5 commit 35d83fd
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ steps:
- id: app-e2e
name: "gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS"
args:
["/bin/bash", "-c", "sleep 60s && cft test run TestAppE2E --stage verify --verbose"]
["/bin/bash", "-c", "sleep 60s && cft test run TestAppE2EMultitenent --stage verify --verbose"]
waitFor:
- appsource-verify-cymbal-bank
- id: appinfra-teardown
Expand Down
5 changes: 4 additions & 1 deletion test/integration/cymbal-bank/e2e_single_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import (
)

func TestAppE2ECymbalBankSingleProject(t *testing.T) {
standaloneSingleProj := tft.NewTFBlueprintTest(t, tft.WithTFDir("../../../examples/standalone_single_project"))
// initialize Terraform test from the Blueprints test framework
setupOutput := tft.NewTFBlueprintTest(t)
projectID := setupOutput.GetTFSetupStringOutput("project_id_standalone")
standaloneSingleProj := tft.NewTFBlueprintTest(t, tft.WithVars(map[string]interface{}{"project_id": projectID}), tft.WithTFDir("../../../examples/standalone_single_project"))
t.Run("End to end tests Single project", func(t *testing.T) {
jar, err := cookiejar.New(nil)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/cymbal-bank/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const (
maxRetries int = 30
)

func TestAppE2E(t *testing.T) {
func TestAppE2EMultitenent(t *testing.T) {
multitenant := tft.NewTFBlueprintTest(t, tft.WithTFDir("../../../2-multitenant/envs/development"))
t.Run("End to end tests", func(t *testing.T) {
t.Run("End to end tests Cymbal Bank Multitenant", func(t *testing.T) {
jar, err := cookiejar.New(nil)
if err != nil {
t.Fatal(err)
Expand Down
16 changes: 16 additions & 0 deletions test/integration/multitenant/multitenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ func TestMultitenant(t *testing.T) {
}
})

multitenant.DefineTeardown(func(assert *assert.Assertions) {
multitenant := tft.NewTFBlueprintTest(t,
tft.WithTFDir(fmt.Sprintf("../../../2-multitenant/envs/%s", envName)),
tft.WithRetryableTerraformErrors(testutils.RetryableTransientErrors, 3, 2*time.Minute),
tft.WithBackendConfig(backendConfig),
)
clusterProjectID := multitenant.GetStringOutput("cluster_project_id")
// removes firewall rules created by the service but not being deleted.
firewallRules := gcloud.Runf(t, "compute firewall-rules list --project %s --filter=\"mcsd\"", clusterProjectID).Array()
for i := range firewallRules {
gcloud.Runf(t, "compute firewall-rules delete %s --project %s -q", firewallRules[i].Get("name"), clusterProjectID)
}
multitenant.DefaultTeardown(assert)

})

multitenant.Test()
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestSingleProjectSourceCymbalBank(t *testing.T) {
// initialize Terraform test from the Blueprints test framework
setupOutput := tft.NewTFBlueprintTest(t)
projectID := setupOutput.GetTFSetupStringOutput("project_id_standalone")
standaloneSingleProj := tft.NewTFBlueprintTest(t, tft.WithTFDir("../../../examples/standalone_single_project"))
standaloneSingleProj := tft.NewTFBlueprintTest(t, tft.WithVars(map[string]interface{}{"project_id": projectID}), tft.WithTFDir("../../../examples/standalone_single_project"))
envName := standaloneSingleProj.GetStringOutput("env")
env_cluster_membership_ids[envName] = make(map[string][]string, 0)
env_cluster_membership_ids[envName]["cluster_membership_ids"] = testutils.GetBptOutputStrSlice(standaloneSingleProj, "cluster_membership_ids")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestStandaloneSingleProjectExample(t *testing.T) {
projectID := setupOutput.GetTFSetupStringOutput("project_id_standalone")

// wire setup output project_id_standalone to example var.project_id
standaloneSingleProjT := tft.NewTFBlueprintTest(t, tft.WithVars(map[string]interface{}{"project_id": projectID}))
standaloneSingleProjT := tft.NewTFBlueprintTest(t, tft.WithVars(map[string]interface{}{"project_id": projectID}), tft.WithTFDir("../../../examples/standalone_single_project"))

// define and write a custom verifier for this test case call the default verify for confirming no additional changes
standaloneSingleProjT.DefineVerify(func(assert *assert.Assertions) {
Expand Down

0 comments on commit 35d83fd

Please sign in to comment.