From 051d337b2183d66e004a33945bf0923b519980a3 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Wed, 12 Oct 2022 18:40:22 -0400 Subject: [PATCH] refact(e2e): Move logging to helper function --- testing/internal/e2e/boundary/scopes.go | 13 ++++--------- testing/internal/e2e/credential/vault/vault_test.go | 4 ---- .../e2e/host/aws/dynamichostcatalog_test.go | 4 ---- .../e2e/host/static/staticcredential_test.go | 4 ---- testing/internal/e2e/host/static/statichost_test.go | 4 ---- 5 files changed, 4 insertions(+), 25 deletions(-) diff --git a/testing/internal/e2e/boundary/scopes.go b/testing/internal/e2e/boundary/scopes.go index 81c750784..710c530af 100644 --- a/testing/internal/e2e/boundary/scopes.go +++ b/testing/internal/e2e/boundary/scopes.go @@ -22,6 +22,7 @@ func CreateNewOrgApi(t testing.TB, ctx context.Context, client *api.Client) stri require.NoError(t, err) }) + t.Logf("Created Org Id: %s", newOrgResult.Item.Id) return newOrgResult.Item.Id } @@ -32,11 +33,8 @@ func CreateNewProjectApi(t testing.TB, ctx context.Context, client *api.Client, scopeClient := scopes.NewClient(client) newProjResult, err := scopeClient.Create(ctx, orgId, scopes.WithName("e2e Automated Test Project")) require.NoError(t, err) - t.Cleanup(func() { - _, err := scopeClient.Delete(ctx, newProjResult.Item.Id) - require.NoError(t, err) - }) + t.Logf("Created Project Id: %s", newProjResult.Item.Id) return newProjResult.Item.Id } @@ -59,6 +57,7 @@ func CreateNewOrgCli(t testing.TB) string { require.NoError(t, output.Err, string(output.Stderr)) }) + t.Logf("Created Org Id: %s", newOrgResult.Item.Id) return newOrgResult.Item.Id } @@ -77,10 +76,6 @@ func CreateNewProjectCli(t testing.TB, orgId string) string { err := json.Unmarshal(output.Stdout, &newProjResult) require.NoError(t, err) - t.Cleanup(func() { - output := e2e.RunCommand("boundary", "scopes", "delete", "-id", newProjResult.Item.Id) - require.NoError(t, output.Err, string(output.Stderr)) - }) - + t.Logf("Created Project Id: %s", newProjResult.Item.Id) return newProjResult.Item.Id } diff --git a/testing/internal/e2e/credential/vault/vault_test.go b/testing/internal/e2e/credential/vault/vault_test.go index bb7c395b1..e97e782ca 100644 --- a/testing/internal/e2e/credential/vault/vault_test.go +++ b/testing/internal/e2e/credential/vault/vault_test.go @@ -93,9 +93,7 @@ func TestCreateVaultCredentialStoreCli(t *testing.T) { // Create an org and project newOrgId := boundary.CreateNewOrgCli(t) - t.Logf("Created Org Id: %s", newOrgId) newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - t.Logf("Created Project Id: %s", newProjectId) // Create a credential store output = e2e.RunCommand("boundary", "credential-stores", "create", "vault", @@ -295,9 +293,7 @@ func TestCreateVaultCredentialStoreApi(t *testing.T) { // Create an org and project newOrgId := boundary.CreateNewOrgApi(t, ctx, client) - t.Logf("Created Org Id: %s", newOrgId) newProjectId := boundary.CreateNewProjectApi(t, ctx, client, newOrgId) - t.Logf("Created Project Id: %s", newProjectId) // Create a credential store csClient := credentialstores.NewClient(client) diff --git a/testing/internal/e2e/host/aws/dynamichostcatalog_test.go b/testing/internal/e2e/host/aws/dynamichostcatalog_test.go index f3da7cc93..4b1f6396f 100644 --- a/testing/internal/e2e/host/aws/dynamichostcatalog_test.go +++ b/testing/internal/e2e/host/aws/dynamichostcatalog_test.go @@ -55,9 +55,7 @@ func TestCreateAwsDynamicHostCatalogCli(t *testing.T) { // Create an org and project newOrgId := boundary.CreateNewOrgCli(t) - t.Logf("Created Org Id: %s", newOrgId) newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - t.Logf("Created Project Id: %s", newProjectId) // Create a dynamic host catalog output := e2e.RunCommand("boundary", "host-catalogs", "create", "plugin", @@ -287,9 +285,7 @@ func TestCreateAwsDynamicHostCatalogApi(t *testing.T) { // Create an org and project newOrgId := boundary.CreateNewOrgApi(t, ctx, client) - t.Logf("Created Org Id: %s", newOrgId) newProjectId := boundary.CreateNewProjectApi(t, ctx, client, newOrgId) - t.Logf("Created Project Id: %s", newProjectId) // Create a dynamic host catalog hcClient := hostcatalogs.NewClient(client) diff --git a/testing/internal/e2e/host/static/staticcredential_test.go b/testing/internal/e2e/host/static/staticcredential_test.go index 278c3a58b..dd0f23533 100644 --- a/testing/internal/e2e/host/static/staticcredential_test.go +++ b/testing/internal/e2e/host/static/staticcredential_test.go @@ -32,9 +32,7 @@ func TestConnectTargetWithStaticCredentialStoreCli(t *testing.T) { // Create an org and project newOrgId := boundary.CreateNewOrgCli(t) - t.Logf("Created Org Id: %s", newOrgId) newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - t.Logf("Created Project Id: %s", newProjectId) // Create a credential store output := e2e.RunCommand("boundary", "credential-stores", "create", "static", @@ -176,9 +174,7 @@ func TestCreateTargetWithStaticCredentialStoreApi(t *testing.T) { // Create an org and project newOrgId := boundary.CreateNewOrgApi(t, ctx, client) - t.Logf("Created Org Id: %s", newOrgId) newProjectId := boundary.CreateNewProjectApi(t, ctx, client, newOrgId) - t.Logf("Created Project Id: %s", newProjectId) // Create a credential store csClient := credentialstores.NewClient(client) diff --git a/testing/internal/e2e/host/static/statichost_test.go b/testing/internal/e2e/host/static/statichost_test.go index ad012c692..5d2bc9780 100644 --- a/testing/internal/e2e/host/static/statichost_test.go +++ b/testing/internal/e2e/host/static/statichost_test.go @@ -28,9 +28,7 @@ func TestConnectTargetCli(t *testing.T) { // Create an org and project newOrgId := boundary.CreateNewOrgCli(t) - t.Logf("Created Org Id: %s", newOrgId) newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - t.Logf("Created Project Id: %s", newProjectId) // Create a host catalog output := e2e.RunCommand("boundary", "host-catalogs", "create", "static", @@ -149,9 +147,7 @@ func TestCreateTargetApi(t *testing.T) { // Create an org and project newOrgId := boundary.CreateNewOrgApi(t, ctx, client) - t.Logf("Created Org Id: %s", newOrgId) newProjectId := boundary.CreateNewProjectApi(t, ctx, client, newOrgId) - t.Logf("Created Project Id: %s", newProjectId) // Create a host catalog hcClient := hostcatalogs.NewClient(client)