mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Account lookup failures, account and client limits, options reload.
Changed account lookup and validation failures to be more understandable by users. Changed limits to be -1 for unlimited to match jwt pkg. The limits changed exposed problems with options holding real objects causing issues with reload tests under race mode. Longer term this code should be reworked such that options only hold config data, not real structs, etc. Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -28,9 +28,9 @@ func TestSplitBufferSubOp(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating gateways: %v", err)
|
||||
}
|
||||
s := &Server{gacc: &Account{Name: globalAccountName}, accounts: make(map[string]*Account), gateway: gws}
|
||||
s := &Server{gacc: NewAccount(globalAccountName), accounts: make(map[string]*Account), gateway: gws}
|
||||
s.registerAccount(s.gacc)
|
||||
c := &client{srv: s, acc: s.gacc, subs: make(map[string]*subscription), nc: cli}
|
||||
c := &client{srv: s, acc: s.gacc, msubs: -1, mpay: -1, subs: make(map[string]*subscription), nc: cli}
|
||||
|
||||
subop := []byte("SUB foo 1\r\n")
|
||||
subop1 := subop[:6]
|
||||
@@ -65,9 +65,9 @@ func TestSplitBufferSubOp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitBufferUnsubOp(t *testing.T) {
|
||||
s := &Server{gacc: &Account{Name: globalAccountName}, accounts: make(map[string]*Account), gateway: &srvGateway{}}
|
||||
s := &Server{gacc: NewAccount(globalAccountName), accounts: make(map[string]*Account), gateway: &srvGateway{}}
|
||||
s.registerAccount(s.gacc)
|
||||
c := &client{srv: s, acc: s.gacc, subs: make(map[string]*subscription)}
|
||||
c := &client{srv: s, acc: s.gacc, msubs: -1, mpay: -1, subs: make(map[string]*subscription)}
|
||||
|
||||
subop := []byte("SUB foo 1024\r\n")
|
||||
if err := c.parse(subop); err != nil {
|
||||
@@ -100,7 +100,7 @@ func TestSplitBufferUnsubOp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitBufferPubOp(t *testing.T) {
|
||||
c := &client{subs: make(map[string]*subscription)}
|
||||
c := &client{msubs: -1, mpay: -1, subs: make(map[string]*subscription)}
|
||||
pub := []byte("PUB foo.bar INBOX.22 11\r\nhello world\r")
|
||||
pub1 := pub[:2]
|
||||
pub2 := pub[2:9]
|
||||
@@ -166,7 +166,7 @@ func TestSplitBufferPubOp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitBufferPubOp2(t *testing.T) {
|
||||
c := &client{subs: make(map[string]*subscription)}
|
||||
c := &client{msubs: -1, mpay: -1, subs: make(map[string]*subscription)}
|
||||
pub := []byte("PUB foo.bar INBOX.22 11\r\nhello world\r\n")
|
||||
pub1 := pub[:30]
|
||||
pub2 := pub[30:]
|
||||
@@ -186,7 +186,7 @@ func TestSplitBufferPubOp2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitBufferPubOp3(t *testing.T) {
|
||||
c := &client{subs: make(map[string]*subscription)}
|
||||
c := &client{msubs: -1, mpay: -1, subs: make(map[string]*subscription)}
|
||||
pubAll := []byte("PUB foo bar 11\r\nhello world\r\n")
|
||||
pub := pubAll[:16]
|
||||
|
||||
@@ -212,7 +212,7 @@ func TestSplitBufferPubOp3(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitBufferPubOp4(t *testing.T) {
|
||||
c := &client{subs: make(map[string]*subscription)}
|
||||
c := &client{msubs: -1, mpay: -1, subs: make(map[string]*subscription)}
|
||||
pubAll := []byte("PUB foo 11\r\nhello world\r\n")
|
||||
pub := pubAll[:12]
|
||||
|
||||
@@ -238,7 +238,7 @@ func TestSplitBufferPubOp4(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitBufferPubOp5(t *testing.T) {
|
||||
c := &client{subs: make(map[string]*subscription)}
|
||||
c := &client{msubs: -1, mpay: -1, subs: make(map[string]*subscription)}
|
||||
pubAll := []byte("PUB foo 11\r\nhello world\r\n")
|
||||
|
||||
// Splits need to be on MSG_END now too, so make sure we check that.
|
||||
@@ -257,7 +257,7 @@ func TestSplitBufferPubOp5(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitConnectArg(t *testing.T) {
|
||||
c := &client{subs: make(map[string]*subscription)}
|
||||
c := &client{msubs: -1, mpay: -1, subs: make(map[string]*subscription)}
|
||||
connectAll := []byte("CONNECT {\"verbose\":false,\"tls_required\":false," +
|
||||
"\"user\":\"test\",\"pedantic\":true,\"pass\":\"pass\"}\r\n")
|
||||
|
||||
@@ -306,7 +306,7 @@ func TestSplitConnectArg(t *testing.T) {
|
||||
|
||||
func TestSplitDanglingArgBuf(t *testing.T) {
|
||||
s := New(&defaultServerOptions)
|
||||
c := &client{srv: s, acc: s.gacc, subs: make(map[string]*subscription)}
|
||||
c := &client{srv: s, acc: s.gacc, msubs: -1, mpay: -1, subs: make(map[string]*subscription)}
|
||||
|
||||
// We test to make sure we do not dangle any argBufs after processing
|
||||
// since that could lead to performance issues.
|
||||
@@ -365,7 +365,7 @@ func TestSplitDanglingArgBuf(t *testing.T) {
|
||||
}
|
||||
|
||||
// MSG (the client has to be a ROUTE)
|
||||
c = &client{subs: make(map[string]*subscription), kind: ROUTER}
|
||||
c = &client{msubs: -1, mpay: -1, subs: make(map[string]*subscription), kind: ROUTER}
|
||||
msgop := []byte("RMSG $foo foo 5\r\nhello\r\n")
|
||||
c.parse(msgop[:5])
|
||||
c.parse(msgop[5:10])
|
||||
@@ -445,7 +445,7 @@ func TestSplitRoutedMsgArg(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitBufferMsgOp(t *testing.T) {
|
||||
c := &client{subs: make(map[string]*subscription), kind: ROUTER}
|
||||
c := &client{msubs: -1, mpay: -1, subs: make(map[string]*subscription), kind: ROUTER}
|
||||
msg := []byte("RMSG $G foo.bar _INBOX.22 11\r\nhello world\r")
|
||||
msg1 := msg[:2]
|
||||
msg2 := msg[2:9]
|
||||
|
||||
Reference in New Issue
Block a user