Index: appengine/findit/waterfall/test/wf_testcase.py |
diff --git a/appengine/findit/waterfall/test/wf_testcase.py b/appengine/findit/waterfall/test/wf_testcase.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..974a6649b0dcdac949e25eb2011271b630311292 |
--- /dev/null |
+++ b/appengine/findit/waterfall/test/wf_testcase.py |
@@ -0,0 +1,108 @@ |
+# Copyright 2016 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+from google.appengine.api import users |
+from testing_utils import testing |
+ |
+from model.wf_config import FinditConfig |
+ |
+ |
+_DEFAULT_STEPS_FOR_MASTERS_RULES = { |
+ 'supported_masters': { |
+ 'm': { |
+ 'check_global': True |
+ }, |
+ 'm3': { |
+ 'check_global': True |
+ }, |
+ 'master1': { |
+ # supported_steps override global. |
+ 'supported_steps': ['unsupported_step6'], |
+ 'unsupported_steps': ['unsupported_step1', |
+ 'unsupported_step2', |
+ 'unsupported_step3'], |
+ 'check_global': True |
+ }, |
+ 'master2': { |
+ # Only supports step4 and step5 regardless of global. |
+ 'supported_steps': ['step4', 'step5'], |
+ 'check_global': False |
+ }, |
+ 'master3': { |
+ # Supports everything not blacklisted in global. |
+ 'check_global': True |
+ }, |
+ }, |
+ 'global': { |
+ # Blacklists all listed steps for all masters unless overridden. |
+ 'unsupported_steps': ['unsupported_step6', 'unsupported_step7'], |
+ } |
+} |
+ |
+ |
+_DEFAULT_TRY_BOT_MAPPING = { |
+ 'master1': { |
+ 'builder1': { |
+ 'mastername': 'tryserver1', |
+ 'buildername': 'trybot1', |
+ 'strict_regex': True, |
+ } |
+ }, |
+ 'm': { |
+ 'b': { |
+ 'mastername': 'tryserver.master', |
+ 'buildername': 'tryserver.builder', |
+ } |
+ } |
+} |
+ |
+ |
+_DEFAULT_TRY_JOB_SETTINGS = { |
+ 'server_query_interval_seconds': 60, |
+ 'job_timeout_hours': 5, |
+ 'allowed_response_error_times': 5 |
+} |
+ |
+ |
+_DEFAULT_SWARMING_SETTINGS = { |
+ 'server_host': 'chromium-swarm.appspot.com', |
+ 'default_request_priority': 150, |
+ 'request_expiration_hours': 20, |
+ 'server_query_interval_seconds': 60, |
+ 'task_timeout_hours': 23, |
+ 'isolated_server': 'https://isolateserver.appspot.com', |
+ 'isolated_storage_url': 'isolateserver.storage.googleapis.com', |
+ 'iterations_to_rerun': 10 |
+} |
+ |
+ |
+class WaterfallTestCase(testing.AppengineTestCase): # pragma: no cover. |
+ |
+ CONFIG_DATA = { |
+ 'steps_for_masters_rules': _DEFAULT_STEPS_FOR_MASTERS_RULES, |
+ 'builders_to_trybots': _DEFAULT_TRY_BOT_MAPPING, |
+ 'try_job_settings': _DEFAULT_TRY_JOB_SETTINGS, |
+ 'swarming_settings': _DEFAULT_SWARMING_SETTINGS |
+ } |
+ |
+ def UpdateUnitTestConfigSettings(self): |
+ """Sets up Findit's config for unit tests.""" |
+ FinditConfig.Get().Update(user=users.User(email='admin@chromium.org'), |
+ is_admin=True, **self.CONFIG_DATA) |
+ |
+ def setUp(self): |
+ super(WaterfallTestCase, self).setUp() |
+ self.UpdateUnitTestConfigSettings() |
+ |
+ def OverrideConfigSettings(self, setting_name, new_values): |
+ """Overrides a settings dict for testing. |
+ |
+ Args: |
+ setting_name: The name of the setting to override, such as |
+ 'swarming_settings' or 'steps_for_masters_rules'. |
+ new_values: A dict containing the new values for setting_name. |
+ """ |
+ 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.
|
+ self.UpdateUnitTestConfigSettings() |
+ |