Make StatsD tests less flaky.
There have been a bunch of Jenkins failures lately where the StatsD tests fail because they can't bind to their desired port. There's nothing special about the particular port they're using, so now we let the kernel pick an available one for us. This also lets us get rid of a sleep() in the test that looked like an attempt to alleviate EADDRINUSE errors, so now in the happy case, the tests are a few fractions of a second faster. Change-Id: Idee11349254107a59643539b1566f3588eee7ef4
This commit is contained in:
1 changed files with 2 additions and 3 deletions
@@ -984,9 +984,9 @@ class TestStatsdLogging(unittest.TestCase):
class TestStatsdLoggingDelegation(unittest.TestCase):
def setUp(self):
self.port = 9177
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.bind(('localhost', self.port))
self.sock.bind(('localhost', 0))
self.port = self.sock.getsockname()[1]
self.queue = Queue()
self.reader_thread = Thread(target=self.statsd_reader)
self.reader_thread.setDaemon(1)
@@ -1004,7 +1004,6 @@ class TestStatsdLoggingDelegation(unittest.TestCase):
self.reader_thread.join(timeout=4)
self.sock.close()
del self.logger
time.sleep(0.15) # avoid occasional "Address already in use"?
def statsd_reader(self):
while True:
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.