Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1376)

Unified Diff: appengine/chromium_try_flakes/handlers/test/flake_issues_test.py

Issue 2007133005: Cap the maximum number of flaky tests that we record from a step (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Added test Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/chromium_try_flakes/handlers/flake_issues.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/chromium_try_flakes/handlers/test/flake_issues_test.py
diff --git a/appengine/chromium_try_flakes/handlers/test/flake_issues_test.py b/appengine/chromium_try_flakes/handlers/test/flake_issues_test.py
index dfee81ca3ca456a3c898521c61efbf7074f1db9a..c252f02b4c2be2fb83b8ac6e52c1ab8fc774da9a 100644
--- a/appengine/chromium_try_flakes/handlers/test/flake_issues_test.py
+++ b/appengine/chromium_try_flakes/handlers/test/flake_issues_test.py
@@ -857,6 +857,39 @@ class CreateFlakyRunTestCase(testing.AppengineTestCase):
for flake in flakes:
self.assertEqual(flake.occurrences, [flaky_run.key])
+ def test_records_step_as_a_flake_when_too_many_tests_fail(self):
+ now = datetime.datetime.utcnow()
+ br_f, br_s = self._create_build_runs(now - datetime.timedelta(hours=1), now)
+ urlfetch_mock = mock.Mock(side_effect = [
+ # Buildbot reply.
+ mock.Mock(status_code=200, content=json.dumps({
+ 'steps': [
+ {'results': [2], 'name': 'test-step', 'text': ['']},
+ ]
+ })),
+ # Test-results reply.
+ mock.Mock(status_code=200, content=json.dumps({
+ 'tests': {
+ 'test%d' % i: {
+ 'expected': 'PASS',
+ 'actual': 'FAIL',
+ } for i in range(51)
+ }
+ }))
+ ])
+
+ with mock.patch('google.appengine.api.urlfetch.fetch', urlfetch_mock):
+ self.test_app.post('/issues/create_flaky_run',
+ {'failure_run_key': br_f.urlsafe(),
+ 'success_run_key': br_s.urlsafe()})
+
+ flaky_runs = FlakyRun.query().fetch(100)
+ self.assertEqual(len(flaky_runs), 1)
+ flaky_run = flaky_runs[0]
+ self.assertEqual(len(flaky_run.flakes), 1)
+ self.assertEqual(flaky_run.flakes[0].name, 'test-step')
+ self.assertEqual(flaky_run.flakes[0].failure, 'test-step')
+
def test_flattens_tests_correctly(self):
passed, failed, skipped = CreateFlakyRun._flatten_tests(
json.loads(TEST_TEST_RESULTS_REPLY)['tests'], '/')
« no previous file with comments | « appengine/chromium_try_flakes/handlers/flake_issues.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698