mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
test: fix TestAccountImportSubjectMapping hanging build (#4386)
Added timeout to test to prevent running into go test timeout in case messages did not arrive on time. ``` === RUN TestAccountImportSubjectMapping panic: test timed out after 30m0s goroutine 85 [chan receive, 29 minutes]: github.com/nats-io/nats-server/v2/test.TestAccountImportSubjectMapping(0xc000007d40) /workspace/build/buildkite/synadia/nats-server-go-v1-21/test/accounts_cycles_test.go:466 +0x5d2 testing.tRunner(0xc000007d40, 0x11e1818) /usr/local/go/src/testing/testing.go:1595 +0x239 created by testing.(*T).Run in goroutine 1 /usr/local/go/src/testing/testing.go:1648 +0x82b ```
This commit is contained in:
@@ -419,17 +419,17 @@ func TestAccountSubjectMapping(t *testing.T) {
|
||||
// Alice imports from Bob with subject mapping
|
||||
func TestAccountImportSubjectMapping(t *testing.T) {
|
||||
conf := createConfFile(t, []byte(`
|
||||
port: -1
|
||||
accounts {
|
||||
A {
|
||||
users: [{user: a, pass: x}]
|
||||
imports [ {stream: {account: B, subject: "foo.*.*"}, to : "foo.$1.{{wildcard(2)}}"}]
|
||||
}
|
||||
B {
|
||||
users: [{user: b, pass x}]
|
||||
exports [ { stream: ">" } ]
|
||||
}
|
||||
}
|
||||
port: -1
|
||||
accounts {
|
||||
A {
|
||||
users: [{user: a, pass: x}]
|
||||
imports [ {stream: {account: B, subject: "foo.*.*"}, to : "foo.$1.{{wildcard(2)}}"}]
|
||||
}
|
||||
B {
|
||||
users: [{user: b, pass x}]
|
||||
exports [ { stream: ">" } ]
|
||||
}
|
||||
}
|
||||
`))
|
||||
|
||||
s, opts := RunServerWithConfig(conf)
|
||||
@@ -449,6 +449,7 @@ func TestAccountImportSubjectMapping(t *testing.T) {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
sub1.AutoUnsubscribe(numMessages)
|
||||
ncA.Flush()
|
||||
|
||||
ncB := clientConnectToServerWithUP(t, opts, "b", "x")
|
||||
defer ncB.Close()
|
||||
@@ -463,7 +464,12 @@ func TestAccountImportSubjectMapping(t *testing.T) {
|
||||
}
|
||||
|
||||
for i := 0; i < numMessages; i++ {
|
||||
subject := <-subjectsReceived
|
||||
var subject string
|
||||
select {
|
||||
case subject = <-subjectsReceived:
|
||||
case <-time.After(1 * time.Second):
|
||||
t.Fatal("Timed out waiting for messages")
|
||||
}
|
||||
sTokens := strings.Split(subject, ".")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user