connectClient() extracted to make it easy to connect a client.
This commit is contained in:
parent
2accbaf3fe
commit
d21f9c847f
@ -149,6 +149,25 @@ func (s *MatchMakerTestSuite) Test_singleAgentAndClient() {
|
||||
waitForAgentFunc := s.registerAgent(publicId, agent)
|
||||
go waitForAgentFunc()
|
||||
|
||||
client, clientId := s.connectClient(publicId)
|
||||
|
||||
s.checkState(1, 1)
|
||||
|
||||
agentClientSideConn, err := agent.listener.GetConnection(string(clientId))
|
||||
log.Printf("Agent side conn %v", agentClientSideConn)
|
||||
s.Nil(err)
|
||||
testsupport.BidirectionalConnectionCheck(
|
||||
&s.Suite, "testmsg",
|
||||
client.clientSideConn,
|
||||
agentClientSideConn)
|
||||
|
||||
client.Disconnect()
|
||||
// It is the agents choice to exit> The test agent does not exit by default when
|
||||
// there are no more connections.
|
||||
s.checkState(1, 0)
|
||||
}
|
||||
|
||||
func (s *MatchMakerTestSuite) connectClient(publicId models.RendezVousId) (*TestClient, models.ClientId) {
|
||||
client := NewTestClient(s.ctx)
|
||||
var clientId models.ClientId
|
||||
testsupport.RunAndWait(
|
||||
@ -168,21 +187,7 @@ func (s *MatchMakerTestSuite) Test_singleAgentAndClient() {
|
||||
// client, nothing to do with wsproxy mode off.
|
||||
return nil
|
||||
})
|
||||
|
||||
s.checkState(1, 1)
|
||||
|
||||
agentClientSideConn, err := agent.listener.GetConnection(string(clientId))
|
||||
log.Printf("Agent side conn %v", agentClientSideConn)
|
||||
s.Nil(err)
|
||||
testsupport.BidirectionalConnectionCheck(
|
||||
&s.Suite, "testmsg",
|
||||
client.clientSideConn,
|
||||
agentClientSideConn)
|
||||
|
||||
client.Disconnect()
|
||||
// It is the agents choice to exit> The test agent does not exit by default when
|
||||
// there are no more connections.
|
||||
s.checkState(1, 0)
|
||||
return client, clientId
|
||||
}
|
||||
|
||||
func (s *MatchMakerTestSuite) checkState(nAgents int, nClients int) {
|
||||
|
Loading…
Reference in New Issue
Block a user