Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from google.appengine.api import users | |
| 6 from testing_utils import testing | |
| 7 | |
| 8 from model.wf_config import FinditConfig | |
| 9 | |
| 10 | |
| 11 _DEFAULT_STEPS_FOR_MASTERS_RULES = { | |
| 12 'supported_masters': { | |
| 13 'm': { | |
| 14 'check_global': True | |
| 15 }, | |
| 16 'm3': { | |
| 17 'check_global': True | |
| 18 }, | |
| 19 'master1': { | |
| 20 # supported_steps override global. | |
| 21 'supported_steps': ['unsupported_step6'], | |
| 22 'unsupported_steps': ['unsupported_step1', | |
| 23 'unsupported_step2', | |
| 24 'unsupported_step3'], | |
| 25 'check_global': True | |
| 26 }, | |
| 27 'master2': { | |
| 28 # Only supports step4 and step5 regardless of global. | |
| 29 'supported_steps': ['step4', 'step5'], | |
| 30 'check_global': False | |
| 31 }, | |
| 32 'master3': { | |
| 33 # Supports everything not blacklisted in global. | |
| 34 'check_global': True | |
| 35 }, | |
| 36 }, | |
| 37 'global': { | |
| 38 # Blacklists all listed steps for all masters unless overridden. | |
| 39 'unsupported_steps': ['unsupported_step6', 'unsupported_step7'], | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 | |
| 44 _DEFAULT_TRY_BOT_MAPPING = { | |
| 45 'master1': { | |
| 46 'builder1': { | |
| 47 'mastername': 'tryserver1', | |
| 48 'buildername': 'trybot1', | |
| 49 'strict_regex': True, | |
| 50 } | |
| 51 }, | |
| 52 'm': { | |
| 53 'b': { | |
| 54 'mastername': 'tryserver.master', | |
| 55 'buildername': 'tryserver.builder', | |
| 56 } | |
| 57 } | |
| 58 } | |
| 59 | |
| 60 | |
| 61 _DEFAULT_TRY_JOB_SETTINGS = { | |
| 62 'server_query_interval_seconds': 60, | |
| 63 'job_timeout_hours': 5, | |
| 64 'allowed_response_error_times': 5 | |
| 65 } | |
| 66 | |
| 67 | |
| 68 _DEFAULT_SWARMING_SETTINGS = { | |
| 69 'server_host': 'chromium-swarm.appspot.com', | |
| 70 'default_request_priority': 150, | |
| 71 'request_expiration_hours': 20, | |
| 72 'server_query_interval_seconds': 60, | |
| 73 'task_timeout_hours': 23, | |
| 74 'isolated_server': 'https://isolateserver.appspot.com', | |
| 75 'isolated_storage_url': 'isolateserver.storage.googleapis.com', | |
| 76 'iterations_to_rerun': 10 | |
| 77 } | |
| 78 | |
| 79 | |
| 80 class WaterfallTestCase(testing.AppengineTestCase): # pragma: no cover. | |
| 81 | |
| 82 CONFIG_DATA = { | |
| 83 'steps_for_masters_rules': _DEFAULT_STEPS_FOR_MASTERS_RULES, | |
| 84 'builders_to_trybots': _DEFAULT_TRY_BOT_MAPPING, | |
| 85 'try_job_settings': _DEFAULT_TRY_JOB_SETTINGS, | |
| 86 'swarming_settings': _DEFAULT_SWARMING_SETTINGS | |
| 87 } | |
| 88 | |
| 89 def UpdateUnitTestConfigSettings(self): | |
| 90 """Sets up Findit's config for unit tests.""" | |
| 91 FinditConfig.Get().Update(user=users.User(email='admin@chromium.org'), | |
| 92 is_admin=True, **self.CONFIG_DATA) | |
| 93 | |
| 94 def setUp(self): | |
| 95 super(WaterfallTestCase, self).setUp() | |
| 96 self.UpdateUnitTestConfigSettings() | |
| 97 | |
| 98 def OverrideConfigSettings(self, setting_name, new_values): | |
| 99 """Overrides a settings dict for testing. | |
| 100 | |
| 101 Args: | |
| 102 setting_name: The name of the setting to override, such as | |
| 103 'swarming_settings' or 'steps_for_masters_rules'. | |
| 104 new_values: A dict containing the new values for setting_name. | |
| 105 """ | |
| 106 self.CONFIG_DATA[setting_name] = new_values | |
|
stgao
2016/04/01 23:35:48
There is a bug. We should not modify shared data f
lijeffrey
2016/04/04 21:35:05
Done.
| |
| 107 self.UpdateUnitTestConfigSettings() | |
| 108 | |
| OLD | NEW |