Testing networking services is hard
See original GitHub issueWhat is wrong?
Testing networking services in isolation is quite difficult right now, as discussed in #688 .
How can it be fixed
I think we should try to separate different layers of the code more so that we can replace them easily. Here’s a concrete proposal:
- Each
BasePeer
gets aBasePeerInterface
instance.BasePeer
callsBasePeerInterface.send_command(command)
,BasePeerInterface
callsBasePeer.process_command(command)
(alternatively, both classes have acommand_queue
on which they put commands on). - To allow this,
Command
s keep parameters as instance variables. StreamPeerInterface
(or justPeerInterface
) writes commands to the output stream and reads them from the input stream, just like the currentBasePeer
does.- For tests, there’s a
MockPeerInterface
that passes commands through to a sharedNetwork
object that sends them to the receivingMockPeerInterface
. That means that nothing goes over a network interface and nothing needs to be encoded or decoded. - Add a
MockDiscovery
which gets a list of peer pools to “discover”. PeerPool
makes thehandshake
function configurable, either by taking it as a constructor argument or by making aBasePeerPool
and requiring it to implement it in sub classes. We add amock_handshake
that looks up the remote inNetwork
and creates a new peer with aMockPeerInterface
.
I haven’t thought this through completely (especially how it affects PeerPool
and Server
), but don’t have more time just now and wanted to write it down. Will update this tonight when I’ll hopefully had some more time.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Top 5 Networking Challenges and How Network Testing Can ...
Today's solutions offer a variety of end-to-end performance testing (for latency, loss, jitter and path analysis). For example, if a client is ...
Read more >Network Testing: How to Test Network Performance - Obkio
Learn how to perform network testing using Network Monitoring tools to test network performance, and identify network bugs and issues.
Read more >Network Testing
One difficult problem for test planning and execution is that only a small number of networks, at best, can actually be tested, even...
Read more >Why hitting the network is bad for your test, and ... - mokacoding
Having your tests hit the network adds the network speed as a constraint to how fast your tests can run, hence how quick...
Read more >Why network testing is important | NetBeez
Network testing is important to test and validate your network design. Here's a list of handful of command line tools to do so....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
One problem with those big architectural redesigns is that usually nobody will have the time/willpower to implement them, so we end up doing things in a suboptimal way waiting for a redesign that will never come. Instead I very much prefer to make small improvements every time I touch a piece of code. For instance, although testing async code is hard and we’re severely lacking on infrastructure for that, we do have some and with some small improvements the existing sharding tests can be a lot simpler and much less fragile
I think that’s a fair point, and probably a good conservative approach. I’d be game to re-visit this when/if someone feels like they have a sufficiently good handle on how to do it and the time to execute on it.