Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ipfsd-ctl to create test IPFS instances #335

Merged
merged 1 commit into from
Mar 27, 2018

Conversation

haadcode
Copy link
Member

@haadcode haadcode commented Mar 9, 2018

This PR brings back ipfsd-ctl to create test IPFS instances.

In addition, this PR will move a lot of the boilerplate test setup code to it's on test utils as well as fix some basic tests for the stores and remove couple of obsolete/unused public methods from OrbitDB class.

@haadcode haadcode force-pushed the feat/tests-with-ipfsd-ctl branch 7 times, most recently from a166fe9 to e394205 Compare March 9, 2018 14:42
if(orbitdb1)
await orbitdb1.stop()
Object.keys(testAPIs).forEach(API => {
describe.only(`orbit-db - Replication (${API})`, function() {
Copy link
Member

@thiagodelgado111 thiagodelgado111 Mar 14, 2018

Choose a reason for hiding this comment

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

The .only here will avoid other tests from running on CI (Just pointing it out to avoid it being merged accidentally)

@thiagodelgado111
Copy link
Member

thiagodelgado111 commented Mar 14, 2018

I'm getting an error log while running tests locally – this time with the automatic replication suite but it happened with the replication suite before as well. Maybe it's just a negative test failing as expected?

Error: underlying socket has been closed
    at /orbit-db/node_modules/multiplex/src/index.js:477:37
    at Array.forEach (<anonymous>)
    at Multiplex.destroy (/orbit-db/node_modules/multiplex/src/index.js:475:10)
    at MultiplexMuxer.end (/orbit-db/node_modules/libp2p-multiplex/src/muxer.js:49:20)
    at each (/orbit-db/node_modules/libp2p-swarm/src/index.js:127:20)
    at /orbit-db/node_modules/async/internal/withoutIndex.js:9:16
    at replenish (/orbit-db/node_modules/async/internal/eachOfLimit.js:64:17)
    at /orbit-db/node_modules/async/internal/eachOfLimit.js:68:9
    at eachOfLimit (/orbit-db/node_modules/async/eachOfLimit.js:39:36)
    at /orbit-db/node_modules/async/internal/doLimit.js:9:16
    at exports.default (/orbit-db/node_modules/async/eachOf.js:9:5)
    at eachLimit (/orbit-db/node_modules/async/each.js:80:24)
    at series (/orbit-db/node_modules/libp2p-swarm/src/index.js:126:15)
    at /orbit-db/node_modules/async/internal/parallel.js:31:39
    at replenish (/orbit-db/node_modules/async/internal/eachOfLimit.js:64:17)
    at /orbit-db/node_modules/async/internal/eachOfLimit.js:68:9
    at eachOfLimit (/orbit-db/node_modules/async/eachOfLimit.js:39:36)
    at /orbit-db/node_modules/async/internal/doLimit.js:9:16
    at _parallel (/orbit-db/node_modules/async/internal/parallel.js:30:5)
    at series (/orbit-db/node_modules/async/series.js:83:26)
    at Swarm.close (/orbit-db/node_modules/libp2p-swarm/src/index.js:125:5)
    at series (/orbit-db/node_modules/libp2p/src/index.js:240:26)
    at /orbit-db/node_modules/async/internal/parallel.js:31:39
    at replenish (/orbit-db/node_modules/async/internal/eachOfLimit.js:64:17)
    at iterateeCallback (/orbit-db/node_modules/async/internal/eachOfLimit.js:49:17)
    at /orbit-db/node_modules/async/internal/onlyOnce.js:12:16
    at /orbit-db/node_modules/async/internal/parallel.js:36:13
    at series (/orbit-db/node_modules/libp2p/src/index.js:238:9)
    at /orbit-db/node_modules/async/internal/parallel.js:31:39
    at replenish (/orbit-db/node_modules/async/internal/eachOfLimit.js:64:17)
    at /orbit-db/node_modules/async/internal/eachOfLimit.js:68:9
    at eachOfLimit (/orbit-db/node_modules/async/eachOfLimit.js:39:36)
    at /orbit-db/node_modules/async/internal/doLimit.js:9:16
    at _parallel (/orbit-db/node_modules/async/internal/parallel.js:30:5)
    at series (/orbit-db/node_modules/async/series.js:83:26)
    at Node.stop (/orbit-db/node_modules/libp2p/src/index.js:233:5)
    at Function.stop.promisify (/orbit-db/node_modules/ipfs/src/core/components/libp2p.js:66:24)
    at Object.stop (/orbit-db/node_modules/promisify-es6/index.js:32:27)
    at series (/orbit-db/node_modules/ipfs/src/core/components/stop.js:35:27)
    at /orbit-db/node_modules/async/internal/parallel.js:31:39
    at replenish (/orbit-db/node_modules/async/internal/eachOfLimit.js:64:17)
    at iterateeCallback (/orbit-db/node_modules/async/internal/eachOfLimit.js:49:17)
    at /orbit-db/node_modules/async/internal/onlyOnce.js:12:16
    at /orbit-db/node_modules/async/internal/parallel.js:36:13
    at asyncEach (/orbit-db/node_modules/libp2p-floodsub/src/index.js:284:7)
    at /orbit-db/node_modules/async/internal/once.js:12:16
    at iterateeCallback (/orbit-db/node_modules/async/internal/eachOfLimit.js:47:24)
    at /orbit-db/node_modules/async/internal/onlyOnce.js:12:16
    at setImmediate (/orbit-db/node_modules/libp2p-floodsub/src/peer.js:182:7)
    at Immediate._onImmediate (/orbit-db/node_modules/async/internal/setImmediate.js:27:16)
    at runCallback (timers.js:756:18)
    at tryOnImmediate (timers.js:717:5)
    at processImmediate [as _immediateCallback] (timers.js:697:5)

@haadcode haadcode force-pushed the feat/tests-with-ipfsd-ctl branch 5 times, most recently from 5109479 to d5c1ff9 Compare March 17, 2018 10:22
@haadcode
Copy link
Member Author

The tests are finally passing again.

I added a workaround for the "Error: underlying socket has been closed" error, as it seems really weird. See here https://github.com/orbitdb/orbit-db/pull/335/files#diff-11b1d30de414c2bebf3a03b5f2bd1b73R48 and here https://github.com/orbitdb/orbit-db/pull/335/files#diff-b1d58ced77879cec2a109423fb3755a8R87. Not sure what's happening but it may not be related to libp2p because if we comment out the leveldb's method to destroy the files from the local filesystem (https://github.com/orbitdb/orbit-db-cache/blob/master/Cache.js#L59 which gets called from https://github.com/orbitdb/orbit-db-store/blob/master/src/Store.js#L171), the error is gone 😕❓❓❓😕

Otherwise, this is ready for merge but would love another round of review to catch any issues!

@thiagodelgado111
Copy link
Member

I have no idea :/ Pulled your last changes, reinstalled everything and now tests are passing. Previously it was failing intermittently, so it does look like a race condition situation

@haadcode haadcode force-pushed the feat/tests-with-ipfsd-ctl branch 2 times, most recently from 343fbfb to e445331 Compare March 24, 2018 15:29
@haadcode
Copy link
Member Author

Found the bug and it was indeed a race condition. We were not waiting for unsubscribing from pubsub internally and that caused the race (receiving messages after closing the database). Fixed it and updated the PR and removed the timeout workarounds from the test.

Ready to merge.

Fix default database creation tests
Add more test utils
Remove obsolete public methods from OrbitDB
Workaround for "underlying socket has been closed" error in replication test
Update package-lock
@haadcode haadcode force-pushed the feat/tests-with-ipfsd-ctl branch from e445331 to 3318b6a Compare March 27, 2018 12:31
@haadcode haadcode merged commit 99c69b6 into master Mar 27, 2018
@haadcode
Copy link
Member Author

haadcode commented Mar 27, 2018

Thanks @thiagodelgado111 and everyone else who tested and reviewed this PR! ❤️ It's now in master and would love some more testing.

Will be merging #328 and then make a new release (0.20.0). Hopefully this week.

@haadcode haadcode deleted the feat/tests-with-ipfsd-ctl branch March 27, 2018 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants