diff --git a/testing/internal/e2e/boundary/session.go b/testing/internal/e2e/boundary/session.go index ef62254c1..6ddb62873 100644 --- a/testing/internal/e2e/boundary/session.go +++ b/testing/internal/e2e/boundary/session.go @@ -20,19 +20,28 @@ import ( // WaitForSessionCli waits for sessions to appear in the session list and returns the most recent session // information. If the WithExpectedSessionsCount option is provided, expects to find specified amount of sessions // or only 1 otherwise. -func WaitForSessionCli(t testing.TB, ctx context.Context, projectId string, opt ...SessionOption) *sessions.Session { - opts := getSessionOpts(opt...) +func WaitForSessionCli(t testing.TB, ctx context.Context, projectId string, sessionOpts []SessionOption, e2eOpts ...e2e.Option) *sessions.Session { + opts := getSessionOpts(sessionOpts...) + + var options []e2e.Option + options = append(options, + e2e.WithArgs("sessions", "list", "-scope-id", projectId, "-include-terminated", "-format", "json"), + ) + options = append(options, e2eOpts...) + t.Log("Waiting for session to appear...") var session *sessions.Session + err := backoff.RetryNotify( func() error { // List sessions output := e2e.RunCommand(ctx, "boundary", - e2e.WithArgs("sessions", "list", "-scope-id", projectId, "-include-terminated", "-format", "json"), + options..., ) if output.Err != nil { return backoff.Permanent(errors.New(string(output.Stderr))) } + var sessionListResult sessions.SessionListResult err := json.Unmarshal(output.Stdout, &sessionListResult) if err != nil { diff --git a/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go b/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go index 91b5eedb5..c131391d7 100644 --- a/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go +++ b/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go @@ -156,7 +156,7 @@ func TestCliCreateAwsDynamicHostCatalogWithHostSet(t *testing.T) { }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) output = e2e.RunCommand(ctx, "boundary", diff --git a/testing/internal/e2e/tests/base/bytes_up_down_empty_test.go b/testing/internal/e2e/tests/base/bytes_up_down_empty_test.go index a205dd9d8..527436581 100644 --- a/testing/internal/e2e/tests/base/bytes_up_down_empty_test.go +++ b/testing/internal/e2e/tests/base/bytes_up_down_empty_test.go @@ -70,7 +70,7 @@ func TestCliBytesUpDownEmpty(t *testing.T) { }() t.Cleanup(cancel) - session := boundary.WaitForSessionCli(t, ctx, projectId) + session := boundary.WaitForSessionCli(t, ctx, projectId, nil) assert.Equal(t, targetId, session.TargetId) // Wait until bytes up and down is greater than 0 diff --git a/testing/internal/e2e/tests/base/bytes_up_down_test.go b/testing/internal/e2e/tests/base/bytes_up_down_test.go index df19a963b..731bb3f6d 100644 --- a/testing/internal/e2e/tests/base/bytes_up_down_test.go +++ b/testing/internal/e2e/tests/base/bytes_up_down_test.go @@ -73,7 +73,7 @@ func TestCliBytesUpDownTransferData(t *testing.T) { ) }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) assert.Equal(t, targetId, s.TargetId) diff --git a/testing/internal/e2e/tests/base/session_cancel_admin_test.go b/testing/internal/e2e/tests/base/session_cancel_admin_test.go index de642d703..bdaa22a35 100644 --- a/testing/internal/e2e/tests/base/session_cancel_admin_test.go +++ b/testing/internal/e2e/tests/base/session_cancel_admin_test.go @@ -68,7 +68,7 @@ func TestCliSessionCancelAdmin(t *testing.T) { ) }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) assert.Equal(t, targetId, s.TargetId) assert.Equal(t, hostId, s.HostId) diff --git a/testing/internal/e2e/tests/base/session_cancel_group_test.go b/testing/internal/e2e/tests/base/session_cancel_group_test.go index eae54c98d..b49aff16b 100644 --- a/testing/internal/e2e/tests/base/session_cancel_group_test.go +++ b/testing/internal/e2e/tests/base/session_cancel_group_test.go @@ -145,7 +145,7 @@ func TestCliSessionCancelGroup(t *testing.T) { ) }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) assert.Equal(t, targetId, s.TargetId) assert.Equal(t, hostId, s.HostId) diff --git a/testing/internal/e2e/tests/base/session_cancel_user_test.go b/testing/internal/e2e/tests/base/session_cancel_user_test.go index 9334aca05..caee20f06 100644 --- a/testing/internal/e2e/tests/base/session_cancel_user_test.go +++ b/testing/internal/e2e/tests/base/session_cancel_user_test.go @@ -138,7 +138,7 @@ func TestCliSessionCancelUser(t *testing.T) { ) }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) assert.Equal(t, targetId, s.TargetId) assert.Equal(t, hostId, s.HostId) diff --git a/testing/internal/e2e/tests/base/session_end_delete_host_set_test.go b/testing/internal/e2e/tests/base/session_end_delete_host_set_test.go index 603f84b6a..d0b796bdc 100644 --- a/testing/internal/e2e/tests/base/session_end_delete_host_set_test.go +++ b/testing/internal/e2e/tests/base/session_end_delete_host_set_test.go @@ -101,7 +101,7 @@ func TestCliSessionEndWhenHostSetIsDeleted(t *testing.T) { ) }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) assert.Equal(t, targetId, s.TargetId) assert.Equal(t, hostId, s.HostId) diff --git a/testing/internal/e2e/tests/base/session_end_delete_host_test.go b/testing/internal/e2e/tests/base/session_end_delete_host_test.go index 0b90cc5d2..392edb5d3 100644 --- a/testing/internal/e2e/tests/base/session_end_delete_host_test.go +++ b/testing/internal/e2e/tests/base/session_end_delete_host_test.go @@ -101,7 +101,7 @@ func TestCliSessionEndWhenHostIsDeleted(t *testing.T) { ) }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) assert.Equal(t, targetId, s.TargetId) assert.Equal(t, hostId, s.HostId) diff --git a/testing/internal/e2e/tests/base/session_end_delete_project_test.go b/testing/internal/e2e/tests/base/session_end_delete_project_test.go index ccabc2604..be21ff9d4 100644 --- a/testing/internal/e2e/tests/base/session_end_delete_project_test.go +++ b/testing/internal/e2e/tests/base/session_end_delete_project_test.go @@ -92,7 +92,7 @@ func TestCliSessionEndWhenProjectIsDeleted(t *testing.T) { ) }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) assert.Equal(t, targetId, s.TargetId) diff --git a/testing/internal/e2e/tests/base/session_end_delete_target_test.go b/testing/internal/e2e/tests/base/session_end_delete_target_test.go index d46bddf28..6546cf848 100644 --- a/testing/internal/e2e/tests/base/session_end_delete_target_test.go +++ b/testing/internal/e2e/tests/base/session_end_delete_target_test.go @@ -101,7 +101,7 @@ func TestCliSessionEndWhenTargetIsDeleted(t *testing.T) { ) }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) assert.Equal(t, targetId, s.TargetId) assert.Equal(t, hostId, s.HostId) diff --git a/testing/internal/e2e/tests/base/session_end_delete_user_test.go b/testing/internal/e2e/tests/base/session_end_delete_user_test.go index d3964dc18..92874d1b1 100644 --- a/testing/internal/e2e/tests/base/session_end_delete_user_test.go +++ b/testing/internal/e2e/tests/base/session_end_delete_user_test.go @@ -106,7 +106,7 @@ func TestCliSessionEndWhenUserIsDeleted(t *testing.T) { ) }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) assert.Equal(t, targetId, s.TargetId) assert.Equal(t, hostId, s.HostId) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_connection_limits_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_connection_limits_test.go index 1cc942c49..417953c7b 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_connection_limits_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_connection_limits_test.go @@ -67,7 +67,7 @@ func TestCliTcpTargetConnectTargetWithConnectionLimits(t *testing.T) { }() t.Cleanup(cancel) - boundary.WaitForSessionCli(t, ctx, projectId) + boundary.WaitForSessionCli(t, ctx, projectId, nil) // Start connections. Expect an error once the limit is reached for i := 0; i <= sessionConnectionLimit; i++ { diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_exec_long_lasting_script_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_exec_long_lasting_script_test.go index d9511ca32..e5f1d9a28 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_exec_long_lasting_script_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_exec_long_lasting_script_test.go @@ -75,7 +75,7 @@ func TestCliTcpTargetConnectExecLongLastingScript(t *testing.T) { ) }() t.Cleanup(cancel) - boundary.WaitForSessionCli(t, ctx, projectId) + boundary.WaitForSessionCli(t, ctx, projectId, nil) t.Log("Copying script to host...") output := e2e.RunCommand(ctx, "scp", diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_go_ssh_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_go_ssh_test.go index 37ff2c4ee..fb260b087 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_go_ssh_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_go_ssh_test.go @@ -55,7 +55,7 @@ func TestCliTcpTargetConnectGoSsh(t *testing.T) { }() t.Cleanup(cancel) - boundary.WaitForSessionCli(t, ctx, projectId) + boundary.WaitForSessionCli(t, ctx, projectId, nil) // Connect to the target using the go experimental ssh library privateKeyRaw, err := os.ReadFile(c.TargetSshKeyPath) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_http_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_http_test.go index 44b273efa..7b2b9a1a8 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_http_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_http_test.go @@ -79,7 +79,7 @@ Server: netcat-can-you-believe-it _, _ = io.Copy(io.Discard, f) // Not checking error here since it will return an error on session close }() - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) // Create http target and connect to it diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_listen_port_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_listen_port_test.go index 1bc15b903..05dc66b53 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_listen_port_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_listen_port_test.go @@ -57,7 +57,7 @@ func TestCliTcpTargetConnectListenPort(t *testing.T) { }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusPending.String()) t.Logf("Successfully connected to target with listen port %s", ListenPort) @@ -118,7 +118,7 @@ func TestCliTcpTargetConnectDefaultClientPort(t *testing.T) { }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusPending.String()) t.Logf("Successfully connected to target with client port %d", DefaultClientPort) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_localhost_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_localhost_test.go index 17de377a9..7b26deab9 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_localhost_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_localhost_test.go @@ -65,7 +65,7 @@ func TestCliTcpTargetConnectTargetWithLocalhost(t *testing.T) { }() t.Cleanup(cancel) - boundary.WaitForSessionCli(t, ctx, projectId) + boundary.WaitForSessionCli(t, ctx, projectId, nil) // Connect to target and print host's IP address output := e2e.RunCommand(ctx, "ssh", diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_scp_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_scp_test.go index 0167b1e90..2e3ec4e28 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_scp_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_scp_test.go @@ -64,7 +64,7 @@ func TestCliTcpTargetConnectTargetAndScp(t *testing.T) { }() t.Cleanup(cancel) - boundary.WaitForSessionCli(t, ctx, projectId) + boundary.WaitForSessionCli(t, ctx, projectId, nil) // Create file to scp testDir := t.TempDir() diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_session_max_seconds_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_session_max_seconds_test.go index c47034069..7fb60168b 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_session_max_seconds_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_session_max_seconds_test.go @@ -71,7 +71,7 @@ func TestCliTcpTargetConnectTargetWithSessionMaxSecondsTearDown(t *testing.T) { ) }() t.Cleanup(cancel) - s := boundary.WaitForSessionCli(t, ctx, projectId) + s := boundary.WaitForSessionCli(t, ctx, projectId, nil) boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) // Check that session was closed once time limit is reached @@ -140,7 +140,7 @@ func TestCliTcpTargetConnectTargetWithSessionMaxSecondsRejectNew(t *testing.T) { ) }() t.Cleanup(cancel) - boundary.WaitForSessionCli(t, ctx, projectId) + boundary.WaitForSessionCli(t, ctx, projectId, nil) // Start connections. Expect an error once the time limit is reached t.Log("Creating connections...")