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

Side by Side Diff: appengine/findit/test/findit_api_test.py

Issue 2439553002: [Findit] Reduce redundant ndb reads by querying necessary entities ahead of time and share them amo… (Closed)
Patch Set: fix nit. Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import mock 6 import mock
7 import re 7 import re
8 8
9 from google.appengine.api import taskqueue 9 from google.appengine.api import taskqueue
10 import webtest 10 import webtest
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 } 546 }
547 ] 547 ]
548 } 548 }
549 549
550 task = WfSwarmingTask.Create(master_name, builder_name, 3, 'b on platform') 550 task = WfSwarmingTask.Create(master_name, builder_name, 3, 'b on platform')
551 task.tests_statuses = { 551 task.tests_statuses = {
552 'Unittest3.Subtest1': { 552 'Unittest3.Subtest1': {
553 'total_run': 4, 553 'total_run': 4,
554 'SUCCESS': 2, 554 'SUCCESS': 2,
555 'FAILURE': 2 555 'FAILURE': 2
556 },
557 'Unittest3.Subtest2': {
558 'total_run': 4,
559 'SUCCESS': 2,
560 'FAILURE': 2
556 } 561 }
557 } 562 }
558 task.put() 563 task.put()
559 564
560 analysis = WfAnalysis.Create(master_name, builder_name, build_number) 565 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
561 analysis.status = analysis_status.COMPLETED 566 analysis.status = analysis_status.COMPLETED
562 analysis.failure_result_map = { 567 analysis.failure_result_map = {
563 'b on platform': { 568 'b on platform': {
564 'Unittest3.Subtest1': '/'.join([master_name, builder_name, '3']), 569 'Unittest3.Subtest1': '/'.join([master_name, builder_name, '3']),
570 'Unittest3.Subtest2': '/'.join([master_name, builder_name, '3']),
565 }, 571 },
566 } 572 }
567 analysis.result = { 573 analysis.result = {
568 'failures': [ 574 'failures': [
569 { 575 {
570 'step_name': 'b on platform', 576 'step_name': 'b on platform',
571 'first_failure': 3, 577 'first_failure': 3,
572 'last_pass': 2, 578 'last_pass': 2,
573 'suspected_cls': [], 579 'suspected_cls': [],
574 'tests': [ 580 'tests': [
575 { 581 {
576 'test_name': 'Unittest3.Subtest1', 582 'test_name': 'Unittest3.Subtest1',
577 'first_failure': 3, 583 'first_failure': 3,
578 'last_pass': 2, 584 'last_pass': 2,
579 'suspected_cls': [] 585 'suspected_cls': []
586 },
587 {
588 'test_name': 'Unittest3.Subtest2',
589 'first_failure': 3,
590 'last_pass': 2,
591 'suspected_cls': []
580 } 592 }
581 ] 593 ]
582 } 594 }
583 ] 595 ]
584 } 596 }
585 analysis.put() 597 analysis.put()
586 598
587 expected_results = [ 599 expected_results = [
588 { 600 {
589 'master_url': master_url, 601 'master_url': master_url,
590 'builder_name': builder_name, 602 'builder_name': builder_name,
591 'build_number': build_number, 603 'build_number': build_number,
592 'step_name': 'b on platform', 604 'step_name': 'b on platform',
593 'is_sub_test': True, 605 'is_sub_test': True,
594 'test_name': 'Unittest3.Subtest1', 606 'test_name': 'Unittest3.Subtest1',
595 'first_known_failed_build_number': 3, 607 'first_known_failed_build_number': 3,
596 'analysis_approach': 'HEURISTIC', 608 'analysis_approach': 'HEURISTIC',
597 'is_flaky_test': True, 609 'is_flaky_test': True,
598 'try_job_status': 'FINISHED' 610 'try_job_status': 'FINISHED'
611 },
612 {
613 'master_url': master_url,
614 'builder_name': builder_name,
615 'build_number': build_number,
616 'step_name': 'b on platform',
617 'is_sub_test': True,
618 'test_name': 'Unittest3.Subtest2',
619 'first_known_failed_build_number': 3,
620 'analysis_approach': 'HEURISTIC',
621 'is_flaky_test': True,
622 'try_job_status': 'FINISHED'
599 } 623 }
600 ] 624 ]
601 625
602 self._MockMasterIsSupported(supported=True) 626 self._MockMasterIsSupported(supported=True)
603 627
604 response = self.call_api('AnalyzeBuildFailures', body=builds) 628 response = self.call_api('AnalyzeBuildFailures', body=builds)
605 self.assertEqual(200, response.status_int) 629 self.assertEqual(200, response.status_int)
606 self.assertEqual(expected_results, response.json_body.get('results')) 630 self.assertEqual(expected_results, response.json_body.get('results'))
607 631
608 @mock.patch.object(suspected_cl_util, 'GetSuspectedCLConfidenceScore') 632 @mock.patch.object(suspected_cl_util, 'GetSuspectedCLConfidenceScore')
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 'master_name': 'm', 975 'master_name': 'm',
952 'builder_name': 'b', 976 'builder_name': 'b',
953 'build_number': 456, 977 'build_number': 456,
954 'step_name': 'name (with patch) on Windows-7-SP1', 978 'step_name': 'name (with patch) on Windows-7-SP1',
955 } 979 }
956 ] 980 ]
957 } 981 }
958 982
959 response = self.call_api('AnalyzeFlake', body=flake) 983 response = self.call_api('AnalyzeFlake', body=flake)
960 self.assertEqual(200, response.status_int) 984 self.assertEqual(200, response.status_int)
961 self.assertTrue(response.json_body.get('analysis_triggered')) 985 self.assertTrue(response.json_body.get('analysis_triggered'))
OLDNEW
« appengine/findit/findit_api.py ('K') | « appengine/findit/findit_api.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698