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() {
|
||||
agentCommChannel, serverCommChannel := s.createCommChannel()
|
||||
|
||||
data := "hello"
|
||||
dataAgentToServer := "hello"
|
||||
dataServerToAgent := "bye"
|
||||
testsupport.RunAndWait(
|
||||
&s.Suite,
|
||||
func() any {
|
||||
conn, err := agentCommChannel.Session.OpenStream()
|
||||
s.Nil(err)
|
||||
n, err := conn.Write([]byte(data))
|
||||
n, err := conn.Write([]byte(dataAgentToServer))
|
||||
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
|
||||
},
|
||||
func() any {
|
||||
conn, err := serverCommChannel.Session.Accept()
|
||||
|
||||
s.Nil(err)
|
||||
buf := make([]byte, len(data))
|
||||
buf := make([]byte, len(dataAgentToServer))
|
||||
n, err := conn.Read(buf)
|
||||
s.Nil(err)
|
||||
s.Equal(len(data), n)
|
||||
s.Equal([]byte(data), buf[:n])
|
||||
s.Equal(len(dataAgentToServer), n)
|
||||
s.Equal([]byte(dataAgentToServer), buf[:n])
|
||||
|
||||
n, err = conn.Write([]byte(dataServerToAgent))
|
||||
s.Nil(err)
|
||||
s.Equal(len(dataServerToAgent), n)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user