Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

storage/pin: fix getAllChunksFromDB test function #1878

Merged
merged 1 commit into from
Oct 21, 2019
Merged

Conversation

janos
Copy link
Member

@janos janos commented Oct 15, 2019

This PR fixes collectPinnedChunks method in test API which makes tests in storage/pin flaky:

--- FAIL: TestPinCollectionUploadEncrypted (0.17s)
    pin_test.go:84: Expected number of chunks to be 38, but is 40
FAIL
FAIL    github.com/ethersphere/swarm/storage/pin    1.031s

There are two issues.

One is the asynchronous getting of chunks which wait for only 10ms (as context timeout) for all chunks to be retrieved from the database, which may be problematic on Travis when it slows down. Even the context done error was not handled in the goroutine, only a return, resulting incomplete chunks slice returned from collectPinnedChunks. This PR uses LastPullSubscriptionBinID to correctly get the right number of chunks and removes goroutines as they only introduce complexity for such small number of chunks. Test are not slowed down.

The second issue is that the for loop had an invalid break condition on chunk.MaxPO, not including the max proximity order (last value).

Copy link
Contributor

@mortelli mortelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

the timeout and end condition for the loop changes seem OK. besides that, the old implementation seems a bit too complex, since it uses both channels as well as mutexes. it seems it didn't handle errors either.

due to my unfamiliarity with the code, i would prefer to leave the approval to someone who is more knowledgeable in the storage and pin packages (maybe @jmozah or someone from core).

@janos janos merged commit 230c565 into master Oct 21, 2019
@janos janos deleted the fix-pinning-tests branch October 21, 2019 13:30
@acud acud added this to the 0.5.3 milestone Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants