bidirectional communication now tested.
This commit is contained in:
parent
11c894e906
commit
6dc8f67570
@ -100,25 +100,39 @@ func (s *AgentServerTestSuite) TestNewCommChannel() {
|
|||||||
func (s *AgentServerTestSuite) Test_ConnectThroughYamux() {
|
func (s *AgentServerTestSuite) Test_ConnectThroughYamux() {
|
||||||
agentCommChannel, serverCommChannel := s.createCommChannel()
|
agentCommChannel, serverCommChannel := s.createCommChannel()
|
||||||
|
|
||||||
data := "hello"
|
dataAgentToServer := "hello"
|
||||||
|
dataServerToAgent := "bye"
|
||||||
testsupport.RunAndWait(
|
testsupport.RunAndWait(
|
||||||
&s.Suite,
|
&s.Suite,
|
||||||
func() any {
|
func() any {
|
||||||
conn, err := agentCommChannel.Session.OpenStream()
|
conn, err := agentCommChannel.Session.OpenStream()
|
||||||
s.Nil(err)
|
s.Nil(err)
|
||||||
n, err := conn.Write([]byte(data))
|
n, err := conn.Write([]byte(dataAgentToServer))
|
||||||
s.Nil(err)
|
s.Nil(err)
|
||||||
s.Equal(len(data), n)
|
s.Equal(len(dataAgentToServer), n)
|
||||||
|
|
||||||
|
buf := make([]byte, len(dataServerToAgent))
|
||||||
|
n, err = conn.Read(buf)
|
||||||
|
s.Nil(err)
|
||||||
|
s.Equal(len(dataServerToAgent), n)
|
||||||
|
s.Equal([]byte(dataServerToAgent), buf[:n])
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func() any {
|
func() any {
|
||||||
conn, err := serverCommChannel.Session.Accept()
|
conn, err := serverCommChannel.Session.Accept()
|
||||||
|
|
||||||
s.Nil(err)
|
s.Nil(err)
|
||||||
buf := make([]byte, len(data))
|
buf := make([]byte, len(dataAgentToServer))
|
||||||
n, err := conn.Read(buf)
|
n, err := conn.Read(buf)
|
||||||
s.Nil(err)
|
s.Nil(err)
|
||||||
s.Equal(len(data), n)
|
s.Equal(len(dataAgentToServer), n)
|
||||||
s.Equal([]byte(data), buf[:n])
|
s.Equal([]byte(dataAgentToServer), buf[:n])
|
||||||
|
|
||||||
|
n, err = conn.Write([]byte(dataServerToAgent))
|
||||||
|
s.Nil(err)
|
||||||
|
s.Equal(len(dataServerToAgent), n)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user