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

Side by Side Diff: appengine/findit/handlers/test/config_test.py

Issue 2104113002: [Findit] Add settings for actions after culprits or suspects are identified. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@group_same_failures
Patch Set: Address chan's comments. Created 4 years, 5 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
« no previous file with comments | « appengine/findit/handlers/config.py ('k') | appengine/findit/model/wf_config.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 datetime 5 import datetime
6 import json 6 import json
7 import re 7 import re
8 import webapp2 8 import webapp2
9 import webtest 9 import webtest
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 'iterations_to_rerun': 10 68 'iterations_to_rerun': 10
69 } 69 }
70 70
71 71
72 _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS = { 72 _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS = {
73 'download_interval_seconds': 10, 73 'download_interval_seconds': 10,
74 'memcache_master_download_expiration_seconds': 3600, 74 'memcache_master_download_expiration_seconds': 3600,
75 'use_chrome_build_extract': True 75 'use_chrome_build_extract': True
76 } 76 }
77 77
78 _MOCK_ACTION_SETTINGS = {
79 'cr_notification_build_threshold': 2,
80 'cr_notification_latency_limit_minutes': 1000,
81 }
82
78 _MOCK_VERSION_NUMBER = 12 83 _MOCK_VERSION_NUMBER = 12
79 84
80 85
81 class ConfigTest(testing.AppengineTestCase): 86 class ConfigTest(testing.AppengineTestCase):
82 app_module = webapp2.WSGIApplication([ 87 app_module = webapp2.WSGIApplication([
83 ('/config', config.Configuration), 88 ('/config', config.Configuration),
84 ], debug=True) 89 ], debug=True)
85 90
86 def testGetConfigurationSettings(self): 91 def testGetConfigurationSettings(self):
87 config_data = { 92 config_data = {
88 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES, 93 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES,
89 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS, 94 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS,
90 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 95 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
91 'swarming_settings': _MOCK_SWARMING_SETTINGS, 96 'swarming_settings': _MOCK_SWARMING_SETTINGS,
92 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS 97 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
98 'action_settings': _MOCK_ACTION_SETTINGS,
93 } 99 }
94 100
95 self.mock_current_user(user_email='test@chromium.org', is_admin=True) 101 self.mock_current_user(user_email='test@chromium.org', is_admin=True)
96 102
97 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True, 103 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True,
98 **config_data) 104 **config_data)
99 105
100 response = self.test_app.get('/config', params={'format': 'json'}) 106 response = self.test_app.get('/config', params={'format': 'json'})
101 self.assertEquals(response.status_int, 200) 107 self.assertEquals(response.status_int, 200)
102 108
103 expected_response = { 109 expected_response = {
104 'masters': _MOCK_STEPS_FOR_MASTERS_RULES, 110 'masters': _MOCK_STEPS_FOR_MASTERS_RULES,
105 'builders': _MOCK_BUILDERS_TO_TRYBOTS, 111 'builders': _MOCK_BUILDERS_TO_TRYBOTS,
106 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 112 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
107 'swarming_settings': _MOCK_SWARMING_SETTINGS, 113 'swarming_settings': _MOCK_SWARMING_SETTINGS,
108 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 114 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
115 'action_settings': _MOCK_ACTION_SETTINGS,
109 'version': 1, 116 'version': 1,
110 'latest_version': 1, 117 'latest_version': 1,
111 'updated_by': 'test', 118 'updated_by': 'test',
112 'updated_ts': response.json_body.get('updated_ts') 119 'updated_ts': response.json_body.get('updated_ts')
113 } 120 }
114 121
115 self.assertEquals(expected_response, response.json_body) 122 self.assertEquals(expected_response, response.json_body)
116 123
117 def testGetVersionOfConfigurationSettings(self): 124 def testGetVersionOfConfigurationSettings(self):
118 self.mock_current_user(user_email='test@chromium.org', is_admin=True) 125 self.mock_current_user(user_email='test@chromium.org', is_admin=True)
119 126
120 config_data = { 127 config_data = {
121 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES, 128 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES,
122 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS, 129 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS,
123 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 130 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
124 'swarming_settings': _MOCK_SWARMING_SETTINGS, 131 'swarming_settings': _MOCK_SWARMING_SETTINGS,
125 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS 132 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
133 'action_settings': _MOCK_ACTION_SETTINGS,
126 } 134 }
127 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True, 135 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True,
128 **config_data) 136 **config_data)
129 137
130 response = self.test_app.get( 138 response = self.test_app.get(
131 '/config', params={'version': 1, 'format': 'json'}) 139 '/config', params={'version': 1, 'format': 'json'})
132 self.assertEquals(response.status_int, 200) 140 self.assertEquals(response.status_int, 200)
133 141
134 expected_response = { 142 expected_response = {
135 'masters': _MOCK_STEPS_FOR_MASTERS_RULES, 143 'masters': _MOCK_STEPS_FOR_MASTERS_RULES,
136 'builders': _MOCK_BUILDERS_TO_TRYBOTS, 144 'builders': _MOCK_BUILDERS_TO_TRYBOTS,
137 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 145 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
138 'swarming_settings': _MOCK_SWARMING_SETTINGS, 146 'swarming_settings': _MOCK_SWARMING_SETTINGS,
139 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 147 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
148 'action_settings': _MOCK_ACTION_SETTINGS,
140 'version': 1, 149 'version': 1,
141 'latest_version': 1, 150 'latest_version': 1,
142 'updated_by': 'test', 151 'updated_by': 'test',
143 'updated_ts': response.json_body.get('updated_ts') 152 'updated_ts': response.json_body.get('updated_ts')
144 } 153 }
145 154
146 self.assertEquals(expected_response, response.json_body) 155 self.assertEquals(expected_response, response.json_body)
147 156
148 def testGetOutOfBoundsVersionOfConfigurationSettings(self): 157 def testGetOutOfBoundsVersionOfConfigurationSettings(self):
149 config_data = { 158 config_data = {
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 'check_global': False 645 'check_global': False
637 } 646 }
638 }, 647 },
639 'global': { 648 'global': {
640 'unsupported_steps': ['1'] 649 'unsupported_steps': ['1']
641 } 650 }
642 }, 651 },
643 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS, 652 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS,
644 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 653 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
645 'swarming_settings': _MOCK_SWARMING_SETTINGS, 654 'swarming_settings': _MOCK_SWARMING_SETTINGS,
646 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS 655 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
656 'action_settings': _MOCK_ACTION_SETTINGS,
647 }) 657 })
648 } 658 }
649 659
650 response = self.test_app.post('/config', params=params) 660 response = self.test_app.post('/config', params=params)
651 661
652 expected_response = { 662 expected_response = {
653 'masters': { 663 'masters': {
654 'supported_masters': { 664 'supported_masters': {
655 'a': { 665 'a': {
656 }, 666 },
657 'b': { 667 'b': {
658 'supported_steps': ['1'], 668 'supported_steps': ['1'],
659 'unsupported_steps': ['2', '3', '4'], 669 'unsupported_steps': ['2', '3', '4'],
660 }, 670 },
661 'c': { 671 'c': {
662 'supported_steps': ['5'], 672 'supported_steps': ['5'],
663 'check_global': False 673 'check_global': False
664 } 674 }
665 }, 675 },
666 'global': { 676 'global': {
667 'unsupported_steps': ['1'] 677 'unsupported_steps': ['1']
668 } 678 }
669 }, 679 },
670 'builders': _MOCK_BUILDERS_TO_TRYBOTS, 680 'builders': _MOCK_BUILDERS_TO_TRYBOTS,
671 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 681 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
672 'swarming_settings': _MOCK_SWARMING_SETTINGS, 682 'swarming_settings': _MOCK_SWARMING_SETTINGS,
673 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 683 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
684 'action_settings': _MOCK_ACTION_SETTINGS,
674 'version': 1, 685 'version': 1,
675 'latest_version': 1, 686 'latest_version': 1,
676 'updated_by': 'test', 687 'updated_by': 'test',
677 'updated_ts': response.json_body.get('updated_ts') 688 'updated_ts': response.json_body.get('updated_ts')
678 } 689 }
679 690
680 self.assertEquals(expected_response, response.json_body) 691 self.assertEquals(expected_response, response.json_body)
692
693 def testValidateActionSettings(self):
694 self.assertFalse(config._ValidateActionSettings({}))
695 self.assertTrue(config._ValidateActionSettings(
696 {
697 'cr_notification_build_threshold': 2,
698 'cr_notification_latency_limit_minutes': 1000,
699 }))
OLDNEW
« no previous file with comments | « appengine/findit/handlers/config.py ('k') | appengine/findit/model/wf_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698