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)
|
waitForAgentFunc := s.registerAgent(publicId, agent)
|
||||||
go waitForAgentFunc()
|
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)
|
client := NewTestClient(s.ctx)
|
||||||
var clientId models.ClientId
|
var clientId models.ClientId
|
||||||
testsupport.RunAndWait(
|
testsupport.RunAndWait(
|
||||||
@ -168,21 +187,7 @@ func (s *MatchMakerTestSuite) Test_singleAgentAndClient() {
|
|||||||
// client, nothing to do with wsproxy mode off.
|
// client, nothing to do with wsproxy mode off.
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
return client, clientId
|
||||||
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) checkState(nAgents int, nClients int) {
|
func (s *MatchMakerTestSuite) checkState(nAgents int, nClients int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user