remove agent now also tested.

This commit is contained in:
Erik Brakkee 2024-08-22 17:28:10 +02:00
parent 5191b9cd49
commit d8a79fbe00

View File

@ -102,13 +102,25 @@ func (s *AdminTestSuite) agentRegisters(requestedPublicId, assignedPublicId stri
}
func (s *AdminTestSuite) Test_AgentRegisters() {
res, _ := s.agentRegisters("abc", "abc")
publicId := "abc"
res, _ := s.agentRegisters(publicId, publicId)
s.Nil(res.err)
agentConn := res.agentConn
state := s.admin.CreateNotifification()
s.Equal(1, len(state.Agents))
s.Equal(0, len(state.Clients))
s.Equal(agentConn.Info, state.Agents[agentConn.Info.Guid])
// Now unregister
s.False(agentConn.CommChannel.Session.IsClosed())
s.admin.RemoveAgent(models.RendezVousId(publicId))
s.True(agentConn.CommChannel.Session.IsClosed())
// copy on write, orioginal state is unchanged
s.Equal(1, len(state.Agents))
s.Equal(0, len(state.Clients))
state = s.admin.CreateNotifification()
s.Equal(0, len(state.Agents))
s.Equal(0, len(state.Clients))
}
func (s *AdminTestSuite) Test_ManyAgentsRegister() {
@ -180,6 +192,13 @@ func (s *AdminTestSuite) Test_connectClient() {
// will close the connections and as a result also th synchronize goroutine.
s.cancelFunc()
// Note: removing agents and clients after connection loss is the responsibility of the MatchMaker
// Here we only test explicit removal of the agents and clients.
}
func (s *AdminTestSuite) Test_multipleAgentsAndClients() {
}
func (s *AdminTestSuite) bidirectionalConnectionCheck(clientToServerRW io.ReadWriteCloser, agentToServerYamux io.ReadWriter) {