diff --git a/.travis.yml b/.travis.yml index dbca4c8f..7496612f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_script: - megacheck $EXCLUDE_VENDOR - if [[ "$TRAVIS_GO_VERSION" == 1.10.* ]]; then ./scripts/cross_compile.sh $TRAVIS_TAG; fi script: -- go test -i -race $EXCLUDE_VENDOR +- go test -i $EXCLUDE_VENDOR - if [[ "$TRAVIS_GO_VERSION" == 1.10.* ]]; then ./scripts/cov.sh TRAVIS; else go test -v -race $EXCLUDE_VENDOR; fi after_success: - if [[ "$TRAVIS_GO_VERSION" == 1.10.* ]] && [ "$TRAVIS_TAG" != "" ]; then ghr --owner nats-io --token $GITHUB_TOKEN --draft --replace $TRAVIS_TAG pkg/; fi diff --git a/server/client_test.go b/server/client_test.go index 37f8583f..29271a34 100644 --- a/server/client_test.go +++ b/server/client_test.go @@ -1006,8 +1006,8 @@ func TestDynamicBuffers(t *testing.T) { nc.Flush() m := stopRecording() - if m.rsz != maxBufSize { - t.Fatalf("Expected read buffer of %d, but got %d\n", maxBufSize, m.rsz) + if m.rsz != maxBufSize && m.rsz != maxBufSize/2 { + t.Fatalf("Expected read buffer of %d or %d, but got %d\n", maxBufSize, maxBufSize/2, m.rsz) } if m.wsz > startBufSize { t.Fatalf("Expected write buffer of <= %d, but got %d\n", startBufSize, m.wsz) diff --git a/server/norace_test.go b/server/norace_test.go index 7840bd2f..f208be38 100644 --- a/server/norace_test.go +++ b/server/norace_test.go @@ -47,7 +47,7 @@ func TestAvoidSlowConsumerBigMessages(t *testing.T) { data := make([]byte, 1024*1024) // 1MB payload rand.Read(data) - expected := int32(1000) + expected := int32(500) received := int32(0) done := make(chan bool) @@ -67,7 +67,9 @@ func TestAvoidSlowConsumerBigMessages(t *testing.T) { t.Fatalf("Received an error on the subscription's connection: %v\n", err) }) - for i := int32(0); i < expected; i++ { + nc1.Flush() + + for i := 0; i < int(expected); i++ { nc2.Publish("slow.consumer", data) } nc2.Flush() diff --git a/server/reload_test.go b/server/reload_test.go index 0585def9..eda457a0 100644 --- a/server/reload_test.go +++ b/server/reload_test.go @@ -606,21 +606,18 @@ func TestConfigReloadRotateTokenAuthentication(t *testing.T) { defer os.Remove(config) defer server.Shutdown() + disconnected := make(chan struct{}) + asyncErr := make(chan error) + eh := func(nc *nats.Conn, sub *nats.Subscription, err error) { asyncErr <- err } + dh := func(*nats.Conn) { disconnected <- struct{}{} } + // Ensure we can connect as a sanity check. addr := fmt.Sprintf("nats://%s:%d", opts.Host, opts.Port) - nc, err := nats.Connect(addr, nats.Token("T0pS3cr3t")) + nc, err := nats.Connect(addr, nats.Token("T0pS3cr3t"), nats.ErrorHandler(eh), nats.DisconnectHandler(dh)) if err != nil { t.Fatalf("Error creating client: %v", err) } defer nc.Close() - disconnected := make(chan struct{}) - asyncErr := make(chan error) - nc.SetErrorHandler(func(nc *nats.Conn, sub *nats.Subscription, err error) { - asyncErr <- err - }) - nc.SetDisconnectHandler(func(*nats.Conn) { - disconnected <- struct{}{} - }) // Change authentication token. createSymlink(t, config, "./configs/reload/token_authentication_2.conf") @@ -656,7 +653,6 @@ func TestConfigReloadRotateTokenAuthentication(t *testing.T) { case <-time.After(2 * time.Second): t.Fatal("Expected connection to be disconnected") } - nc.Close() } // Ensure Reload supports enabling token authentication. Test this by starting diff --git a/server/routes_test.go b/server/routes_test.go index 3fd43477..de1226eb 100644 --- a/server/routes_test.go +++ b/server/routes_test.go @@ -862,7 +862,7 @@ func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) { func TestRoutedQueueAutoUnsubscribe(t *testing.T) { optsA, _ := ProcessConfigFile("./configs/seed.conf") optsA.NoSigs, optsA.NoLog = true, true - optsA.RQSubsSweep = 250 * time.Millisecond + optsA.RQSubsSweep = 500 * time.Millisecond srvA := RunServer(optsA) defer srvA.Shutdown() @@ -882,6 +882,7 @@ func TestRoutedQueueAutoUnsubscribe(t *testing.T) { t.Fatalf("Error on connect: %v", err) } defer ncA.Close() + ncB, err := nats.Connect(fmt.Sprintf("nats://%s:%d", optsB.Host, optsB.Port)) if err != nil { t.Fatalf("Error on connect: %v", err) diff --git a/test/cluster_test.go b/test/cluster_test.go index c7d183b8..4bca2fc3 100644 --- a/test/cluster_test.go +++ b/test/cluster_test.go @@ -447,6 +447,8 @@ func TestAutoUnsubscribePropagation(t *testing.T) { sendA("PING\r\n") expectA(pongRe) + time.Sleep(50 * time.Millisecond) + // Make sure number of subscriptions on B is correct if subs := srvB.NumSubscriptions(); subs != 0 { t.Fatalf("Expected no subscriptions on remote server, got %d\n", subs)