Skip to content

Commit 2f34a67

Browse files
committed
Add better errors for ssh
1 parent cfe4a84 commit 2f34a67

5 files changed

Lines changed: 32 additions & 3 deletions

File tree

commander_unix.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,8 @@ tests:
7171
stdout:
7272
contains:
7373
- ✓ [ssh-host] it should test ssh host
74+
- ✓ [ssh-host] it should set env variable
7475
- ✗ [local] it should test ssh host
76+
- ✗ [ssh-host] it should fail if env could not be set
77+
- "Failed setting env variables, maybe ssh server is configured to only accept LC_ prefixed env variables. Error: ssh: setenv failed"
7578
exit-code: 1

integration/unix/nodes.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,22 @@ tests:
1616
- test file ssh
1717
- root
1818
- /root
19-
exit-code: 0
19+
exit-code: 0
20+
21+
it should set env variable:
22+
nodes:
23+
- ssh-host
24+
config:
25+
env:
26+
LC_TEST_ENV: env var
27+
command: echo $LC_TEST_ENV
28+
stdout: env var
29+
30+
it should fail if env could not be set:
31+
nodes:
32+
- ssh-host
33+
config:
34+
env:
35+
TEST_ENV: env var
36+
command: echo $TEST_ENV
37+
stdout: env var

pkg/output/cli.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ func (w *OutputWriter) Start(results <-chan runtime.TestResult) bool {
4545
str := fmt.Sprintf("✓ [%s] %s", r.Node, r.TestCase.Title)
4646
s := w.addTries(str, r)
4747
w.fprintf(s)
48+
continue
4849
}
4950

5051
if !r.ValidationResult.Success {
5152
failed++
5253
str := fmt.Sprintf("✗ [%s] %s", r.Node, r.TestCase.Title)
5354
s := w.addTries(str, r)
5455
w.fprintf(au.Red(s))
56+
continue
5557
}
5658
}
5759

pkg/runtime/runtime.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ type TestResult struct {
125125
FailedProperty string
126126
Tries int
127127
Node string
128+
Error error
128129
}
129130

130131
// Start starts the given test suite and executes all tests

pkg/runtime/ssh_executor.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type SSHExecutor struct {
2121
// Execute executes a command on a remote host viá SSH
2222
func (e SSHExecutor) Execute(test TestCase) TestResult {
2323
if test.Command.InheritEnv {
24-
log.Fatal("Inherit env is not supported viá SSH")
24+
panic("Inherit env is not supported viá SSH")
2525
}
2626

2727
// initialize auth methods with pass auth method as the default
@@ -65,7 +65,12 @@ func (e SSHExecutor) Execute(test TestCase) TestResult {
6565
for k, v := range test.Command.Env {
6666
err := session.Setenv(k, v)
6767
if err != nil {
68-
log.Fatal(fmt.Sprintf("Failed, maybe ssh server is configured to only accept LC_ prefixed env variables. Error: %s", err))
68+
test.Result = CommandResult{
69+
Error: fmt.Errorf("Failed setting env variables, maybe ssh server is configured to only accept LC_ prefixed env variables. Error: %s", err),
70+
}
71+
return TestResult{
72+
TestCase: test,
73+
}
6974
}
7075
}
7176

0 commit comments

Comments
 (0)