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

[tests] lower flakiness of test_no_parallelism #2690

Merged
merged 1 commit into from
Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tests/core/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ def test_parallelism(self):
self.assertEqual(trManager._finished_flushes, step)
self.assertIs(trManager._trs_to_flush, None)

@attr('unix')
def test_no_parallelism(self):
step = 2
trManager = TransactionManager(timedelta(seconds=0), MAX_QUEUE_SIZE,
Expand All @@ -312,7 +311,11 @@ def test_no_parallelism(self):
self.assertEqual(trManager._running_flushes, 1)
self.assertEqual(trManager._finished_flushes, i)
self.assertEqual(len(trManager._trs_to_flush), step - (i + 1))
time.sleep(1)
time.sleep(1.3)
# Once it's finished
self.assertEqual(trManager._running_flushes, 0)
self.assertEqual(trManager._finished_flushes, 2)
self.assertIs(trManager._trs_to_flush, None)

def test_multiple_endpoints(self):
config = {
Expand All @@ -338,3 +341,5 @@ def test_multiple_endpoints(self):
MetricTransaction({}, {})
# 2 endpoints = 2 transactions
self.assertEqual(len(trManager._transactions), 2)
self.assertEqual(trManager._transactions[0]._endpoint, 'https://app.datadoghq.com')
self.assertEqual(trManager._transactions[1]._endpoint, 'https://app.example.com')
12 changes: 10 additions & 2 deletions tests/core/test_watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ def flush(self):

class PseudoAgent(object):
"""Same logic as the agent, simplified"""
AGENT_CONFIG = {
"bind_host": "localhost",
'endpoints': {
'https://app.datadoghq.com': ['api_key']
},
'forwarder_timeout': 5
}

def busy_run(self):
w = Watchdog(5)
w.reset()
Expand All @@ -162,13 +170,13 @@ def normal_run(self):
w.reset()

def slow_tornado(self):
a = Application(12345, {"bind_host": "localhost"})
a = Application(12345, self.AGENT_CONFIG)
a._watchdog = Watchdog(4)
a._tr_manager = MockTxManager()
a.run()

def fast_tornado(self):
a = Application(12345, {"bind_host": "localhost"})
a = Application(12345, self.AGENT_CONFIG)
a._watchdog = Watchdog(6)
a._tr_manager = MockTxManager()
a.run()
Expand Down
2 changes: 1 addition & 1 deletion transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def flush_next(self):
log.debug("Flushing transaction %d", tr.get_id())
try:
tr.flush()
except Exception as e :
except Exception as e:
log.exception(e)
self.tr_error(tr)
self.flush_next()
Expand Down