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

Side by Side Diff: bin/cros_au_test_harness.py

Issue 6331007: Use different proxy ports, and log port conflicts. Hopefully works around (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Created 9 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 | « no previous file | lib/cros_test_proxy.py » ('j') | lib/cros_test_proxy.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """This module runs a suite of Auto Update tests. 7 """This module runs a suite of Auto Update tests.
8 8
9 The tests can be run on either a virtual machine or actual device depending 9 The tests can be run on either a virtual machine or actual device depending
10 on parameters given. Specific tests can be run by invoking --test_prefix. 10 on parameters given. Specific tests can be run by invoking --test_prefix.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 self._UpdateUsingPayload(payload) 132 self._UpdateUsingPayload(payload)
133 except UpdateException as err: 133 except UpdateException as err:
134 # Will raise ValueError if expected is not found. 134 # Will raise ValueError if expected is not found.
135 if re.search(re.escape(expected_msg), err.stdout, re.MULTILINE): 135 if re.search(re.escape(expected_msg), err.stdout, re.MULTILINE):
136 return 136 return
137 137
138 Warning("Didn't find '%s' in:" % expected_msg) 138 Warning("Didn't find '%s' in:" % expected_msg)
139 Warning(err.stdout) 139 Warning(err.stdout)
140 self.fail('We managed to update when failure was expected') 140 self.fail('We managed to update when failure was expected')
141 141
142 def AttemptUpdateWithFilter(self, filter): 142 def AttemptUpdateWithFilter(self, filter, proxy_port=8081):
143 """Update through a proxy, with a specified filter, and expect success.""" 143 """Update through a proxy, with a specified filter, and expect success."""
144 144
145 self.PrepareBase(self.target_image_path) 145 self.PrepareBase(self.target_image_path)
146 146
147 # The devserver runs at port 8080 by default. We assume that here, and 147 # The devserver runs at port 8080 by default. We assume that here, and
148 # start our proxy at 8081. We then tell our update tools to have the 148 # start our proxy at a different. We then tell our update tools to
149 # client connect to 8081 instead of 8080. 149 # have the client connect to our proxy_port instead of 8080.
150 proxy_port = 8081
151 proxy = cros_test_proxy.CrosTestProxy(port_in=proxy_port, 150 proxy = cros_test_proxy.CrosTestProxy(port_in=proxy_port,
152 address_out='127.0.0.1', 151 address_out='127.0.0.1',
153 port_out=8080, 152 port_out=8080,
154 filter=filter) 153 filter=filter)
155 proxy.serve_forever_in_thread() 154 proxy.serve_forever_in_thread()
156 155
157 # This update is expected to fail... 156 # This update is expected to fail...
158 try: 157 try:
159 self.PerformUpdate(self.target_image_path, self.base_image_path, 158 self.PerformUpdate(self.target_image_path, self.base_image_path,
160 proxy_port=proxy_port) 159 proxy_port=proxy_port)
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 outbound will be closed. 342 outbound will be closed.
344 """ 343 """
345 if self.close_count < 3: 344 if self.close_count < 3:
346 if self.data_size > (2 * 1024 * 1024): 345 if self.data_size > (2 * 1024 * 1024):
347 self.close_count += 1 346 self.close_count += 1
348 return None 347 return None
349 348
350 self.data_size += len(data) 349 self.data_size += len(data)
351 return data 350 return data
352 351
353 self.AttemptUpdateWithFilter(InterruptionFilter()) 352 self.AttemptUpdateWithFilter(InterruptionFilter(), proxy_port=8082)
354 353
355 def testDelayedUpdate(self): 354 def testDelayedUpdate(self):
356 """Tests what happens if some data is delayed during update delivery""" 355 """Tests what happens if some data is delayed during update delivery"""
357 356
358 class DelayedFilter(cros_test_proxy.Filter): 357 class DelayedFilter(cros_test_proxy.Filter):
359 """Causes intermittent delays in data transmission. 358 """Causes intermittent delays in data transmission.
360 359
361 It does this by inserting 3 20 second delays when transmitting 360 It does this by inserting 3 20 second delays when transmitting
362 data after 2M has been sent. 361 data after 2M has been sent.
363 """ 362 """
364 def setup(self): 363 def setup(self):
365 """Called once at the start of each connection.""" 364 """Called once at the start of each connection."""
366 self.data_size = 0 365 self.data_size = 0
367 self.delay_count = 0 366 self.delay_count = 0
368 367
369 def OutBound(self, data): 368 def OutBound(self, data):
370 """Called once per packet for outgoing data. 369 """Called once per packet for outgoing data.
371 370
372 The first three packets after we reach 2M transferred 371 The first three packets after we reach 2M transferred
373 are delayed by 20 seconds. 372 are delayed by 20 seconds.
374 """ 373 """
375 if self.delay_count < 3: 374 if self.delay_count < 3:
376 if self.data_size > (2 * 1024 * 1024): 375 if self.data_size > (2 * 1024 * 1024):
377 self.delay_count += 1 376 self.delay_count += 1
378 time.sleep(20) 377 time.sleep(20)
379 378
380 self.data_size += len(data) 379 self.data_size += len(data)
381 return data 380 return data
382 381
383 self.AttemptUpdateWithFilter(DelayedFilter()) 382 self.AttemptUpdateWithFilter(DelayedFilter(), proxy_port=8083)
384 383
385 def SimpleTest(self): 384 def SimpleTest(self):
386 """A simple update that updates once from a base image to a target. 385 """A simple update that updates once from a base image to a target.
387 386
388 We explicitly don't use test prefix so that isn't run by default. Can be 387 We explicitly don't use test prefix so that isn't run by default. Can be
389 run using test_prefix option. 388 run using test_prefix option.
390 """ 389 """
391 self.PrepareBase(self.base_image_path) 390 self.PrepareBase(self.base_image_path)
392 self.PerformUpdate(self.target_image_path, self.base_image_path) 391 self.PerformUpdate(self.target_image_path, self.base_image_path)
393 self.VerifyImage(100) 392 self.VerifyImage(100)
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 test_loader.testMethodPrefix = options.test_prefix 648 test_loader.testMethodPrefix = options.test_prefix
650 test_suite = test_loader.loadTestsFromTestCase(test_class) 649 test_suite = test_loader.loadTestsFromTestCase(test_class)
651 test_result = unittest.TextTestRunner(verbosity=2).run(test_suite) 650 test_result = unittest.TextTestRunner(verbosity=2).run(test_suite)
652 651
653 if not test_result.wasSuccessful(): 652 if not test_result.wasSuccessful():
654 Die('Test harness was not successful') 653 Die('Test harness was not successful')
655 654
656 655
657 if __name__ == '__main__': 656 if __name__ == '__main__':
658 main() 657 main()
OLDNEW
« no previous file with comments | « no previous file | lib/cros_test_proxy.py » ('j') | lib/cros_test_proxy.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698