now also testing client removal.

This commit is contained in:
Erik Brakkee 2024-08-22 17:33:54 +02:00
parent 4e2265c1b3
commit 8fcdf5711f

View File

@ -190,11 +190,16 @@ func (s *AdminTestSuite) Test_connectClient() {
s.Equal(1, len(state.Clients))
s.Equal(clientConn.Info, state.Clients[clientConn.Info.Guid])
// 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.
// removing the client will close all connections, we test this by writing to the connections
// after removing the client.
s.admin.RemoveClient(clientConn)
buf := make([]byte, 10)
_, err := clientConn.clientConnection.Write(buf)
s.NotNil(err)
s.True(strings.Contains(err.Error(), "closed"))
_, err = clientConn.agentConnection.Write(buf)
s.NotNil(err)
s.True(strings.Contains(err.Error(), "closed"))
}
func (s *AdminTestSuite) Test_multipleAgentsAndClients() {