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

Side by Side Diff: au_test_harness/vm_au_worker.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: Don's feedback 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 | « au_test_harness/parallel_test_job.py ('k') | ctest/ctest.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) 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 implementation of an au_worker for virtual machines.""" 5 """Module containing implementation of an au_worker for virtual machines."""
6 6
7 import os 7 import os
8 import threading
9 import unittest 8 import unittest
10 9
11 import cros_build_lib as cros_lib 10 import cros_build_lib as cros_lib
12 11
13 import au_worker 12 import au_worker
14 13
15 14
16 class VMAUWorker(au_worker.AUWorker): 15 class VMAUWorker(au_worker.AUWorker):
17 """Test harness for updating virtual machines.""" 16 """Test harness for updating virtual machines."""
18 17
19 # Class variables used to acquire individual VM variables per test.
20 _vm_lock = threading.Lock()
21 _next_port = 9222
22
23 def __init__(self, options, test_results_root): 18 def __init__(self, options, test_results_root):
24 """Processes vm-specific options.""" 19 """Processes vm-specific options."""
25 au_worker.AUWorker.__init__(self, options, test_results_root) 20 au_worker.AUWorker.__init__(self, options, test_results_root)
26 self.graphics_flag = '' 21 self.graphics_flag = ''
27 if options.no_graphics: self.graphics_flag = '--no_graphics' 22 if options.no_graphics: self.graphics_flag = '--no_graphics'
28 if not self.board: cros_lib.Die('Need board to convert base image to vm.') 23 if not self.board: cros_lib.Die('Need board to convert base image to vm.')
29 24
30 self._AcquireUniquePortAndPidFile()
31 self._KillExistingVM(self._kvm_pid_file)
32
33 def _KillExistingVM(self, pid_file): 25 def _KillExistingVM(self, pid_file):
34 """Kills an existing VM specified by the pid_file.""" 26 """Kills an existing VM specified by the pid_file."""
35 if os.path.exists(pid_file): 27 if os.path.exists(pid_file):
36 cros_lib.Warning('Existing %s found. Deleting and killing process' % 28 cros_lib.Warning('Existing %s found. Deleting and killing process' %
37 pid_file) 29 pid_file)
38 cros_lib.RunCommand(['./cros_stop_vm', '--kvm_pid=%s' % pid_file], 30 cros_lib.RunCommand(['./cros_stop_vm', '--kvm_pid=%s' % pid_file],
39 cwd=self.crosutilsbin) 31 cwd=self.crosutilsbin)
40 32
41 assert not os.path.exists(pid_file) 33 assert not os.path.exists(pid_file)
42 34
43 def _AcquireUniquePortAndPidFile(self):
44 """Acquires unique ssh port and pid file for VM."""
45 with VMAUWorker._vm_lock:
46 self._ssh_port = VMAUWorker._next_port
47 self._kvm_pid_file = '/tmp/kvm.%d' % self._ssh_port
48 VMAUWorker._next_port += 1
49
50 def CleanUp(self): 35 def CleanUp(self):
51 """Stop the vm after a test.""" 36 """Stop the vm after a test."""
52 self._KillExistingVM(self._kvm_pid_file) 37 self._KillExistingVM(self._kvm_pid_file)
53 38
54 def PrepareBase(self, image_path): 39 def PrepareBase(self, image_path):
55 """Creates an update-able VM based on base image.""" 40 """Creates an update-able VM based on base image."""
56 self.PrepareVMBase(image_path) 41 self.PrepareVMBase(image_path)
57 42
58 def UpdateImage(self, image_path, src_image_path='', stateful_change='old', 43 def UpdateImage(self, image_path, src_image_path='', stateful_change='old',
59 proxy_port='', private_key_path=None): 44 proxy_port='', private_key_path=None):
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 '--results_dir_root=%s' % log_directory_in_chroot, 97 '--results_dir_root=%s' % log_directory_in_chroot,
113 self.verify_suite, 98 self.verify_suite,
114 ] 99 ]
115 if self.graphics_flag: commandWithArgs.append(self.graphics_flag) 100 if self.graphics_flag: commandWithArgs.append(self.graphics_flag)
116 output = cros_lib.RunCommand(commandWithArgs, error_ok=True, 101 output = cros_lib.RunCommand(commandWithArgs, error_ok=True,
117 enter_chroot=False, redirect_stdout=True, 102 enter_chroot=False, redirect_stdout=True,
118 cwd=self.crosutilsbin) 103 cwd=self.crosutilsbin)
119 return self.AssertEnoughTestsPassed(unittest, output, 104 return self.AssertEnoughTestsPassed(unittest, output,
120 percent_required_to_pass) 105 percent_required_to_pass)
121 106
OLDNEW
« no previous file with comments | « au_test_harness/parallel_test_job.py ('k') | ctest/ctest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698