Files
Matthew Oliver
e6b73612d1
FakeStatsdClient: Stop issuing DNS calls for host.
Running unittests on my home server, even though is a beast, would be painfully slow. Running them on my laptop ran much faster. I tried everything and couldn't figure it out. Chris, co-author, dug in and after we ran out of options he fired up his packet capture and realised most tests were issuing DNS queries for `host.`. On my home server, it runs ipv6 dual stack, so these calls would need to timeout before a test can continue. On finding this `host.` Ben, another co-author, dug into the code and found the only reference we have to `host` is in FakeStatsdClient. Sure enough as I dug a little further it turns out our FakeStatsdClient used to override a StatsdClient function `_determine_sock_family(self, host, port)` to stop actually creating a real socket. However, at some point the StatsdClient was refactored and that method was renamed and changed. Which leads to a DNS lookup every time we create a debug_logger as it brings up the socket. As you can imagine, this happens alot! This patch overrides the new function that handles to socket creation `_set_sock_family_and_target(self, host, port)`. Which eliminates the DNS call all together. Co-Authored-By: Ben Formosa <bformosa@nvidia.com> Co-Authored-By: Chris Smart <csmart@nvidia.com> Change-Id: Ie393075f79447627714692e3f01bb53e967a71e8