aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2018-08-21 11:06:36 +0200
committerClément Bénier <clement.benier@iot.bzh>2018-08-21 11:08:36 +0200
commit4192072863ac0997b0c3cb4131ea913e6f85f83e (patch)
tree8d9045b701ec4a5dc41c9f2f7bc2ad1f081b91a8 /test
parent72bb1c521aff5bb166db287ef426b243166d8927 (diff)
test target: open 1 terminal for connection errors
before opening all terminals, open just one to check there is no ssh connection problems Change-Id: I700a00264a96480ac4656be6338e2d728f509627 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
Diffstat (limited to 'test')
-rw-r--r--test/target_test.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/test/target_test.go b/test/target_test.go
index 0fcd94d..50483ff 100644
--- a/test/target_test.go
+++ b/test/target_test.go
@@ -234,10 +234,12 @@ func TestTarget(t *testing.T) {
chTerm <- ev
})
- /*open terminals*/
- PostTerms(t, "open", chTermEvt)
-
/*just for the first term*/
+ var terms []xsapiv1.TerminalConfig
+ var term xsapiv1.TerminalConfig
+ assert.Nil(t, HTTPCli.Get("/targets/"+listID[0]+"/terminals", &terms))
+ assert.Nil(t, HTTPCli.Post("/targets/"+listID[0]+"/terminals/"+terms[0].ID+"/open", terms[0], &term))
+ <-chTermEvt //waiting for event terminalStateChange
termOut := <-chTerm //waiting for terminalOutMsg
flushChannelTerm(chTerm, 50) //flushing all terminalOutMsg
stdoutMsg := string(termOut.Stdout)
@@ -247,7 +249,20 @@ func TestTarget(t *testing.T) {
t.Fatalf("%vcopy your pub key in authorized_keys\ncat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys", stdoutMsg)
}
assert.True(t, strings.Contains(stdoutMsg, "Last login")) //first terminal msg should be Last Login
- t.Logf("terminal is open, console msg is %v", stdoutMsg)
+ assert.Nil(t, HTTPCli.Post("/targets/"+listID[0]+"/terminals/"+terms[0].ID+"/close", terms[0], &term))
+ <-chTermEvt //waiting for event terminalStateChange
+
+ /*open terminals*/
+ PostTerms(t, "open", chTermEvt)
+ termOut = <-chTerm //waiting for terminalOutMsg
+ flushChannelTerm(chTerm, 50) //flushing all terminalOutMsg
+ stdoutMsg = string(termOut.Stdout)
+ if strings.Contains(stdoutMsg, "Connection refused") {
+ t.Fatalf("%vYou may have to launch ssh server", stdoutMsg)
+ } else if strings.Contains(stdoutMsg, "password") {
+ t.Fatalf("%vcopy your pub key in authorized_keys\ncat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys", stdoutMsg)
+ }
+ assert.True(t, strings.Contains(stdoutMsg, "Last login")) //first terminal msg should be Last Login
/*create toto file through terminals*/
rootCfgDir := os.Getenv(envRootCfgDir)