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

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

Issue 2272953002: [Findit] Moving check flake parameters to config (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fixing naming in html file Created 4 years, 4 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 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 'download_interval_seconds': 10, 74 'download_interval_seconds': 10,
75 'memcache_master_download_expiration_seconds': 3600, 75 'memcache_master_download_expiration_seconds': 3600,
76 'use_chrome_build_extract': True 76 'use_chrome_build_extract': True
77 } 77 }
78 78
79 _MOCK_ACTION_SETTINGS = { 79 _MOCK_ACTION_SETTINGS = {
80 'cr_notification_build_threshold': 2, 80 'cr_notification_build_threshold': 2,
81 'cr_notification_latency_limit_minutes': 1000, 81 'cr_notification_latency_limit_minutes': 1000,
82 } 82 }
83 83
84 _MOCK_CHECK_FLAKE_SETTINGS = {
85 'lower_flake_threshold': 0.02,
86 'upper_flake_threshold': 0.98,
87 'max_flake_in_a_row': 4,
88 'max_stable_in_a_row': 4
89 }
90
84 _MOCK_VERSION_NUMBER = 12 91 _MOCK_VERSION_NUMBER = 12
85 92
86 93
87 class ConfigTest(testing.AppengineTestCase): 94 class ConfigTest(testing.AppengineTestCase):
88 app_module = webapp2.WSGIApplication([ 95 app_module = webapp2.WSGIApplication([
89 ('/config', config.Configuration), 96 ('/config', config.Configuration),
90 ], debug=True) 97 ], debug=True)
91 98
92 def testGetConfigurationSettings(self): 99 def testGetConfigurationSettings(self):
93 config_data = { 100 config_data = {
94 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES, 101 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES,
95 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS, 102 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS,
96 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 103 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
97 'swarming_settings': _MOCK_SWARMING_SETTINGS, 104 'swarming_settings': _MOCK_SWARMING_SETTINGS,
98 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 105 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
99 'action_settings': _MOCK_ACTION_SETTINGS, 106 'action_settings': _MOCK_ACTION_SETTINGS,
107 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS
100 } 108 }
101 109
102 self.mock_current_user(user_email='test@chromium.org', is_admin=True) 110 self.mock_current_user(user_email='test@chromium.org', is_admin=True)
103 111
104 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True, 112 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True,
105 **config_data) 113 **config_data)
106 114
107 response = self.test_app.get('/config', params={'format': 'json'}) 115 response = self.test_app.get('/config', params={'format': 'json'})
108 self.assertEquals(response.status_int, 200) 116 self.assertEquals(response.status_int, 200)
109 117
110 expected_response = { 118 expected_response = {
111 'masters': _MOCK_STEPS_FOR_MASTERS_RULES, 119 'masters': _MOCK_STEPS_FOR_MASTERS_RULES,
112 'builders': _MOCK_BUILDERS_TO_TRYBOTS, 120 'builders': _MOCK_BUILDERS_TO_TRYBOTS,
113 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 121 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
114 'swarming_settings': _MOCK_SWARMING_SETTINGS, 122 'swarming_settings': _MOCK_SWARMING_SETTINGS,
115 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 123 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
116 'action_settings': _MOCK_ACTION_SETTINGS, 124 'action_settings': _MOCK_ACTION_SETTINGS,
125 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS,
117 'version': 1, 126 'version': 1,
118 'latest_version': 1, 127 'latest_version': 1,
119 'updated_by': 'test', 128 'updated_by': 'test',
120 'updated_ts': response.json_body.get('updated_ts') 129 'updated_ts': response.json_body.get('updated_ts')
121 } 130 }
122 131
123 self.assertEquals(expected_response, response.json_body) 132 self.assertEquals(expected_response, response.json_body)
124 133
125 def testGetVersionOfConfigurationSettings(self): 134 def testGetVersionOfConfigurationSettings(self):
126 self.mock_current_user(user_email='test@chromium.org', is_admin=True) 135 self.mock_current_user(user_email='test@chromium.org', is_admin=True)
127 136
128 config_data = { 137 config_data = {
129 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES, 138 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES,
130 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS, 139 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS,
131 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 140 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
132 'swarming_settings': _MOCK_SWARMING_SETTINGS, 141 'swarming_settings': _MOCK_SWARMING_SETTINGS,
133 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 142 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
134 'action_settings': _MOCK_ACTION_SETTINGS, 143 'action_settings': _MOCK_ACTION_SETTINGS,
144 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS
135 } 145 }
136 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True, 146 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True,
137 **config_data) 147 **config_data)
138 148
139 response = self.test_app.get( 149 response = self.test_app.get(
140 '/config', params={'version': 1, 'format': 'json'}) 150 '/config', params={'version': 1, 'format': 'json'})
141 self.assertEquals(response.status_int, 200) 151 self.assertEquals(response.status_int, 200)
142 152
143 expected_response = { 153 expected_response = {
144 'masters': _MOCK_STEPS_FOR_MASTERS_RULES, 154 'masters': _MOCK_STEPS_FOR_MASTERS_RULES,
145 'builders': _MOCK_BUILDERS_TO_TRYBOTS, 155 'builders': _MOCK_BUILDERS_TO_TRYBOTS,
146 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 156 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
147 'swarming_settings': _MOCK_SWARMING_SETTINGS, 157 'swarming_settings': _MOCK_SWARMING_SETTINGS,
148 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 158 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
149 'action_settings': _MOCK_ACTION_SETTINGS, 159 'action_settings': _MOCK_ACTION_SETTINGS,
160 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS,
150 'version': 1, 161 'version': 1,
151 'latest_version': 1, 162 'latest_version': 1,
152 'updated_by': 'test', 163 'updated_by': 'test',
153 'updated_ts': response.json_body.get('updated_ts') 164 'updated_ts': response.json_body.get('updated_ts')
154 } 165 }
155 166
156 self.assertEquals(expected_response, response.json_body) 167 self.assertEquals(expected_response, response.json_body)
157 168
158 def testGetOutOfBoundsVersionOfConfigurationSettings(self): 169 def testGetOutOfBoundsVersionOfConfigurationSettings(self):
159 config_data = { 170 config_data = {
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 }, 663 },
653 'global': { 664 'global': {
654 'unsupported_steps': ['1'] 665 'unsupported_steps': ['1']
655 } 666 }
656 }, 667 },
657 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS, 668 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS,
658 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 669 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
659 'swarming_settings': _MOCK_SWARMING_SETTINGS, 670 'swarming_settings': _MOCK_SWARMING_SETTINGS,
660 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 671 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
661 'action_settings': _MOCK_ACTION_SETTINGS, 672 'action_settings': _MOCK_ACTION_SETTINGS,
673 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS
662 }) 674 })
663 } 675 }
664 676
665 response = self.test_app.post('/config', params=params) 677 response = self.test_app.post('/config', params=params)
666 678
667 expected_response = { 679 expected_response = {
668 'masters': { 680 'masters': {
669 'supported_masters': { 681 'supported_masters': {
670 'a': { 682 'a': {
671 }, 683 },
672 'b': { 684 'b': {
673 'supported_steps': ['1'], 685 'supported_steps': ['1'],
674 'unsupported_steps': ['2', '3', '4'], 686 'unsupported_steps': ['2', '3', '4'],
675 }, 687 },
676 'c': { 688 'c': {
677 'supported_steps': ['5'], 689 'supported_steps': ['5'],
678 'check_global': False 690 'check_global': False
679 } 691 }
680 }, 692 },
681 'global': { 693 'global': {
682 'unsupported_steps': ['1'] 694 'unsupported_steps': ['1']
683 } 695 }
684 }, 696 },
685 'builders': _MOCK_BUILDERS_TO_TRYBOTS, 697 'builders': _MOCK_BUILDERS_TO_TRYBOTS,
686 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 698 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
687 'swarming_settings': _MOCK_SWARMING_SETTINGS, 699 'swarming_settings': _MOCK_SWARMING_SETTINGS,
688 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 700 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
689 'action_settings': _MOCK_ACTION_SETTINGS, 701 'action_settings': _MOCK_ACTION_SETTINGS,
702 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS,
690 'version': 1, 703 'version': 1,
691 'latest_version': 1, 704 'latest_version': 1,
692 'updated_by': 'test', 705 'updated_by': 'test',
693 'updated_ts': response.json_body.get('updated_ts') 706 'updated_ts': response.json_body.get('updated_ts')
694 } 707 }
695 708
696 self.assertEquals(expected_response, response.json_body) 709 self.assertEquals(expected_response, response.json_body)
697 710
698 def testValidateActionSettings(self): 711 def testValidateActionSettings(self):
699 self.assertFalse(config._ValidateActionSettings({})) 712 self.assertFalse(config._ValidateActionSettings({}))
700 self.assertTrue(config._ValidateActionSettings( 713 self.assertTrue(config._ValidateActionSettings(
701 { 714 {
702 'cr_notification_build_threshold': 2, 715 'cr_notification_build_threshold': 2,
703 'cr_notification_latency_limit_minutes': 1000, 716 'cr_notification_latency_limit_minutes': 1000,
704 })) 717 }))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698