Skip to content

Commit

Permalink
test(e2e): Add ssh log for failed requests (#4431)
Browse files Browse the repository at this point in the history
  • Loading branch information
stasryzhov authored Feb 20, 2024
1 parent 4d344ed commit 2497078
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ package base_test
import (
"context"
"fmt"
"os/exec"
"testing"

"github.com/hashicorp/boundary/internal/target"
"github.com/hashicorp/boundary/testing/internal/e2e"
"github.com/hashicorp/boundary/testing/internal/e2e/boundary"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
)

// TestCliTcpTargetConnectExecLongLastingScript verifies that SSH requests sent to target
// TestCliTcpTargetConnectExecLongLastingScript verifies that SSH requests sent to TCP target
// can execute long-lasting scripts successfully.
// It sends two SSH requests:
// - to execute the script saved on the target
Expand Down Expand Up @@ -86,34 +84,31 @@ func TestCliTcpTargetConnectExecLongLastingScript(t *testing.T) {
require.NoError(t, output.Err, string(output.Stderr))

// Send SSH requests to the target to execute long-lasting scripts
var eg errgroup.Group
eg.Go(func() error {
t.Log("Executing the long-lasting script saved on the target...")
cmd := exec.CommandContext(ctx, "/usr/bin/ssh",
t.Log("Executing the long-lasting script saved on the target...")
output = e2e.RunCommand(ctx, "ssh",
e2e.WithArgs(
"-v",
"-l", c.TargetSshUser,
"-i", c.TargetSshKeyPath,
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
"-p", proxyPort,
"localhost",
"./long_lasting_test_script.sh")
return cmd.Run()
})
"./long_lasting_test_script.sh"),
)
require.NoError(t, output.Err, string(output.Stderr))

eg.Go(func() error {
t.Log("Executing a long-lasting script sent with the ssh request...")
cmd := exec.CommandContext(ctx, "/usr/bin/ssh",
t.Log("Executing a long-lasting script sent with the ssh request...")
output = e2e.RunCommand(ctx, "ssh",
e2e.WithArgs(
"-v",
"-l", c.TargetSshUser,
"-i", c.TargetSshKeyPath,
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
"-p", proxyPort,
"localhost",
"sleep 10")
return cmd.Run()
})

require.NoError(t, eg.Wait())
"sleep 5"),
)
require.NoError(t, output.Err, string(output.Stderr))
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

for i in {1..10}
for i in {1..5}
do
echo iteration $i
sleep 1;
Expand Down

0 comments on commit 2497078

Please sign in to comment.