-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle and enforce max payload
- Loading branch information
1 parent
9a60bc1
commit 075529e
Showing
14 changed files
with
180 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright 2015 Apcera Inc. All rights reserved. | ||
|
||
# Config file to test overrides to client | ||
|
||
port: 4224 | ||
|
||
# maximum payload | ||
max_payload: 2222 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2015 Apcera Inc. All rights reserved. | ||
|
||
package test | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/nats-io/nats" | ||
) | ||
|
||
func TestMaxPayload(t *testing.T) { | ||
srv, opts := RunServerWithConfig("./configs/override.conf") | ||
defer srv.Shutdown() | ||
|
||
nc, err := nats.Connect(fmt.Sprintf("nats://%s:%d/", opts.Host, opts.Port)) | ||
if err != nil { | ||
t.Fatalf("Could not connect to server: %v", err) | ||
} | ||
defer nc.Close() | ||
|
||
big := sizedBytes(4 * 1024 * 1024) | ||
nc.Publish("foo", big) | ||
err = nc.FlushTimeout(1 * time.Second) | ||
if err == nil { | ||
t.Fatalf("Expected an error from flush") | ||
} | ||
if strings.Contains(err.Error(), "Maximum Payload Violation") != true { | ||
t.Fatalf("Received wrong error message (%v)\n", err) | ||
} | ||
if !nc.IsClosed() { | ||
t.Fatalf("Expected connection to be closed") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2015 Apcera Inc. All rights reserved. | ||
|
||
package test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestServerConfig(t *testing.T) { | ||
srv, opts := RunServerWithConfig("./configs/override.conf") | ||
defer srv.Shutdown() | ||
|
||
c := createClientConn(t, opts.Host, opts.Port) | ||
defer c.Close() | ||
|
||
sinfo := checkInfoMsg(t, c) | ||
if sinfo.MaxPayload != opts.MaxPayload { | ||
t.Fatalf("Expected max_payload from server, got %d vs %d", | ||
opts.MaxPayload, sinfo.MaxPayload) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters