Merge pull request #708 from nats-io/flaky

Fix for flaky tests
This commit is contained in:
Ivan Kozlovic
2018-07-03 11:31:23 -06:00
committed by GitHub
6 changed files with 17 additions and 16 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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()

View File

@@ -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

View File

@@ -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)

View File

@@ -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)