test(e2e): Update migration test with additional resources (#4069)

* test(e2e): Add descriptions to resources

* test(e2e): Add more resources to migration test
This commit is contained in:
Michael Li authored and GitHub committed 2023-11-30 09:38:07 -05:00
1 parent 798e86cefe
commit 3cae4933c0
9 files changed
+48 -4

No files matched your search

@@ -16,6 +16,8 @@ import (
"time"
"github.com/hashicorp/boundary/api/credentiallibraries"
"github.com/hashicorp/boundary/api/workers"
"github.com/hashicorp/boundary/internal/target"
"github.com/hashicorp/boundary/testing/internal/e2e"
"github.com/hashicorp/boundary/testing/internal/e2e/boundary"
"github.com/hashicorp/boundary/testing/internal/e2e/infra"
@@ -48,7 +50,6 @@ func TestDatabaseMigration(t *testing.T) {
boundaryRepo := "hashicorp/boundary"
boundaryTag := "latest"
te := setupEnvironment(t, ctx, c, boundaryRepo, boundaryTag)
populateBoundaryDatabase(t, ctx, c, te, boundaryRepo, boundaryTag)
@@ -201,7 +202,7 @@ func setupEnvironment(t testing.TB, ctx context.Context, c *config, boundaryRepo
func populateBoundaryDatabase(t testing.TB, ctx context.Context, c *config, te TestEnvironment, boundaryRepo, boundaryTag string) {
// Create resources for target. Uses the local CLI so that these methods can be reused.
// While the CLI version used won't necessarily match the controller version, it should be (and is
// supposed to be) backwards ompatible
// supposed to be) backwards compatible
boundary.AuthenticateCli(t, ctx, te.DbInitInfo.AuthMethod.AuthMethodId, te.DbInitInfo.AuthMethod.LoginName, te.DbInitInfo.AuthMethod.Password)
newOrgId := boundary.CreateNewOrgCli(t, ctx)
newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId)
@@ -212,6 +213,16 @@ func populateBoundaryDatabase(t testing.TB, ctx context.Context, c *config, te T
newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, "2222") // openssh-server uses port 2222
boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId)
// Create a target with an address attached
_ = boundary.CreateNewTargetCli(
t,
ctx,
newProjectId,
"2222",
target.WithName("e2e target with address"),
target.WithAddress(te.Target.UriNetwork),
)
// Create AWS dynamic host catalog
newAwsHostCatalogId := boundary.CreateNewAwsHostCatalogCli(t, ctx, newProjectId, c.AwsAccessKeyId, c.AwsSecretAccessKey)
newAwsHostSetId := boundary.CreateNewAwsHostSetCli(t, ctx, newAwsHostCatalogId, c.AwsHostSetFilter)
@@ -275,6 +286,7 @@ func populateBoundaryDatabase(t testing.TB, ctx context.Context, c *config, te T
"-vault-path", c.VaultSecretPath+"/data/"+privateKeySecretName,
"-name", "e2e Automated Test Vault Credential Library",
"-credential-type", "ssh_private_key",
"-description", "e2e",
"-format", "json",
),
)
@@ -293,6 +305,7 @@ func populateBoundaryDatabase(t testing.TB, ctx context.Context, c *config, te T
"-vault-path", c.VaultSecretPath+"/data/"+passwordSecretName,
"-name", "e2e Automated Test Vault Credential Library - Password",
"-credential-type", "username_password",
"-description", "e2e",
"-format", "json",
),
)
@@ -302,6 +315,22 @@ func populateBoundaryDatabase(t testing.TB, ctx context.Context, c *config, te T
newPasswordCredentialLibraryId := newCredentialLibraryResult.Item.Id
t.Logf("Created Credential Library: %s", newPasswordCredentialLibraryId)
// Create a worker
output = e2e.RunCommand(ctx, "boundary",
e2e.WithArgs(
"workers", "create", "controller-led",
"-name", "e2e worker",
"-description", "e2e",
"-format", "json",
),
)
require.NoError(t, output.Err, string(output.Stderr))
var newWorkerResult workers.WorkerCreateResult
err = json.Unmarshal(output.Stdout, &newWorkerResult)
require.NoError(t, err)
newWorkerId := newWorkerResult.Item.Id
t.Logf("Created Worker: %s", newWorkerId)
// Create a session. Uses Boundary in a docker container to do the connect in order to avoid
// modifying the runner's /etc/hosts file. Otherwise, you would need to add a `127.0.0.1
// localhost boundary` entry into /etc/hosts.