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 import copy | |
| 9 | |
| 10 from model.wf_config import FinditConfig | |
| 11 | |
| 12 | |
| 13 _DEFAULT_STEPS_FOR_MASTERS_RULES = { | |
| 14 'supported_masters': { | |
| 15 'm': { | |
| 16 'check_global': True | |
| 17 }, | |
| 18 'm3': { | |
| 19 'check_global': True | |
| 20 }, | |
| 21 'master1': { | |
| 22 # supported_steps override global. | |
| 23 'supported_steps': ['unsupported_step6'], | |
| 24 'unsupported_steps': ['unsupported_step1', | |
| 25 'unsupported_step2', | |
| 26 'unsupported_step3'], | |
| 27 'check_global': True | |
| 28 }, | |
| 29 'master2': { | |
| 30 # Only supports step4 and step5 regardless of global. | |
| 31 'supported_steps': ['step4', 'step5'], | |
| 32 'check_global': False | |
| 33 }, | |
| 34 'master3': { | |
| 35 # Supports everything not blacklisted in global. | |
| 36 'check_global': True | |
| 37 }, | |
| 38 }, | |
| 39 'global': { | |
| 40 # Blacklists all listed steps for all masters unless overridden. | |
| 41 'unsupported_steps': ['unsupported_step6', 'unsupported_step7'], | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 | |
| 46 _DEFAULT_TRY_BOT_MAPPING = { | |
| 47 'master1': { | |
| 48 'builder1': { | |
| 49 'mastername': 'tryserver1', | |
| 50 'buildername': 'trybot1', | |
| 51 'strict_regex': True, | |
| 52 } | |
| 53 }, | |
| 54 'm': { | |
| 55 'b': { | |
| 56 'mastername': 'tryserver.master', | |
| 57 'buildername': 'tryserver.builder', | |
| 58 } | |
| 59 } | |
| 60 } | |
| 61 | |
| 62 | |
| 63 _DEFAULT_TRY_JOB_SETTINGS = { | |
| 64 'server_query_interval_seconds': 60, | |
| 65 'job_timeout_hours': 5, | |
| 66 'allowed_response_error_times': 5 | |
| 67 } | |
| 68 | |
| 69 | |
| 70 _DEFAULT_SWARMING_SETTINGS = { | |
| 71 'server_host': 'chromium-swarm.appspot.com', | |
| 72 'default_request_priority': 150, | |
| 73 'request_expiration_hours': 20, | |
| 74 'server_query_interval_seconds': 60, | |
| 75 'task_timeout_hours': 23, | |
| 76 'isolated_server': 'https://isolateserver.appspot.com', | |
| 77 'isolated_storage_url': 'isolateserver.storage.googleapis.com', | |
| 78 'iterations_to_rerun': 10 | |
| 79 } | |
| 80 | |
| 81 | |
| 82 DEFAULT_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 | |
| 90 class WaterfallTestCase(testing.AppengineTestCase): # pragma: no cover. | |
| 91 | |
| 92 def UpdateUnitTestConfigSettings(self, config_property=None, | |
| 93 override_data=None): | |
|
stgao
2016/04/05 00:13:47
How about just one parameter ``override_config_dat
lijeffrey
2016/04/05 00:57:19
It seems if config_data is more than 1 layer deep
stgao
2016/04/05 01:15:29
ok. We could keep the current implemented approach
| |
| 94 """Sets up Findit's config for unit tests. | |
| 95 | |
| 96 Args: | |
| 97 config_property: The name of the config property to update. | |
| 98 override_data: A dict to override any default settings. | |
| 99 """ | |
| 100 config_data = DEFAULT_CONFIG_DATA | |
| 101 | |
| 102 if config_property and override_data: | |
| 103 config_data = copy.deepcopy(DEFAULT_CONFIG_DATA) | |
| 104 config_data[config_property].update(override_data) | |
| 105 | |
| 106 FinditConfig.Get().Update(users.User(email='admin@chromium.org'), True, | |
| 107 **config_data) | |
| 108 | |
| 109 def setUp(self): | |
| 110 super(WaterfallTestCase, self).setUp() | |
| 111 self.UpdateUnitTestConfigSettings() | |
| 112 | |
| 113 | |
| OLD | NEW |