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

Side by Side Diff: infra/services/service_manager/test/service_thread_test.py

Issue 1365583002: Have service_manager start a cloudtail attached to each service it starts. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Don't use hash() Created 5 years, 3 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
« no previous file with comments | « infra/services/service_manager/test/service_test.py ('k') | infra_libs/experiments.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) 2015 The Chromium Authors. All rights reserved. 1 # Copyright (c) 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 import threading 5 import threading
6 import unittest 6 import unittest
7 7
8 import mock 8 import mock
9 9
10 from infra.services.service_manager import service 10 from infra.services.service_manager import service
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 service_thread.ServiceThread.upgrades.reset() 50 service_thread.ServiceThread.upgrades.reset()
51 51
52 self.mock_service_ctor = mock.patch( 52 self.mock_service_ctor = mock.patch(
53 'infra.services.service_manager.service.Service').start() 53 'infra.services.service_manager.service.Service').start()
54 self.mock_service = self.mock_service_ctor.return_value 54 self.mock_service = self.mock_service_ctor.return_value
55 self.mock_service.name = 'foo' 55 self.mock_service.name = 'foo'
56 56
57 config = {'name': 'foo'} 57 config = {'name': 'foo'}
58 self.condition = FakeCondition() 58 self.condition = FakeCondition()
59 self.t = service_thread.ServiceThread( 59 self.t = service_thread.ServiceThread(
60 10, '/foo', config, wait_condition=self.condition) 60 10, '/foo', config, None, wait_condition=self.condition)
61 61
62 self.mock_service_ctor.assert_called_once_with('/foo', config) 62 self.mock_service_ctor.assert_called_once_with('/foo', config, None)
63 63
64 def tearDown(self): 64 def tearDown(self):
65 if self.t.is_alive(): 65 if self.t.is_alive():
66 self.t.stop(join=False) 66 self.t.stop(join=False)
67 self.condition.next(blocking=False) 67 self.condition.next(blocking=False)
68 self.t.join() 68 self.t.join()
69 69
70 mock.patch.stopall() 70 mock.patch.stopall()
71 71
72 def test_run_and_exit(self): 72 def test_run_and_exit(self):
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 new_config = {'name': 'bar'} 191 new_config = {'name': 'bar'}
192 new_service = mock.Mock() 192 new_service = mock.Mock()
193 self.mock_service_ctor.return_value = new_service 193 self.mock_service_ctor.return_value = new_service
194 194
195 self.t.restart_with_new_config(new_config) 195 self.t.restart_with_new_config(new_config)
196 self.assertTrue(self.condition.notify_called) 196 self.assertTrue(self.condition.notify_called)
197 self.condition.next() 197 self.condition.next()
198 198
199 self.assertEqual(1, self.t.reconfigs.get({'service': 'foo'})) 199 self.assertEqual(1, self.t.reconfigs.get({'service': 'foo'}))
200 self.mock_service.stop.assert_called_once_with() 200 self.mock_service.stop.assert_called_once_with()
201 self.mock_service_ctor.assert_called_with('/foo', new_config) 201 self.mock_service_ctor.assert_called_with('/foo', new_config, None)
202 new_service.start.assert_called_once_with() 202 new_service.start.assert_called_once_with()
203 203
204 def test_new_args_on_startup(self): 204 def test_new_args_on_startup(self):
205 self.t.start() 205 self.t.start()
206 self.condition.start() 206 self.condition.start()
207 207
208 self.assertEqual(0, self.t.reconfigs.get({'service': 'foo'})) 208 self.assertEqual(0, self.t.reconfigs.get({'service': 'foo'}))
209 209
210 self.mock_service.get_running_process_state.return_value = ( 210 self.mock_service.get_running_process_state.return_value = (
211 service.ProcessState(pid=1, starttime=2)) 211 service.ProcessState(pid=1, starttime=2))
(...skipping 13 matching lines...) Expand all
225 self.mock_service.start.side_effect = Exception() 225 self.mock_service.start.side_effect = Exception()
226 226
227 self.t.start_service() 227 self.t.start_service()
228 self.assertTrue(self.condition.notify_called) 228 self.assertTrue(self.condition.notify_called)
229 self.condition.next() 229 self.condition.next()
230 230
231 self.mock_service.start.assert_called_once_with() 231 self.mock_service.start.assert_called_once_with()
232 232
233 # The loop should continue. 233 # The loop should continue.
234 self.condition.next() 234 self.condition.next()
OLDNEW
« no previous file with comments | « infra/services/service_manager/test/service_test.py ('k') | infra_libs/experiments.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698