Skip to content

Commit

Permalink
Fix #552: Pintracker tests were pinning in parallel
Browse files Browse the repository at this point in the history
When we increased the default concurrency setting
we forgot the tests are for ConcurrentPins=1.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
  • Loading branch information
hsanjuan committed Oct 1, 2018
1 parent 5cdff2a commit fc5a6df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pintracker/pintracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion pintracker/stateless/stateless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fc5a6df

Please sign in to comment.