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

Side by Side Diff: scripts/master/unittests/master_gen_test.py

Issue 1152093002: Adjust master_gen.PopulateBuildmasterConfig() to look at master_site_config (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: add active_master_cls param to AnnotatorFactory() Created 5 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Tests for scripts/master/master_gen.py.""" 6 """Tests for scripts/master/master_gen.py."""
7 7
8 import os 8 import os
9 import tempfile 9 import tempfile
10 import unittest 10 import unittest
(...skipping 11 matching lines...) Expand all
22 "Test Linux": { 22 "Test Linux": {
23 "properties": { 23 "properties": {
24 "config": "Release" 24 "config": "Release"
25 }, 25 },
26 "recipe": "test_recipe", 26 "recipe": "test_recipe",
27 "slave_pools": ["main"], 27 "slave_pools": ["main"],
28 "slavebuilddir": "test" 28 "slavebuilddir": "test"
29 } 29 }
30 }, 30 },
31 "git_repo_url": "https://chromium.googlesource.com/test/test.git", 31 "git_repo_url": "https://chromium.googlesource.com/test/test.git",
32 "master_base_class": "_FakeMaster", 32 "master_base_class": "_FakeMasterBase",
33 "master_port": 20999, 33 "master_port": 20999,
34 "master_port_alt": 40999, 34 "master_port_alt": 40999,
35 "master_type": "waterfall", 35 "master_type": "waterfall",
36 "slave_port": 30999, 36 "slave_port": 30999,
37 "slave_pools": { 37 "slave_pools": {
38 "main": { 38 "main": {
39 "slave_data": { 39 "slave_data": {
40 "bits": 64, 40 "bits": 64,
41 "os": "linux", 41 "os": "linux",
42 "version": "precise" 42 "version": "precise"
43 }, 43 },
44 "slaves": ["vm9999-m1"], 44 "slaves": ["vm9999-m1"],
45 }, 45 },
46 }, 46 },
47 "templates": ["templates"], 47 "templates": ["templates"],
48 } 48 }
49 """ 49 """
50 50
51 51
52 class _FakeMaster(object): 52 # This class fakes the base class from master_site_config.py.
53 class _FakeMasterBase(object):
53 in_production = False 54 in_production = False
54 is_production_host = False 55 is_production_host = False
56
57
58 # This class fakes the actual master class in master_site_config.py.
59 class _FakeMaster(_FakeMasterBase):
55 project_name = 'test' 60 project_name = 'test'
56 project_url = 'https://example.com/' 61 master_port = '20999'
62 slave_port = '30999'
63 master_port_alt = '40999'
64 buildbot_url = 'https://build.chromium.org/p/test'
57 buildbucket_bucket = None 65 buildbucket_bucket = None
58 66 service_account_file = None
59 @classmethod
60 def GetBotPassword(cls):
61 return ''
62 67
63 68
64 class PopulateBuildmasterConfigTest(unittest.TestCase): 69 class PopulateBuildmasterConfigTest(unittest.TestCase):
65 def test_waterfall(self): 70 def test_waterfall(self):
66 try: 71 try:
67 fp = tempfile.NamedTemporaryFile(delete=False) 72 fp = tempfile.NamedTemporaryFile(delete=False)
68 fp.write(SAMPLE_BUILDERS_PY) 73 fp.write(SAMPLE_BUILDERS_PY)
69 fp.close() 74 fp.close()
70 75
71 setattr(_FakeMaster, '_FakeMaster', _FakeMaster)
72 c = {} 76 c = {}
73 master_gen.PopulateBuildmasterConfig(c, fp.name, _FakeMaster) 77 master_gen.PopulateBuildmasterConfig(c, fp.name, _FakeMaster)
74 78
75 self.assertEqual(len(c['builders']), 1) 79 self.assertEqual(len(c['builders']), 1)
76 self.assertEqual(c['builders'][0]['name'], 'Test Linux') 80 self.assertEqual(c['builders'][0]['name'], 'Test Linux')
77 81
78 self.assertEqual(len(c['change_source']), 1) 82 self.assertEqual(len(c['change_source']), 1)
79 self.assertEqual(len(c['schedulers']), 1) 83 self.assertEqual(len(c['schedulers']), 1)
80 finally: 84 finally:
81 os.remove(fp.name) 85 os.remove(fp.name)
82 86
83 def test_tryserver(self): 87 def test_tryserver(self):
84 try: 88 try:
85 contents = SAMPLE_BUILDERS_PY.replace('waterfall', 'tryserver') 89 contents = SAMPLE_BUILDERS_PY.replace('waterfall', 'tryserver')
86 fp = tempfile.NamedTemporaryFile(delete=False) 90 fp = tempfile.NamedTemporaryFile(delete=False)
87 fp.write(contents) 91 fp.write(contents)
88 fp.close() 92 fp.close()
89 93
90 setattr(_FakeMaster, '_FakeMaster', _FakeMaster)
91 c = {} 94 c = {}
92 master_gen.PopulateBuildmasterConfig(c, fp.name, _FakeMaster) 95 master_gen.PopulateBuildmasterConfig(c, fp.name, _FakeMaster)
93 96
94 self.assertEqual(len(c['builders']), 1) 97 self.assertEqual(len(c['builders']), 1)
95 self.assertEqual(c['builders'][0]['name'], 'Test Linux') 98 self.assertEqual(c['builders'][0]['name'], 'Test Linux')
96 99
97 self.assertEqual(len(c['change_source']), 0) 100 self.assertEqual(len(c['change_source']), 0)
98 self.assertEqual(len(c['schedulers']), 1) 101 self.assertEqual(len(c['schedulers']), 1)
99 finally: 102 finally:
100 os.remove(fp.name) 103 os.remove(fp.name)
101 104
102 105
103 106
104 if __name__ == '__main__': 107 if __name__ == '__main__':
105 unittest.TestCase.maxDiff = None 108 unittest.TestCase.maxDiff = None
106 unittest.main() 109 unittest.main()
OLDNEW
« no previous file with comments | « scripts/master/master_gen.py ('k') | scripts/tools/buildbot_tool_templates/tryserver/master.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698