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

Side by Side Diff: scripts/master/factory/swarm_factory.py

Issue 139343011: Add swarming_run_shim.py to run swarming tasks as annotated tasks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: . Created 6 years, 11 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
« no previous file with comments | « scripts/master/factory/swarm_commands.py ('k') | scripts/slave/swarming/swarming_run_shim.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Utility class to build the Swarm master BuildFactory's. 5 """Utility class to build the Swarm master BuildFactory's.
6 6
7 Based on chromium_factory.py and adds chromium-on-swarm-specific steps. 7 Based on chromium_factory.py and adds chromium-on-swarm-specific steps.
8 8
9 Common usage: 9 Common usage:
10 - For a split builder&tester configuration, use: 10 - For a split builder&tester configuration, use:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 # size of the executables to map. 43 # size of the executables to map.
44 SwarmTest('base_unittests', 1), 44 SwarmTest('base_unittests', 1),
45 SwarmTest('net_unittests', 1), 45 SwarmTest('net_unittests', 1),
46 SwarmTest('unit_tests', 2), 46 SwarmTest('unit_tests', 2),
47 SwarmTest('interactive_ui_tests', 3), 47 SwarmTest('interactive_ui_tests', 3),
48 SwarmTest('sync_integration_tests', 4), 48 SwarmTest('sync_integration_tests', 4),
49 SwarmTest('browser_tests', 5), 49 SwarmTest('browser_tests', 5),
50 ] 50 ]
51 51
52 52
53 def SwarmTestBuilder(swarm_server, isolation_outdir, tests): 53 def SwarmTestBuilder(swarm_server, isolation_server, tests):
54 """Create a basic swarm builder that runs tests via Swarm. 54 """Create a basic swarm builder that runs tests via Swarming.
55 55
56 To clarify, this 'buildbot builder' doesn't compile. 56 To clarify, this 'buildbot builder' doesn't compile, doesn't have a checkout,
57 it just triggers a job and gets results.
57 """ 58 """
58 valid_tests = set(s.test_name for s in SWARM_TESTS)
59 assert not any(t not in valid_tests for t in tests)
60
61 # No need of a window manager when only retrieving results. 59 # No need of a window manager when only retrieving results.
62 f = build_factory.BuildFactory() 60 f = build_factory.BuildFactory()
63 61
64 # Some of the scripts require a build_dir to be set, so set it even 62 # Some of the scripts require a build_dir to be set, so set it even
65 # if the machine might not have it (It shouldn't matter what this is). 63 # if the machine might not have it (It shouldn't matter what this is).
66 build_dir = 'chrome' 64 build_dir = 'chrome'
67 65
68 swarm_command_obj = swarm_commands.SwarmCommands(factory=f, 66 swarm_command_obj = swarm_commands.SwarmCommands(factory=f,
69 build_dir=build_dir) 67 build_dir=build_dir)
70 # Update scripts before triggering so the tasks are triggered and collected 68 # Update scripts before triggering so the tasks are triggered and collected
71 # with the same version of the scripts. 69 # with the same version of the scripts.
72 swarm_command_obj.AddUpdateScriptStep() 70 swarm_command_obj.AddUpdateScriptStep()
73 71
74 # Checks out the scripts at the right revision so the trigger can happen. 72 # Checks out the scripts at the right revision so the trigger can happen.
75 swarm_command_obj.AddUpdateSwarmClientStep() 73 swarm_command_obj.AddUpdateSwarmClientStep()
76 74
77 # Send the swarm tests to the swarm server. 75 swarm_command_obj.AddSwarmingStep(swarm_server, isolation_server)
78 swarm_tests = [s for s in SWARM_TESTS if s.test_name in tests]
79 swarm_command_obj.AddTriggerSwarmTestStep(
80 swarm_server=swarm_server,
81 isolation_outdir=isolation_outdir,
82 tests=swarm_tests,
83 doStepIf=swarm_commands.TestStepFilterTriggerSwarm)
84
85 # Collect the results
86 for swarm_test in swarm_tests:
87 swarm_command_obj.AddGetSwarmTestResultStep(
88 swarm_server, swarm_test.test_name, swarm_test.shards)
89
90 return f 76 return f
91 77
92 78
93 class SwarmFactory(chromium_factory.ChromiumFactory): 79 class SwarmFactory(chromium_factory.ChromiumFactory):
94 """Runs swarm tests in a single build, contrary to ChromiumFactory which can 80 """Runs swarming tests in a single build, contrary to ChromiumFactory which
95 trigger swarm jobs but doesn't look for results. 81 can trigger swarming jobs but doesn't look for results.
96 82
97 This factory does both, which is usually a waste of resource, you don't want 83 This factory does both, which is usually a waste of resource, you don't want
98 to waste a powerful slave sitting idle, waiting for swarm results. Used on 84 to waste a powerful slave sitting idle, waiting for swarm results. Used on
99 chromium.swarm canary for simplicity purpose. 85 chromium.swarm canary for simplicity purpose.
100 """ 86 """
101 def SwarmFactory( 87 def SwarmFactory(
102 self, tests, options, factory_properties, swarm_server, isolate_server): 88 self, tests, options, factory_properties, swarm_server, isolate_server):
103 """Only Release is supported for now. 89 """Only Release is supported for now.
104 90
105 Caller must not reuse factory_properties since it is modified in-place. 91 Caller must not reuse factory_properties since it is modified in-place.
106 """ 92 """
107 valid_tests = set(s.test_name for s in SWARM_TESTS)
108 assert not (set(tests) - set(valid_tests))
109 target = 'Release' 93 target = 'Release'
110
111 factory_properties.setdefault('gclient_env', {}) 94 factory_properties.setdefault('gclient_env', {})
112 factory_properties['gclient_env'].setdefault('GYP_DEFINES', '') 95 factory_properties['gclient_env'].setdefault('GYP_DEFINES', '')
113 factory_properties['gclient_env']['GYP_DEFINES'] += ( 96 factory_properties['gclient_env']['GYP_DEFINES'] += (
114 ' test_isolation_mode=hashtable test_isolation_outdir=' + 97 ' test_isolation_mode=hashtable test_isolation_outdir=' +
115 isolate_server) 98 isolate_server)
116 99
117 # Do not pass the tests to the ChromiumFactory, they'll be processed below. 100 # Do not pass the tests to the ChromiumFactory, they'll be processed below.
118 f = self.ChromiumFactory(target=target, 101 f = self.ChromiumFactory(target=target,
119 options=options, 102 options=options,
120 factory_properties=factory_properties) 103 factory_properties=factory_properties)
121 104
122 swarm_command_obj = swarm_commands.SwarmCommands( 105 swarm_command_obj = swarm_commands.SwarmCommands(
123 f, 106 f,
124 target, 107 target,
125 self._build_dir, 108 self._build_dir,
126 self._target_platform) 109 self._target_platform)
127 110
128 swarm_command_obj.AddGenerateIsolatedHashesStep(tests=tests, doStepIf=True) 111 swarm_command_obj.AddGenerateIsolatedHashesStep(tests=tests, doStepIf=True)
129 112 swarm_command_obj.AddSwarmingStep(swarm_server, isolate_server)
130 # Send of all the test requests as a single step.
131 swarm_tests = [s for s in SWARM_TESTS if s.test_name in tests]
132 swarm_command_obj.AddTriggerSwarmTestStep(swarm_server, isolate_server,
133 swarm_tests, True)
134
135 # Each test has its output returned as its own step.
136 for test in swarm_tests:
137 swarm_command_obj.AddGetSwarmTestResultStep(
138 swarm_server, test.test_name, test.shards)
139
140 return f 113 return f
141 114
142 115
143 class IsolatedFactory(chromium_factory.ChromiumFactory): 116 class IsolatedFactory(chromium_factory.ChromiumFactory):
144 """Run all the tests in isolated mode, without using swarm at all. 117 """Run all the tests in isolated mode, without using swarm at all.
145 118
146 It's a normal BuilderTester but runs all its tests in isolated mode 119 It's a normal BuilderTester but runs all its tests in isolated mode
147 inconditionally. 120 inconditionally.
148 """ 121 """
149 def IsolatedFactory(self, tests, options, factory_properties): 122 def IsolatedFactory(self, tests, options, factory_properties):
(...skipping 21 matching lines...) Expand all
171 144
172 # Reorder the tests by the order specified in SWARM_TESTS. E.g. the slower 145 # Reorder the tests by the order specified in SWARM_TESTS. E.g. the slower
173 # tests are retrieved last. 146 # tests are retrieved last.
174 for swarm_test in SWARM_TESTS: 147 for swarm_test in SWARM_TESTS:
175 if swarm_test.test_name in tests: 148 if swarm_test.test_name in tests:
176 tests.remove(swarm_test.test_name) 149 tests.remove(swarm_test.test_name)
177 swarm_command_obj.AddIsolateTest(swarm_test.test_name) 150 swarm_command_obj.AddIsolateTest(swarm_test.test_name)
178 151
179 assert not tests 152 assert not tests
180 return f 153 return f
OLDNEW
« no previous file with comments | « scripts/master/factory/swarm_commands.py ('k') | scripts/slave/swarming/swarming_run_shim.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698