nskinkel / oppy

A Tor client (onion proxy) implementation in Python
BSD 3-Clause "New" or "Revised" License
24 stars 3 forks source link

Speed up unittest's #34

Closed nskinkel closed 9 years ago

nskinkel commented 9 years ago

Unit tests are running way too slow. This is because we're downloading a new consensus and copy of server descriptors for each test file (and in netstatus' case, for every test).

This is bad.

We should:

The only real challenge here will be that the information will go out of date after a while, so reading from a file will eventually just fail to make connections to certain routers, causing mysterious errors.

The solution is to write a test driver that can grab new copies of the documents at some interval and then supply them to the test cases to use.

This should be done in demo/master.

dwtj commented 9 years ago

Why would the connection being unable to connect to a router be a "mysterious error". That should be a common exception that we need to catch.

Anyway, how you solve this is completely up to you, but here's a thought.

What if we had copies of the consensus and the descriptor file in something like oppy/tests/data. Any new copies that were downloaded by the "real" unit test could be put in here. Then whenever you instantiated a netstatus object you passed a flag to distinguish between three different modes:

This issue is part of a larger more general one. Twisted unit tests should avoid making any network connections. However, mocking tests, esp. network connection/protocol tests would be a lot of work, way too much for us at this stage.

nskinkel commented 9 years ago

Yea that's along the lines of what I was thinking.

Only mysterious error at this early stage because (at least speaking for myself) some parts of code need a lot more robust error checking that's currently lacking and probably won't be implemented before the demo.