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

Unified Diff: appengine/findit/waterfall/test/wf_testcase.py

Issue 1836293002: [Findit] Adding central config test class for unit tests (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Addressing comments Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/waterfall/test/waterfall_config_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e5a2da51f62bd6894da87497b5979623d970a66b
--- /dev/null
+++ b/appengine/findit/waterfall/test/wf_testcase.py
@@ -0,0 +1,113 @@
+# 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
+
+import copy
+
+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
+}
+
+
+DEFAULT_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
+}
+
+
+class WaterfallTestCase(testing.AppengineTestCase): # pragma: no cover.
+
+ def UpdateUnitTestConfigSettings(self, config_property=None,
+ 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
+ """Sets up Findit's config for unit tests.
+
+ Args:
+ config_property: The name of the config property to update.
+ override_data: A dict to override any default settings.
+ """
+ config_data = DEFAULT_CONFIG_DATA
+
+ if config_property and override_data:
+ config_data = copy.deepcopy(DEFAULT_CONFIG_DATA)
+ config_data[config_property].update(override_data)
+
+ FinditConfig.Get().Update(users.User(email='admin@chromium.org'), True,
+ **config_data)
+
+ def setUp(self):
+ super(WaterfallTestCase, self).setUp()
+ self.UpdateUnitTestConfigSettings()
+
+
« no previous file with comments | « appengine/findit/waterfall/test/waterfall_config_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698