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 net/mocknet in integration tests #470

Merged
merged 28 commits into from
Dec 25, 2014
Merged

use net/mocknet in integration tests #470

merged 28 commits into from
Dec 25, 2014

Conversation

btc
Copy link
Contributor

@btc btc commented Dec 24, 2014

This PR adds the net/mocknet to the tests/benchmarks that perform the Add/Cat operation.

@jbenet @whyrusleeping

TODOs:

  • remove panics
  • revise and cleanup
  • does mocknet require cleanup? mn.Close()?
  • when setting up mocknet, is it sufficient to link, but not connect peers?
  • private key generation is really expensive/slows down tests. got any ideas for faster fixture generation that meets mocknet requirements? Would @whyrusleeping's parameterized version solve this problem?
  • bootstrap DHT

@btc btc added the status/in-progress In progress label Dec 24, 2014
@btc btc mentioned this pull request Dec 24, 2014
@jbenet
Copy link
Member

jbenet commented Dec 24, 2014

@maybebtc is this LFCR ?

if _, err := mn.LinkPeers(i, j); err != nil {
return err
}
if err := mn.ConnectPeers(i, j); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's necessary to link peers, but not necessary to connect them, right?

@jbenet

Copy link
Member

Choose a reason for hiding this comment

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

@maybebtc

  • Link means that a connection is possible. (think physical link)
  • Connect means "open a connection". (think a net.Conn)

So yeah, you dont have to link nodes together, if someone will try to find the node and Dial as the result of some other actions in the test.

@btc
Copy link
Contributor Author

btc commented Dec 24, 2014

@jbenet RFCR please see questions on original post.

@jbenet
Copy link
Member

jbenet commented Dec 24, 2014

  • does mocknet require cleanup? mn.Close()?

We can add one for good practice. But no, it's just a struct.

  • when setting up mocknet, is it sufficient to link, but not connect peers?

Depends on what your code will do. If you code will open connections itself then no need to connect. if your code assumes that nodes have a live connection, then yes. (e.g. dht needs a few nodes bootstrapped (connected already) and from there it can open more connections by itself).

  • private key generation is really expensive/slows down tests. got any ideas for faster fixture generation that meets mocknet requirements? Would @whyrusleeping's parameterized version solve this problem?

Mocknet itself doesnt need the keys itself. They're there because things outside using mocknet may assume they have public keys because a connection is open. So it depends on your test. (we could add a function if you want, but you'll have to either setup the nodes with things that behave like keys, make sure you dont use anything that expects keys to be there).

ID() peer.ID
PrivateKey() ci.PrivKey
PublicKey() ci.PubKey
}
Copy link
Member

Choose a reason for hiding this comment

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

please rename this to something other than Peer. suggest just using PeerNetParams directly. I just got done removing Peer from the entire codebase. It will breed confusion and break things. Also, anything called Peer shouldn't "contain" addresses. the ephemeral + indeterminate state of addresses is a source of so, so much pain. (peers can have many, can gain + lose them, might have different mappings depending on where two peers are in the network, might have complete information, might selectively expose addresses to some peers, etc etc etc.)

Why not just use PeerNetParams ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is testutil.Peer. The name is pretty clear.

Why not just use PeerNetParams ?

Don't want to tie down callsites to a concrete type that's subject to change.

Copy link
Member

Choose a reason for hiding this comment

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

  1. Package names are not global. they are rebound locally. tu.Peer is no longer so clear.
  2. it's Peer. please, i'm specifically requesting that we do not expose things named Peer anymore that represent an ipfs' peer's Identity, and purport to carry addresses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed 0172e4f

@jbenet
Copy link
Member

jbenet commented Dec 24, 2014

LGTM other than:

  • rename Peer to something else.
  • rebase on top of new master (just merged dht fixes #473)

Brian Tiger Chow added 20 commits December 24, 2014 09:31
so it'll be easier to create another implementation using the new
mocknet
…ersion

License: MIT
Signed-off-by: Brian Tiger Chow <[email protected]>
License: MIT
Signed-off-by: Brian Tiger Chow <[email protected]>
…kpeernet under the hood

License: MIT
Signed-off-by: Brian Tiger Chow <[email protected]>
@whyrusleeping @jbenet this is a WIP with the DHT.

wip

License: MIT
Signed-off-by: Brian Tiger Chow <[email protected]>

Conflicts:
	epictest/addcat_test.go
	exchange/bitswap/testnet/peernet.go
	exchange/bitswap/testutils.go
	routing/mock/centralized_server.go
	routing/mock/centralized_test.go
	routing/mock/interface.go

fix(routing/mock) fill in function definition
pprof cannot be used reliably on OS X. This provides two make tasks to
collect and analyze profiling data.

To run profiling in a dockerized linux environment...
```
make // or `make collect`
```

To analyze results on host machine...
```
make analyze
```

@jbenet @whyrusleeping
It's now possible to produce the DHT issues without process
orchestration.

Test1KBInstantaneous fails

@jbenet @whyrusleeping
@btc
Copy link
Contributor Author

btc commented Dec 24, 2014

We can add one for good practice. But no, it's just a struct.

👍
Just want to make sure I'm not leaking goroutines and slowing down tests.

@jbenet
Copy link
Member

jbenet commented Dec 24, 2014

thanks! lgtm

@btc
Copy link
Contributor Author

btc commented Dec 24, 2014

still has two TODOs

  • faster key generation
  • bootstrap the DHT

@whyrusleeping
Copy link
Member

@maybebtc my key generation using u.NewTimeSeededRand works a good deal faster. We should be using that for all keys generated in tests.

@whyrusleeping
Copy link
Member

(I do this in my branch provides-rewrite and running a full test suite is tolerable on my chromebook now)

@btc
Copy link
Contributor Author

btc commented Dec 25, 2014

@jbenet @whyrusleeping the test reproduces the docker network test failure. context deadline exceeded when adding and catting through a bootstrap node.

ready for merge

@whyrusleeping
Copy link
Member

This looks good to me, the peer generation stuff gets some work in my branch, but as you said, we might want to merge this one first.

Brian Tiger Chow added 3 commits December 25, 2014 04:07
refactor(epictest) Core

refactor: extract repo

fix

move core
@btc
Copy link
Contributor Author

btc commented Dec 25, 2014

merging in

NB: this triggers go test failures

btc pushed a commit that referenced this pull request Dec 25, 2014
use `net/mocknet` in integration tests
@btc btc merged commit 95ba056 into master Dec 25, 2014
@btc btc removed the status/in-progress In progress label Dec 25, 2014
@btc btc deleted the feat/use-mocknet branch December 25, 2014 09:11
ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this pull request Oct 23, 2021
…com/multiformats/go-multiaddr-0.2.1

build(deps): bump github.com/multiformats/go-multiaddr from 0.2.0 to 0.2.1
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.

3 participants