diff --git a/server/client_test.go b/server/client_test.go index bc1a9df9..54bfba6c 100644 --- a/server/client_test.go +++ b/server/client_test.go @@ -1483,66 +1483,6 @@ func TestWildcardCharsInLiteralSubjectWorks(t *testing.T) { } } -// This test ensures that coalescing into the fixed-size output -// queues works as expected. When bytes are queued up, they should -// not overflow a buffer until the capacity is exceeded, at which -// point a new buffer should be added. -func TestClientOutboundQueueCoalesce(t *testing.T) { - opts := DefaultOptions() - s := RunServer(opts) - defer s.Shutdown() - - nc, err := nats.Connect(fmt.Sprintf("nats://%s:%d", opts.Host, opts.Port)) - if err != nil { - t.Fatalf("Error on connect: %v", err) - } - defer nc.Close() - - clients := s.GlobalAccount().getClients() - if len(clients) != 1 { - t.Fatal("Expecting a client to exist") - } - client := clients[0] - client.mu.Lock() - defer client.mu.Unlock() - - // First up, queue something small into the queue. - client.queueOutbound([]byte{1, 2, 3, 4, 5}) - - if len(client.out.nb) != 1 { - t.Fatal("Expecting a single queued buffer") - } - if l := len(client.out.nb[0]); l != 5 { - t.Fatalf("Expecting only 5 bytes in the first queued buffer, found %d instead", l) - } - - // Then queue up a few more bytes, but not enough - // to overflow into the next buffer. - client.queueOutbound([]byte{6, 7, 8, 9, 10}) - - if len(client.out.nb) != 1 { - t.Fatal("Expecting a single queued buffer") - } - if l := len(client.out.nb[0]); l != 10 { - t.Fatalf("Expecting 10 bytes in the first queued buffer, found %d instead", l) - } - - // Finally, queue up something that is guaranteed - // to overflow. - b := nbPoolSmall.Get().(*[nbPoolSizeSmall]byte)[:] - b = b[:cap(b)] - client.queueOutbound(b) - if len(client.out.nb) != 2 { - t.Fatal("Expecting buffer to have overflowed") - } - if l := len(client.out.nb[0]); l != cap(b) { - t.Fatalf("Expecting %d bytes in the first queued buffer, found %d instead", cap(b), l) - } - if l := len(client.out.nb[1]); l != 10 { - t.Fatalf("Expecting 10 bytes in the second queued buffer, found %d instead", l) - } -} - // This test ensures that outbound queues don't cause a run on // memory when sending something to lots of clients. func TestClientOutboundQueueMemory(t *testing.T) {