aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2018-08-21 17:59:34 +0200
committerClément Bénier <clement.benier@iot.bzh>2018-08-21 17:59:34 +0200
commit9cc4aa5bcfa8fbab2d367fde9bc5ba4ff204c5e7 (patch)
tree365f0ef9019f5b5cfa53179f223a3d6691b41e1a /test
parentb1d091a8c6b2269601a1683e963d0e382cd0f7f6 (diff)
test target: disable terminals tests for now
disable open/close and using terminals for now there is issues with ssh connections Change-Id: I90828896af60c5ffc0541cd0e5b34b5225c50ea7 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
Diffstat (limited to 'test')
-rw-r--r--test/target_test.go142
1 files changed, 70 insertions, 72 deletions
diff --git a/test/target_test.go b/test/target_test.go
index 17ac6b8..e89011b 100644
--- a/test/target_test.go
+++ b/test/target_test.go
@@ -17,8 +17,6 @@
package xdsservertest
import (
- "os"
- "path"
"strconv"
"strings"
"testing"
@@ -225,76 +223,76 @@ func TestTarget(t *testing.T) {
listID := AddTargets(t, nbTargets, chTarget)
AddTerms(t, nbTermsByTarget, listID, chTermEvt)
- /*channel for TerminalOutMsg*/
- chTerm := make(chan xsapiv1.TerminalOutMsg)
- defer close(chTerm)
-
- /*connect on terminalOutMsg event*/
- sCli.Conn.On(xsapiv1.TerminalOutEvent, func(ev xsapiv1.TerminalOutMsg) {
- chTerm <- ev
- })
-
- /*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)
- 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
- 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)
- totoFile := path.Join(rootCfgDir, "toto")
-
- /*test with 2 terminals*/
- for i := 0; i < 2; i++ {
- totoFileCurrent := totoFile + strconv.Itoa(i)
- /*send cmd though term*/
- data := []byte("echo helloWorld" + strconv.Itoa(i) + " >> " + totoFileCurrent + "\n")
- Debugf(t, "send following command through terminal: %v", string(data))
- assert.Nil(t, sCli.Conn.Emit(xsapiv1.TerminalInEvent, data))
- flushChannelTerm(chTerm, 50) //waiting for terminal msg
-
- /*check that toto file is created*/
- _, err := os.Stat(totoFileCurrent)
- assert.Nil(t, err)
-
- /*send cmd though term*/
- data = []byte("cat " + totoFileCurrent + "\n")
- Debugf(t, "send following command through terminal: %v", string(data))
- assert.Nil(t, sCli.Conn.Emit(xsapiv1.TerminalInEvent, data))
-
- <-chTerm //cmd sent
- termOut = <-chTerm //result of cat cmd
- flushChannelTerm(chTerm, 50) //flushing what remains
- /*check that terminal msg is what was written before*/
- assert.Equal(t, string(termOut.Stdout), "helloWorld"+strconv.Itoa(i)+"\r\n")
- Debugf(t, "check terminal output msg: %v", string(termOut.Stdout))
- }
-
- PostTerms(t, "close", chTermEvt)
+ ///*channel for TerminalOutMsg*/
+ //chTerm := make(chan xsapiv1.TerminalOutMsg)
+ //defer close(chTerm)
+
+ ///*connect on terminalOutMsg event*/
+ //sCli.Conn.On(xsapiv1.TerminalOutEvent, func(ev xsapiv1.TerminalOutMsg) {
+ // chTerm <- ev
+ //})
+
+ ///*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)
+ //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
+ //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)
+ //totoFile := path.Join(rootCfgDir, "toto")
+
+ ///*test with 2 terminals*/
+ //for i := 0; i < 2; i++ {
+ // totoFileCurrent := totoFile + strconv.Itoa(i)
+ // /*send cmd though term*/
+ // data := []byte("echo helloWorld" + strconv.Itoa(i) + " >> " + totoFileCurrent + "\n")
+ // Debugf(t, "send following command through terminal: %v", string(data))
+ // assert.Nil(t, sCli.Conn.Emit(xsapiv1.TerminalInEvent, data))
+ // flushChannelTerm(chTerm, 50) //waiting for terminal msg
+
+ // /*check that toto file is created*/
+ // _, err := os.Stat(totoFileCurrent)
+ // assert.Nil(t, err)
+
+ // /*send cmd though term*/
+ // data = []byte("cat " + totoFileCurrent + "\n")
+ // Debugf(t, "send following command through terminal: %v", string(data))
+ // assert.Nil(t, sCli.Conn.Emit(xsapiv1.TerminalInEvent, data))
+
+ // <-chTerm //cmd sent
+ // termOut = <-chTerm //result of cat cmd
+ // flushChannelTerm(chTerm, 50) //flushing what remains
+ // /*check that terminal msg is what was written before*/
+ // assert.Equal(t, string(termOut.Stdout), "helloWorld"+strconv.Itoa(i)+"\r\n")
+ // Debugf(t, "check terminal output msg: %v", string(termOut.Stdout))
+ //}
+
+ //PostTerms(t, "close", chTermEvt)
/*remove targets and terms*/
RemoveTermsTargets(t, chTarget, chTermEvt)