OLD | NEW |
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 from testing_utils import testing | |
6 | |
7 from model.wf_config import FinditConfig | |
8 from waterfall import waterfall_config | 5 from waterfall import waterfall_config |
| 6 from waterfall.test import wf_testcase |
9 | 7 |
10 | 8 |
11 class MastersTest(testing.AppengineTestCase): | 9 class MastersTest(wf_testcase.WaterfallTestCase): |
12 | |
13 def setUp(self): | |
14 super(MastersTest, self).setUp() | |
15 self.mock_current_user(user_email='test@chromium.org', is_admin=True) | |
16 | |
17 config_data = { | |
18 'steps_for_masters_rules': { | |
19 'supported_masters': { | |
20 'master1': { | |
21 # supported_steps override global. | |
22 'supported_steps': ['step6'], | |
23 'unsupported_steps': ['step1', 'step2', 'step3'], | |
24 }, | |
25 'master2': { | |
26 # Only supports step4 and step5 regardless of global. | |
27 'supported_steps': ['step4', 'step5'], | |
28 'check_global': False | |
29 }, | |
30 'master3': { | |
31 # Supports everything not blacklisted in global. | |
32 }, | |
33 }, | |
34 'global': { | |
35 # Blacklists all listed steps for all masters unless overridden. | |
36 'unsupported_steps': ['step6', 'step7'], | |
37 } | |
38 }, | |
39 'builders_to_trybots': { | |
40 'master1': { | |
41 'builder1': { | |
42 'mastername': 'tryserver1', | |
43 'buildername': 'trybot1', | |
44 'strict_regex': True, | |
45 } | |
46 } | |
47 }, | |
48 'try_job_settings': { | |
49 'server_query_interval_seconds': 60, | |
50 'job_timeout_hours': 5, | |
51 'allowed_response_error_times': 1 | |
52 }, | |
53 'swarming_settings': { | |
54 'server_host': 'chromium-swarm.appspot.com', | |
55 'default_request_priority': 150, | |
56 'request_expiration_hours': 20, | |
57 'server_query_interval_seconds': 60, | |
58 'task_timeout_hours': 23, | |
59 'isolated_server': 'https://isolateserver.appspot.com', | |
60 'isolated_storage_url': 'isolateserver.storage.googleapis.com', | |
61 'iterations_to_rerun': 10 | |
62 } | |
63 } | |
64 | |
65 FinditConfig.Get().Update(**config_data) | |
66 | 10 |
67 def testConvertOldMastersFormatToNew(self): | 11 def testConvertOldMastersFormatToNew(self): |
68 self.assertEqual( | 12 self.assertEqual( |
69 { | 13 { |
70 'supported_masters': { | 14 'supported_masters': { |
71 'master1': { | 15 'master1': { |
72 'unsupported_steps': ['1', '2'] | 16 'unsupported_steps': ['1', '2'] |
73 }, | 17 }, |
74 'master2': {} | 18 'master2': {} |
75 }, | 19 }, |
76 'global': {} | 20 'global': {} |
77 }, | 21 }, |
78 waterfall_config._ConvertOldMastersFormatToNew( | 22 waterfall_config._ConvertOldMastersFormatToNew( |
79 { | 23 { |
80 'master1': ['1', '2'], | 24 'master1': ['1', '2'], |
81 'master2': {} | 25 'master2': {} |
82 | |
83 })) | 26 })) |
84 | 27 |
85 def testGetStepsForMastersRulesWithSettingsProvided(self): | 28 def testGetStepsForMastersRulesWithSettingsProvided(self): |
86 class MockSettings(): | 29 class MockSettings(): |
87 steps_for_masters_rules = {'blabla': 'blabla'} | 30 steps_for_masters_rules = {'blabla': 'blabla'} |
88 | 31 |
89 self.assertEqual(waterfall_config.GetStepsForMastersRules(MockSettings()), | 32 self.assertEqual(waterfall_config.GetStepsForMastersRules(MockSettings()), |
90 MockSettings().steps_for_masters_rules) | 33 MockSettings().steps_for_masters_rules) |
91 | 34 |
92 def testMasterIsSupported(self): | 35 def testMasterIsSupported(self): |
93 self.assertTrue(waterfall_config.MasterIsSupported('master1')) | 36 self.assertTrue(waterfall_config.MasterIsSupported('master1')) |
94 self.assertFalse(waterfall_config.MasterIsSupported('blabla')) | 37 self.assertFalse(waterfall_config.MasterIsSupported('blabla')) |
95 | 38 |
96 def testStepIsSupportedForMaster(self): | 39 def testStepIsSupportedForMaster(self): |
97 self.assertFalse( | 40 self.assertFalse( |
98 waterfall_config.StepIsSupportedForMaster('step1', 'master1')) | 41 waterfall_config.StepIsSupportedForMaster('unsupported_step1', |
| 42 'master1')) |
99 self.assertTrue( | 43 self.assertTrue( |
100 waterfall_config.StepIsSupportedForMaster('step4', 'master1')) | 44 waterfall_config.StepIsSupportedForMaster('step4', 'master1')) |
101 self.assertTrue( | 45 self.assertTrue( |
102 waterfall_config.StepIsSupportedForMaster('step4', 'master2')) | 46 waterfall_config.StepIsSupportedForMaster('step4', 'master2')) |
103 self.assertFalse( | 47 self.assertFalse( |
104 waterfall_config.StepIsSupportedForMaster('blabla', 'blabla')) | 48 waterfall_config.StepIsSupportedForMaster('blabla', 'blabla')) |
105 self.assertTrue( | 49 self.assertTrue( |
106 waterfall_config.StepIsSupportedForMaster('step4', 'master2')) | 50 waterfall_config.StepIsSupportedForMaster('step4', 'master2')) |
107 self.assertTrue( | 51 self.assertTrue( |
108 waterfall_config.StepIsSupportedForMaster('blabla', 'master3')) | 52 waterfall_config.StepIsSupportedForMaster('blabla', 'master3')) |
109 self.assertTrue( | 53 self.assertTrue( |
110 waterfall_config.StepIsSupportedForMaster('step5', 'master1')) | 54 waterfall_config.StepIsSupportedForMaster('step5', 'master1')) |
111 self.assertTrue( | 55 self.assertTrue( |
112 waterfall_config.StepIsSupportedForMaster('step5', 'master2')) | 56 waterfall_config.StepIsSupportedForMaster('step5', 'master2')) |
113 self.assertFalse( | 57 self.assertFalse( |
114 waterfall_config.StepIsSupportedForMaster('step7', 'master2')) | 58 waterfall_config.StepIsSupportedForMaster('unsupported_step7', |
| 59 'master2')) |
115 self.assertTrue( | 60 self.assertTrue( |
116 waterfall_config.StepIsSupportedForMaster('step6', 'master1')) | 61 waterfall_config.StepIsSupportedForMaster('unsupported_step6', |
| 62 'master1')) |
117 self.assertFalse( | 63 self.assertFalse( |
118 waterfall_config.StepIsSupportedForMaster('step6', 'master2')) | 64 waterfall_config.StepIsSupportedForMaster('unsupported_step6', |
| 65 'master2')) |
119 self.assertFalse( | 66 self.assertFalse( |
120 waterfall_config.StepIsSupportedForMaster('step6', 'master3')) | 67 waterfall_config.StepIsSupportedForMaster('unsupported_step6', |
| 68 'master3')) |
121 self.assertFalse( | 69 self.assertFalse( |
122 waterfall_config.StepIsSupportedForMaster('step7', 'master3')) | 70 waterfall_config.StepIsSupportedForMaster('unsupported_step7', |
| 71 'master3')) |
123 | 72 |
124 def testGetTrybotForWaterfallBuilder(self): | 73 def testGetTrybotForWaterfallBuilder(self): |
125 self.assertEqual( | 74 self.assertEqual( |
126 ('tryserver1', 'trybot1'), | 75 ('tryserver1', 'trybot1'), |
127 waterfall_config.GetTrybotForWaterfallBuilder('master1', 'builder1')) | 76 waterfall_config.GetTrybotForWaterfallBuilder('master1', 'builder1')) |
128 self.assertEqual( | 77 self.assertEqual( |
129 (None, None), | 78 (None, None), |
130 waterfall_config.GetTrybotForWaterfallBuilder('master2', 'builder2')) | 79 waterfall_config.GetTrybotForWaterfallBuilder('master2', 'builder2')) |
131 | 80 |
132 def testGetTryJobSettings(self): | 81 def testGetTryJobSettings(self): |
133 self.assertEqual( | 82 self.assertEqual( |
134 { | 83 { |
135 'server_query_interval_seconds': 60, | 84 'server_query_interval_seconds': 60, |
136 'job_timeout_hours': 5, | 85 'job_timeout_hours': 5, |
137 'allowed_response_error_times': 1 | 86 'allowed_response_error_times': 5 |
138 }, | 87 }, |
139 waterfall_config.GetTryJobSettings()) | 88 waterfall_config.GetTryJobSettings()) |
140 | 89 |
141 def testGetSwarmingSettings(self): | 90 def testGetSwarmingSettings(self): |
142 self.assertEqual( | 91 self.assertEqual( |
143 { | 92 { |
144 'server_host': 'chromium-swarm.appspot.com', | 93 'server_host': 'chromium-swarm.appspot.com', |
145 'default_request_priority': 150, | 94 'default_request_priority': 150, |
146 'request_expiration_hours': 20, | 95 'request_expiration_hours': 20, |
147 'server_query_interval_seconds': 60, | 96 'server_query_interval_seconds': 60, |
148 'task_timeout_hours': 23, | 97 'task_timeout_hours': 23, |
149 'isolated_server': 'https://isolateserver.appspot.com', | 98 'isolated_server': 'https://isolateserver.appspot.com', |
150 'isolated_storage_url': 'isolateserver.storage.googleapis.com', | 99 'isolated_storage_url': 'isolateserver.storage.googleapis.com', |
151 'iterations_to_rerun': 10 | 100 'iterations_to_rerun': 10 |
152 }, | 101 }, |
153 waterfall_config.GetSwarmingSettings()) | 102 waterfall_config.GetSwarmingSettings()) |
154 | 103 |
155 def testEnableStrictRegexForCompileLinkFailures(self): | 104 def testEnableStrictRegexForCompileLinkFailures(self): |
156 self.assertFalse( | 105 self.assertFalse( |
157 waterfall_config.EnableStrictRegexForCompileLinkFailures('m', 'b')) | 106 waterfall_config.EnableStrictRegexForCompileLinkFailures('m', 'b')) |
158 self.assertTrue( | 107 self.assertTrue( |
159 waterfall_config.EnableStrictRegexForCompileLinkFailures( | 108 waterfall_config.EnableStrictRegexForCompileLinkFailures( |
160 'master1', 'builder1')) | 109 'master1', 'builder1')) |
OLD | NEW |