mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-25 07:31:01 +02:00
Add methods to run vm tests on x86-pre-flight-queue.
Right now we're leaving error_ok=True until the tests are shown to work on builder. Change-Id: I6b8c690a0da30948389fd4312032c78d87115364 BUG=6906 TEST=Ran through it locally. Review URL: http://codereview.chromium.org/3591002
This commit is contained in:
parent
e3049de00f
commit
c2db26c796
@ -208,6 +208,20 @@ def _UprevAllPackages(buildroot):
|
|||||||
'--tracking_branch="cros/master"'],
|
'--tracking_branch="cros/master"'],
|
||||||
cwd=cwd, enter_chroot=True)
|
cwd=cwd, enter_chroot=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _GetVMConstants(buildroot):
|
||||||
|
"""Returns minimum (vdisk_size, statefulfs_size) recommended for VM's."""
|
||||||
|
cwd = os.path.join(buildroot, 'src', 'scripts', 'lib')
|
||||||
|
source_cmd = 'source %s/cros_vm_constants.sh' % cwd
|
||||||
|
vdisk_size = RunCommand([
|
||||||
|
'/bin/bash', '-c', '%s && echo $MIN_VDISK_SIZE_FULL' % source_cmd],
|
||||||
|
redirect_stdout=True)
|
||||||
|
statefulfs_size = RunCommand([
|
||||||
|
'/bin/bash', '-c', '%s && echo $MIN_STATEFUL_FS_SIZE_FULL' % source_cmd],
|
||||||
|
redirect_stdout=True)
|
||||||
|
return (vdisk_size.strip(), statefulfs_size.strip())
|
||||||
|
|
||||||
|
|
||||||
# =========================== Main Commands ===================================
|
# =========================== Main Commands ===================================
|
||||||
|
|
||||||
def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES):
|
def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES):
|
||||||
@ -244,20 +258,43 @@ def _Build(buildroot):
|
|||||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
RunCommand(['./build_packages'], cwd=cwd, enter_chroot=True)
|
RunCommand(['./build_packages'], cwd=cwd, enter_chroot=True)
|
||||||
|
|
||||||
|
|
||||||
def _WipeOldOutput(buildroot):
|
def _WipeOldOutput(buildroot):
|
||||||
RunCommand(['rm', '-rf', 'src/build/images'], cwd=buildroot)
|
RunCommand(['rm', '-rf', 'src/build/images'], cwd=buildroot)
|
||||||
|
|
||||||
|
|
||||||
def _BuildImage(buildroot):
|
def _BuildImage(buildroot):
|
||||||
_WipeOldOutput(buildroot)
|
_WipeOldOutput(buildroot)
|
||||||
|
|
||||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
RunCommand(['./build_image', '--replace'], cwd=cwd, enter_chroot=True)
|
RunCommand(['./build_image', '--replace'], cwd=cwd, enter_chroot=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _BuildVMImageForTesting(buildroot):
|
||||||
|
(vdisk_size, statefulfs_size) = _GetVMConstants(buildroot)
|
||||||
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
|
RunCommand(['./image_to_vm.sh',
|
||||||
|
'--test_image',
|
||||||
|
'--full',
|
||||||
|
'--vdisk_size %s' % vdisk_size,
|
||||||
|
'--statefulfs_size %s' % statefulfs_size,
|
||||||
|
], cwd=cwd, enter_chroot=True)
|
||||||
|
|
||||||
|
|
||||||
def _RunUnitTests(buildroot):
|
def _RunUnitTests(buildroot):
|
||||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
RunCommand(['./cros_run_unit_tests'], cwd=cwd, enter_chroot=True)
|
RunCommand(['./cros_run_unit_tests'], cwd=cwd, enter_chroot=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _RunSmokeSuite(buildroot):
|
||||||
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
|
RunCommand(['bin/cros_run_vm_test',
|
||||||
|
'--no_graphics',
|
||||||
|
'--test_case',
|
||||||
|
'suite_Smoke',
|
||||||
|
], cwd=cwd, error_ok=True)
|
||||||
|
|
||||||
|
|
||||||
def _UprevPackages(buildroot, revisionfile, board):
|
def _UprevPackages(buildroot, revisionfile, board):
|
||||||
"""Uprevs a package based on given revisionfile.
|
"""Uprevs a package based on given revisionfile.
|
||||||
|
|
||||||
@ -383,6 +420,11 @@ def main():
|
|||||||
_RunUnitTests(buildroot)
|
_RunUnitTests(buildroot)
|
||||||
|
|
||||||
_BuildImage(buildroot)
|
_BuildImage(buildroot)
|
||||||
|
|
||||||
|
if buildconfig['smoke_bvt']:
|
||||||
|
_BuildVMImageForTesting(buildroot)
|
||||||
|
_RunSmokeSuite(buildroot)
|
||||||
|
|
||||||
if buildconfig['uprev']:
|
if buildconfig['uprev']:
|
||||||
if buildconfig['master']:
|
if buildconfig['master']:
|
||||||
# Master bot needs to check if the other slaves completed.
|
# Master bot needs to check if the other slaves completed.
|
||||||
|
@ -18,6 +18,7 @@ important -- Master bot uses important bots to determine overall status.
|
|||||||
hostname -- Needed for 'important' slaves. The hostname of the bot. Should
|
hostname -- Needed for 'important' slaves. The hostname of the bot. Should
|
||||||
match hostname in slaves.cfg in buildbot checkout.
|
match hostname in slaves.cfg in buildbot checkout.
|
||||||
unittests -- Runs unittests for packages.
|
unittests -- Runs unittests for packages.
|
||||||
|
smoke_bvt -- Runs the test smoke suite in a qemu-based VM using KVM.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ config['default'] = {
|
|||||||
'master' : False,
|
'master' : False,
|
||||||
'important' : False,
|
'important' : False,
|
||||||
'unittests' : False,
|
'unittests' : False,
|
||||||
|
'smoke_bvt' : False,
|
||||||
}
|
}
|
||||||
config['x86-generic-pre-flight-queue'] = {
|
config['x86-generic-pre-flight-queue'] = {
|
||||||
'board' : 'x86-generic',
|
'board' : 'x86-generic',
|
||||||
@ -37,6 +39,7 @@ config['x86-generic-pre-flight-queue'] = {
|
|||||||
'important' : False,
|
'important' : False,
|
||||||
'hostname' : 'chromeosbuild2',
|
'hostname' : 'chromeosbuild2',
|
||||||
'unittests' : True,
|
'unittests' : True,
|
||||||
|
'smoke_bvt' : True,
|
||||||
}
|
}
|
||||||
config['x86_pineview_bin'] = {
|
config['x86_pineview_bin'] = {
|
||||||
'board' : 'x86-pineview',
|
'board' : 'x86-pineview',
|
||||||
@ -45,6 +48,7 @@ config['x86_pineview_bin'] = {
|
|||||||
'important' : False,
|
'important' : False,
|
||||||
'hostname' : 'codf200.jail',
|
'hostname' : 'codf200.jail',
|
||||||
'unittests': True,
|
'unittests': True,
|
||||||
|
'smoke_bvt' : True,
|
||||||
}
|
}
|
||||||
config['arm_tegra2_bin'] = {
|
config['arm_tegra2_bin'] = {
|
||||||
'board' : 'tegra2',
|
'board' : 'tegra2',
|
||||||
|
@ -4,11 +4,21 @@
|
|||||||
|
|
||||||
"""Common python commands used by various build scripts."""
|
"""Common python commands used by various build scripts."""
|
||||||
|
|
||||||
|
import inspect
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
_STDOUT_IS_TTY = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
|
_STDOUT_IS_TTY = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
|
||||||
|
|
||||||
|
# TODO(sosa): Move logging to logging module.
|
||||||
|
|
||||||
|
def GetCallerName():
|
||||||
|
"""Returns the name of the calling module with __main__."""
|
||||||
|
top_frame = inspect.stack()[-1][0]
|
||||||
|
return os.path.basename(top_frame.f_code.co_filename)
|
||||||
|
|
||||||
|
|
||||||
def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
|
def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
|
||||||
exit_code=False, redirect_stdout=False, redirect_stderr=False,
|
exit_code=False, redirect_stdout=False, redirect_stderr=False,
|
||||||
cwd=None, input=None, enter_chroot=False):
|
cwd=None, input=None, enter_chroot=False):
|
||||||
@ -44,7 +54,8 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
|
|||||||
|
|
||||||
# Print out the command before running.
|
# Print out the command before running.
|
||||||
if print_cmd:
|
if print_cmd:
|
||||||
Info('RunCommand: %s' % ' '.join(cmd))
|
Info('PROGRAM(%s) -> RunCommand: %s in dir %s' %
|
||||||
|
(GetCallerName(), ' '.join(cmd), cwd))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin,
|
proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin,
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#
|
#
|
||||||
# Common vm functions for use in crosutils.
|
# Common vm functions for use in crosutils.
|
||||||
|
|
||||||
. "$(dirname "$0")/cros_vm_constants.sh"
|
|
||||||
|
|
||||||
DEFINE_string kvm_pid "" \
|
DEFINE_string kvm_pid "" \
|
||||||
"Use this pid file. If it exists and is set, use the vm specified by pid."
|
"Use this pid file. If it exists and is set, use the vm specified by pid."
|
||||||
DEFINE_boolean no_graphics ${FLAGS_FALSE} "Runs the KVM instance silently."
|
DEFINE_boolean no_graphics ${FLAGS_FALSE} "Runs the KVM instance silently."
|
||||||
@ -48,7 +46,7 @@ function start_kvm() {
|
|||||||
snapshot="-snapshot"
|
snapshot="-snapshot"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo kvm -m ${DEFAULT_MEM} \
|
sudo kvm -m 1024 \
|
||||||
-vga std \
|
-vga std \
|
||||||
-pidfile "${KVM_PID_FILE}" \
|
-pidfile "${KVM_PID_FILE}" \
|
||||||
-daemonize \
|
-daemonize \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user