mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-24 07:01:13 +02:00
VM: Add --results_dir_root option to cros_run_parallel_vm_tests
This allows the user to specify a custom results directory root. cbuildbot can be switched to use cros_run_parallel_vm_tests if necessary without any further changes. Also create parents directories for user-specified results directory roots in run_remote_tests. BUG=8585 TEST=./bin/cros_run_parallel_vm_tests suite_Smoke suite_Smoke \ --results_dir_root=/tmp/foo Change-Id: I7314c1d9e74ca139eaa4bd95290866a43a3606ff Review URL: http://codereview.chromium.org/4297003
This commit is contained in:
parent
1f79aafb89
commit
3bab032123
@ -20,18 +20,28 @@ class ParallelTestRunner(object):
|
|||||||
|
|
||||||
_DEFAULT_START_SSH_PORT = 9222
|
_DEFAULT_START_SSH_PORT = 9222
|
||||||
|
|
||||||
def __init__(self, tests):
|
def __init__(self, tests, results_dir_root=None):
|
||||||
|
"""Constructs and initializes the test runner class.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
tests: A list of test names (see run_remote_tests.sh).
|
||||||
|
results_dir_root: The results directory root. If provided, the results
|
||||||
|
directory root for each test will be created under it with the SSH port
|
||||||
|
appended to the test name.
|
||||||
|
"""
|
||||||
self._tests = tests
|
self._tests = tests
|
||||||
|
self._results_dir_root = results_dir_root
|
||||||
|
|
||||||
def _SpawnTests(self):
|
def _SpawnTests(self):
|
||||||
"""Spawns VMs and starts the test runs on them.
|
"""Spawns VMs and starts the test runs on them.
|
||||||
|
|
||||||
Runs all tests in |self._tests|. Each test is executed on a separate VM.
|
Runs all tests in |self._tests|. Each test is executed on a separate VM.
|
||||||
|
|
||||||
Returns: A list of test process info objects containing the following
|
Returns:
|
||||||
dictionary entries:
|
A list of test process info objects containing the following dictionary
|
||||||
'test': the test name;
|
entries:
|
||||||
'proc': the Popen process instance for this test run.
|
'test': the test name;
|
||||||
|
'proc': the Popen process instance for this test run.
|
||||||
"""
|
"""
|
||||||
ssh_port = self._DEFAULT_START_SSH_PORT
|
ssh_port = self._DEFAULT_START_SSH_PORT
|
||||||
spawned_tests = []
|
spawned_tests = []
|
||||||
@ -45,6 +55,9 @@ class ParallelTestRunner(object):
|
|||||||
'--no_graphics',
|
'--no_graphics',
|
||||||
'--ssh_port=%d' % ssh_port,
|
'--ssh_port=%d' % ssh_port,
|
||||||
'--test_case=%s' % test ]
|
'--test_case=%s' % test ]
|
||||||
|
if self._results_dir_root:
|
||||||
|
args.append('--results_dir_root=%s/%s.%d' %
|
||||||
|
(self._results_dir_root, test, ssh_port))
|
||||||
Info('Running %r...' % args)
|
Info('Running %r...' % args)
|
||||||
proc = subprocess.Popen(args, stdin=dev_null)
|
proc = subprocess.Popen(args, stdin=dev_null)
|
||||||
test_info = { 'test': test,
|
test_info = { 'test': test,
|
||||||
@ -56,10 +69,11 @@ class ParallelTestRunner(object):
|
|||||||
def _WaitForCompletion(self, spawned_tests):
|
def _WaitForCompletion(self, spawned_tests):
|
||||||
"""Waits for tests to complete and returns a list of failed tests.
|
"""Waits for tests to complete and returns a list of failed tests.
|
||||||
|
|
||||||
Arguments:
|
Args:
|
||||||
spawned_tests: A list of test info objects (see _SpawnTests).
|
spawned_tests: A list of test info objects (see _SpawnTests).
|
||||||
|
|
||||||
Returns: A list of failed test names.
|
Returns:
|
||||||
|
A list of failed test names.
|
||||||
"""
|
"""
|
||||||
failed_tests = []
|
failed_tests = []
|
||||||
for test_info in spawned_tests:
|
for test_info in spawned_tests:
|
||||||
@ -78,13 +92,14 @@ class ParallelTestRunner(object):
|
|||||||
def main():
|
def main():
|
||||||
usage = 'Usage: %prog [options] tests...'
|
usage = 'Usage: %prog [options] tests...'
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
|
parser.add_option('--results_dir_root', help='Root results directory.')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
Die('no tests provided')
|
Die('no tests provided')
|
||||||
|
|
||||||
runner = ParallelTestRunner(args)
|
runner = ParallelTestRunner(args, options.results_dir_root)
|
||||||
runner.Run()
|
runner.Run()
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ function main() {
|
|||||||
if [[ ${INSIDE_CHROOT} -eq 0 ]]; then
|
if [[ ${INSIDE_CHROOT} -eq 0 ]]; then
|
||||||
if [[ -n "${FLAGS_results_dir_root}" ]]; then
|
if [[ -n "${FLAGS_results_dir_root}" ]]; then
|
||||||
TMP=${FLAGS_chroot}${FLAGS_results_dir_root}
|
TMP=${FLAGS_chroot}${FLAGS_results_dir_root}
|
||||||
mkdir -m 777 ${TMP}
|
mkdir -p -m 777 ${TMP}
|
||||||
else
|
else
|
||||||
TMP=$(mktemp -d ${FLAGS_chroot}/tmp/run_remote_tests.XXXX)
|
TMP=$(mktemp -d ${FLAGS_chroot}/tmp/run_remote_tests.XXXX)
|
||||||
fi
|
fi
|
||||||
@ -144,7 +144,7 @@ function main() {
|
|||||||
else
|
else
|
||||||
if [[ -n "${FLAGS_results_dir_root}" ]]; then
|
if [[ -n "${FLAGS_results_dir_root}" ]]; then
|
||||||
TMP=${FLAGS_results_dir_root}
|
TMP=${FLAGS_results_dir_root}
|
||||||
mkdir -m 777 ${TMP}
|
mkdir -p -m 777 ${TMP}
|
||||||
else
|
else
|
||||||
TMP=$(mktemp -d /tmp/run_remote_tests.XXXX)
|
TMP=$(mktemp -d /tmp/run_remote_tests.XXXX)
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user