From 43d9e3838b0cdbaf19368d4ed7f9bd0b3ce7c6de Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Fri, 5 Jun 2020 18:09:04 -0600 Subject: [PATCH] Fixed possible test data races Update Travis go matrix to 1.14/1.13 instead of 1.13/1.12 Signed-off-by: Ivan Kozlovic --- .travis.yml | 2 +- server/clustering_test.go | 8 ++++++-- server/server_delivery_test.go | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e76d37f..54c6c68c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ os: - windows language: go go: -- 1.12.x +- 1.14.x - 1.13.x addons: apt: diff --git a/server/clustering_test.go b/server/clustering_test.go index e8bae326..5729a4c2 100644 --- a/server/clustering_test.go +++ b/server/clustering_test.go @@ -7139,10 +7139,12 @@ func TestClusteringRestoreSnapshotErrorDontSkipSeq(t *testing.T) { t.Fatalf("Error on snapshot: %v", err) } - c := s1.channels.get("foo") ch1 := make(chan struct{}) ch2 := make(chan bool) + s1.channels.Lock() + c := s1.channels.channels["foo"] c.store.Msgs = &blockingLookupStore{MsgStore: c.store.Msgs, inLookupCh: ch1, releaseCh: ch2} + s1.channels.Unlock() // Configure second server. s3sOpts := getTestDefaultOptsForClustering("c", false) @@ -7257,10 +7259,12 @@ func TestClusteringRestoreSnapshotGapInSeq(t *testing.T) { t.Fatalf("Error on snapshot: %v", err) } - c := s1.channels.get("foo") ch1 := make(chan struct{}) ch2 := make(chan bool) + s1.channels.Lock() + c := s1.channels.channels["foo"] c.store.Msgs = &blockingLookupStore{MsgStore: c.store.Msgs, inLookupCh: ch1, releaseCh: ch2} + s1.channels.Unlock() // Configure second server. s3sOpts := getTestDefaultOptsForClustering("c", false) diff --git a/server/server_delivery_test.go b/server/server_delivery_test.go index 420996f9..cd151ca5 100644 --- a/server/server_delivery_test.go +++ b/server/server_delivery_test.go @@ -353,10 +353,12 @@ func TestDeliveryRaceBetweenNextMsgAndStoring(t *testing.T) { sc.Publish("foo", []byte("msg1")) - c := s.channels.get("foo") ch1 := make(chan struct{}) ch2 := make(chan bool) + s.channels.Lock() + c := s.channels.channels["foo"] c.store.Msgs = &blockingLookupStore{MsgStore: c.store.Msgs, inLookupCh: ch1, releaseCh: ch2} + s.channels.Unlock() sub := s.clients.getSubs(clientName)[0] wg := sync.WaitGroup{}