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

Side by Side Diff: au_test_harness/au_test.py

Issue 6815003: This CL updates the parallel job library in the au test harness to be more robust. (Closed) Base URL: http://git.chromium.org/git/crostestutils.git@master
Patch Set: Last fixes Created 9 years, 8 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 | au_test_harness/au_worker.py » ('j') | au_test_harness/parallel_test_job.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium OS 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 """Module containing a test suite that is run to test auto updates.""" 5 """Module containing a test suite that is run to test auto updates."""
6 6
7 import os 7 import os
8 import tempfile 8 import tempfile
9 import time 9 import time
10 import unittest 10 import unittest
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 def tearDown(self): 124 def tearDown(self):
125 """Overrides unittest.TestCase.tearDown and called after every test.""" 125 """Overrides unittest.TestCase.tearDown and called after every test."""
126 self.worker.CleanUp() 126 self.worker.CleanUp()
127 127
128 def testUpdateKeepStateful(self): 128 def testUpdateKeepStateful(self):
129 """Tests if we can update normally. 129 """Tests if we can update normally.
130 130
131 This test checks that we can update by updating the stateful partition 131 This test checks that we can update by updating the stateful partition
132 rather than wiping it. 132 rather than wiping it.
133 """ 133 """
134 self.worker.InitializeResultsDirectory() 134 self.worker.Initialize(9222)
135 # Just make sure some tests pass on original image. Some old images 135 # Just make sure some tests pass on original image. Some old images
136 # don't pass many tests. 136 # don't pass many tests.
137 self.worker.PrepareBase(self.base_image_path) 137 self.worker.PrepareBase(self.base_image_path)
138 # TODO(sosa): move to 100% once we start testing using the autotest paired 138 # TODO(sosa): move to 100% once we start testing using the autotest paired
139 # with the dev channel. 139 # with the dev channel.
140 percent_passed = self.worker.VerifyImage(self, 10) 140 percent_passed = self.worker.VerifyImage(self, 10)
141 141
142 # Update to - all tests should pass on new image. 142 # Update to - all tests should pass on new image.
143 self.worker.PerformUpdate(self.target_image_path, self.base_image_path) 143 self.worker.PerformUpdate(self.target_image_path, self.base_image_path)
144 percent_passed = self.worker.VerifyImage(self) 144 percent_passed = self.worker.VerifyImage(self)
145 145
146 # Update from - same percentage should pass that originally passed. 146 # Update from - same percentage should pass that originally passed.
147 self.worker.PerformUpdate(self.base_image_path, self.target_image_path) 147 self.worker.PerformUpdate(self.base_image_path, self.target_image_path)
148 self.worker.VerifyImage(self, percent_passed) 148 self.worker.VerifyImage(self, percent_passed)
149 149
150 def testUpdateWipeStateful(self): 150 def testUpdateWipeStateful(self):
151 """Tests if we can update after cleaning the stateful partition. 151 """Tests if we can update after cleaning the stateful partition.
152 152
153 This test checks that we can update successfully after wiping the 153 This test checks that we can update successfully after wiping the
154 stateful partition. 154 stateful partition.
155 """ 155 """
156 self.worker.InitializeResultsDirectory() 156 self.worker.Initialize(9223)
157 # Just make sure some tests pass on original image. Some old images 157 # Just make sure some tests pass on original image. Some old images
158 # don't pass many tests. 158 # don't pass many tests.
159 self.worker.PrepareBase(self.base_image_path) 159 self.worker.PrepareBase(self.base_image_path)
160 percent_passed = self.worker.VerifyImage(self, 10) 160 percent_passed = self.worker.VerifyImage(self, 10)
161 161
162 # Update to - all tests should pass on new image. 162 # Update to - all tests should pass on new image.
163 self.worker.PerformUpdate(self.target_image_path, self.base_image_path, 163 self.worker.PerformUpdate(self.target_image_path, self.base_image_path,
164 'clean') 164 'clean')
165 self.worker.VerifyImage(self) 165 self.worker.VerifyImage(self)
166 166
(...skipping 27 matching lines...) Expand all
194 outbound will be closed. 194 outbound will be closed.
195 """ 195 """
196 if self.close_count < 3: 196 if self.close_count < 3:
197 if self.data_size > (2 * 1024 * 1024): 197 if self.data_size > (2 * 1024 * 1024):
198 self.close_count += 1 198 self.close_count += 1
199 return None 199 return None
200 200
201 self.data_size += len(data) 201 self.data_size += len(data)
202 return data 202 return data
203 203
204 self.worker.InitializeResultsDirectory() 204 self.worker.Initialize(9224)
205 self.AttemptUpdateWithFilter(InterruptionFilter(), proxy_port=8082) 205 self.AttemptUpdateWithFilter(InterruptionFilter(), proxy_port=8082)
206 206
207 def testDelayedUpdate(self): 207 def testDelayedUpdate(self):
208 """Tests what happens if some data is delayed during update delivery""" 208 """Tests what happens if some data is delayed during update delivery"""
209 209
210 class DelayedFilter(cros_test_proxy.Filter): 210 class DelayedFilter(cros_test_proxy.Filter):
211 """Causes intermittent delays in data transmission. 211 """Causes intermittent delays in data transmission.
212 212
213 It does this by inserting 3 20 second delays when transmitting 213 It does this by inserting 3 20 second delays when transmitting
214 data after 2M has been sent. 214 data after 2M has been sent.
(...skipping 10 matching lines...) Expand all
225 are delayed by 20 seconds. 225 are delayed by 20 seconds.
226 """ 226 """
227 if self.delay_count < 3: 227 if self.delay_count < 3:
228 if self.data_size > (2 * 1024 * 1024): 228 if self.data_size > (2 * 1024 * 1024):
229 self.delay_count += 1 229 self.delay_count += 1
230 time.sleep(20) 230 time.sleep(20)
231 231
232 self.data_size += len(data) 232 self.data_size += len(data)
233 return data 233 return data
234 234
235 self.worker.InitializeResultsDirectory() 235 self.worker.Initialize(9225)
236 self.AttemptUpdateWithFilter(DelayedFilter(), proxy_port=8083) 236 self.AttemptUpdateWithFilter(DelayedFilter(), proxy_port=8083)
237 237
238 def SimpleTest(self): 238 def SimpleTest(self):
239 """A simple update that updates once from a base image to a target. 239 """A simple update that updates once from a base image to a target.
240 240
241 We explicitly don't use test prefix so that isn't run by default. Can be 241 We explicitly don't use test prefix so that isn't run by default. Can be
242 run using test_prefix option. 242 run using test_prefix option.
243 """ 243 """
244 self.worker.InitializeResultsDirectory() 244 self.worker.Initialize(9226)
245 self.worker.PrepareBase(self.base_image_path) 245 self.worker.PrepareBase(self.base_image_path)
246 self.worker.PerformUpdate(self.target_image_path, self.base_image_path) 246 self.worker.PerformUpdate(self.target_image_path, self.base_image_path)
247 self.worker.VerifyImage(self) 247 self.worker.VerifyImage(self)
248 248
249 # --- DISABLED TESTS --- 249 # --- DISABLED TESTS ---
250 250
251 # TODO(sosa): Get test to work with verbose. 251 # TODO(sosa): Get test to work with verbose.
252 def NotestPartialUpdate(self): 252 def NotestPartialUpdate(self):
253 """Tests what happens if we attempt to update with a truncated payload.""" 253 """Tests what happens if we attempt to update with a truncated payload."""
254 self.worker.InitializeResultsDirectory() 254 self.worker.Initialize(9227)
255 # Preload with the version we are trying to test. 255 # Preload with the version we are trying to test.
256 self.worker.PrepareBase(self.target_image_path) 256 self.worker.PrepareBase(self.target_image_path)
257 257
258 # Image can be updated at: 258 # Image can be updated at:
259 # ~chrome-eng/chromeos/localmirror/autest-images 259 # ~chrome-eng/chromeos/localmirror/autest-images
260 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \ 260 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \
261 'autest-images/truncated_image.gz' 261 'autest-images/truncated_image.gz'
262 payload = os.path.join(self.download_folder, 'truncated_image.gz') 262 payload = os.path.join(self.download_folder, 'truncated_image.gz')
263 263
264 # Read from the URL and write to the local file 264 # Read from the URL and write to the local file
265 urllib.urlretrieve(url, payload) 265 urllib.urlretrieve(url, payload)
266 266
267 expected_msg = 'download_hash_data == update_check_response_hash failed' 267 expected_msg = 'download_hash_data == update_check_response_hash failed'
268 self.AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) 268 self.AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg)
269 269
270 # TODO(sosa): Get test to work with verbose. 270 # TODO(sosa): Get test to work with verbose.
271 def NotestCorruptedUpdate(self): 271 def NotestCorruptedUpdate(self):
272 """Tests what happens if we attempt to update with a corrupted payload.""" 272 """Tests what happens if we attempt to update with a corrupted payload."""
273 self.worker.InitializeResultsDirectory() 273 self.worker.Initialize(9228)
274 # Preload with the version we are trying to test. 274 # Preload with the version we are trying to test.
275 self.worker.PrepareBase(self.target_image_path) 275 self.worker.PrepareBase(self.target_image_path)
276 276
277 # Image can be updated at: 277 # Image can be updated at:
278 # ~chrome-eng/chromeos/localmirror/autest-images 278 # ~chrome-eng/chromeos/localmirror/autest-images
279 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \ 279 url = 'http://gsdview.appspot.com/chromeos-localmirror/' \
280 'autest-images/corrupted_image.gz' 280 'autest-images/corrupted_image.gz'
281 payload = os.path.join(self.download_folder, 'corrupted.gz') 281 payload = os.path.join(self.download_folder, 'corrupted.gz')
282 282
283 # Read from the URL and write to the local file 283 # Read from the URL and write to the local file
284 urllib.urlretrieve(url, payload) 284 urllib.urlretrieve(url, payload)
285 285
286 # This update is expected to fail... 286 # This update is expected to fail...
287 expected_msg = 'zlib inflate() error:-3' 287 expected_msg = 'zlib inflate() error:-3'
288 self.AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg) 288 self.AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg)
OLDNEW
« no previous file with comments | « no previous file | au_test_harness/au_worker.py » ('j') | au_test_harness/parallel_test_job.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698