From fc5a6df3ad47172d63a2c745a0f1b265775639a6 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 1 Oct 2018 14:59:14 +0200 Subject: [PATCH] Fix #552: Pintracker tests were pinning in parallel When we increased the default concurrency setting we forgot the tests are for ConcurrentPins=1. License: MIT Signed-off-by: Hector Sanjuan --- pintracker/pintracker_test.go | 2 ++ pintracker/stateless/stateless_test.go | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pintracker/pintracker_test.go b/pintracker/pintracker_test.go index 6b903e850..4ea26bc40 100644 --- a/pintracker/pintracker_test.go +++ b/pintracker/pintracker_test.go @@ -202,6 +202,7 @@ var sortPinInfoByCid = func(p []api.PinInfo) { func testSlowMapPinTracker(t testing.TB) *maptracker.MapPinTracker { cfg := &maptracker.Config{} cfg.Default() + cfg.ConcurrentPins = 1 mpt := maptracker.NewMapPinTracker(cfg, test.TestPeerID1, test.TestPeerName1) mpt.SetClient(mockRPCClient(t)) return mpt @@ -210,6 +211,7 @@ func testSlowMapPinTracker(t testing.TB) *maptracker.MapPinTracker { func testMapPinTracker(t testing.TB) *maptracker.MapPinTracker { cfg := &maptracker.Config{} cfg.Default() + cfg.ConcurrentPins = 1 mpt := maptracker.NewMapPinTracker(cfg, test.TestPeerID1, test.TestPeerName1) mpt.SetClient(test.NewMockRPCClient(t)) return mpt diff --git a/pintracker/stateless/stateless_test.go b/pintracker/stateless/stateless_test.go index e7dab51d0..687c4257a 100644 --- a/pintracker/stateless/stateless_test.go +++ b/pintracker/stateless/stateless_test.go @@ -102,6 +102,7 @@ func (mock *mockService) PinGet(ctx context.Context, in api.PinSerial, out *api. func testSlowStatelessPinTracker(t *testing.T) *Tracker { cfg := &Config{} cfg.Default() + cfg.ConcurrentPins = 1 mpt := New(cfg, test.TestPeerID1, test.TestPeerName1) mpt.SetClient(mockRPCClient(t)) return mpt @@ -110,6 +111,7 @@ func testSlowStatelessPinTracker(t *testing.T) *Tracker { func testStatelessPinTracker(t testing.TB) *Tracker { cfg := &Config{} cfg.Default() + cfg.ConcurrentPins = 1 spt := New(cfg, test.TestPeerID1, test.TestPeerName1) spt.SetClient(test.NewMockRPCClient(t)) return spt @@ -193,6 +195,11 @@ func TestTrackUntrackWithCancel(t *testing.T) { } } +// This tracks a slow CID and then tracks a fast/normal one. +// Because we are pinning the slow CID, the fast one will stay +// queued. We proceed to untrack it then. Since it was never +// "pinning", it should simply be unqueued (or ignored), and no +// cancelling of the pinning operation happens (unlike on WithCancel). func TestTrackUntrackWithNoCancel(t *testing.T) { spt := testSlowStatelessPinTracker(t) defer spt.Shutdown() @@ -234,7 +241,7 @@ func TestTrackUntrackWithNoCancel(t *testing.T) { // t.Fatal(ErrPinCancelCid) // } } else { - t.Error("fastPin should be queued to pin") + t.Errorf("fastPin should be queued to pin but is %s", fastPInfo.Status) } pi := spt.optracker.Get(fastPin.Cid)