yellow team mailing list archive
-
yellow team
-
Mailing list archive
-
Message #00740
[Merge] lp:~frankban/lpsetup/install-subunit into lp:lpsetup
Francesco Banconi has proposed merging lp:~frankban/lpsetup/install-subunit into lp:lpsetup.
Requested reviews:
Launchpad Yellow Squad (yellow)
For more details, see:
https://code.launchpad.net/~frankban/lpsetup/install-subunit/+merge/102874
== Changes ==
Added the --install-subunit option to the lxc-install sub command. This flag can be used to let lp-setup install subunit in the host.
lp-setup lxc-install now accepts a --testing flag as an alias for --use-urandom --create-scripts --install-subunit, and for all future tweaks needed in parallel tests.
The `initialize_lxc` step of the lxc-install sub command upgrades the debian packages of the newly created container.
== Tests ==
$ bin/test
Running zope.testrunner.layer.UnitTests tests:
Set up zope.testrunner.layer.UnitTests in 0.000 seconds.
Ran 48 tests with 0 failures and 0 errors in 0.478 seconds.
Tearing down left over layers:
Tear down zope.testrunner.layer.UnitTests in 0.000 seconds.
--
https://code.launchpad.net/~frankban/lpsetup/install-subunit/+merge/102874
Your team Launchpad Yellow Squad is requested to review the proposed merge of lp:~frankban/lpsetup/install-subunit into lp:lpsetup.
=== modified file 'lpsetup/handlers.py'
--- lpsetup/handlers.py 2012-03-16 16:49:23 +0000
+++ lpsetup/handlers.py 2012-04-20 14:53:27 +0000
@@ -243,3 +243,14 @@
'argument {0} does not reside under the home '
'directory of the system user.'.format(attr))
setattr(namespace, attr, directory)
+
+
+def handle_testing(namespace):
+ """Handle the `testing` flag.
+
+ Set the parallel testing related options to True if `testing` is True.
+ """
+ if getattr(namespace, 'testing', False):
+ namespace.create_scripts = True
+ namespace.install_subunit = True
+ namespace.use_urandom = True
=== modified file 'lpsetup/settings.py'
--- lpsetup/settings.py 2012-04-10 17:16:25 +0000
+++ lpsetup/settings.py 2012-04-20 14:53:27 +0000
@@ -73,7 +73,7 @@
lxc.network.link = {interface}
lxc.network.flags = up
"""
-LXC_PACKAGES = ['lxc', 'libvirt-bin']
+LXC_PACKAGES = ('lxc', 'libvirt-bin')
LXC_PATH = '/var/lib/lxc/'
RESOLV_FILE = '/etc/resolv.conf'
SCRIPTS = ('lp-setup-lxc-build', 'lp-setup-lxc-cleanup', 'lp-setup-lxc-test')
=== modified file 'lpsetup/subcommands/lxcinstall.py'
--- lpsetup/subcommands/lxcinstall.py 2012-04-18 10:02:33 +0000
+++ lpsetup/subcommands/lxcinstall.py 2012-04-20 14:53:27 +0000
@@ -29,6 +29,7 @@
ssh,
)
+from lpsetup import handlers
from lpsetup.settings import (
BASE_PACKAGES,
DHCP_FILE,
@@ -90,14 +91,17 @@
f.write('0\n')
-def create_lxc(user, lxc_name, lxc_arch, lxc_os):
+def create_lxc(user, lxc_name, lxc_arch, lxc_os, install_subunit):
"""Create the LXC named `lxc_name` sharing `user` home directory.
The container will be used as development environment or as base template
for parallel testing using ephemeral instances.
"""
# Install necessary deb packages.
- apt_get_install(*LXC_PACKAGES, caller=call)
+ packages = list(LXC_PACKAGES)
+ if install_subunit:
+ packages.append('subunit')
+ apt_get_install(*packages, caller=call)
# XXX 2012-02-02 gmb bug=925024:
# These calls need to be removed once the lxc vs. apparmor bug
# is resolved, since having apparmor enabled for lxc is very
@@ -175,7 +179,10 @@
'repository': LPSETUP_PPA,
}
sshcall('apt-add-repository {assume_yes} {repository}'.format(**args))
- sshcall('apt-get clean && apt-get update && apt-get install -y lpsetup')
+ sshcall('apt-get clean && apt-get update')
+ sshcall(
+ 'DEBIAN_FRONTEND=noninteractive '
+ 'apt-get upgrade -y && apt-get install -y lpsetup')
def setup_launchpad_lxc(
@@ -208,7 +215,7 @@
(create_scripts,
'user', 'lxc_name', 'ssh_key_path'),
(create_lxc,
- 'user', 'lxc_name', 'lxc_arch', 'lxc_os'),
+ 'user', 'lxc_name', 'lxc_arch', 'lxc_os', 'install_subunit'),
(start_lxc,
'lxc_name'),
(wait_for_lxc,
@@ -225,6 +232,10 @@
ssh_key_name_help = ('The ssh key name used to connect to Launchpad '
'and to to the LXC container.')
+ def get_validators(self, namespace):
+ validators = super(SubCommand, self).get_validators(namespace)
+ return validators + (handlers.handle_testing,)
+
def call_create_scripts(self, namespace, step, args):
"""Run the `create_scripts` step only if the related flag is set."""
if namespace.create_scripts:
@@ -248,3 +259,14 @@
parser.add_argument(
'-C', '--create-scripts', action='store_true',
help='Create the scripts used by buildbot for parallel testing.')
+ # The following flag is not present in the install sub command since
+ # subunit is always installed there as a dependency of
+ # launchpad-developer-dependencies.
+ parser.add_argument(
+ '--install-subunit', action='store_true',
+ help='Install subunit in the host machine. Activate this if you '
+ 'are using this command to create an automated parallel '
+ 'testing environment e.g. for buildbot.')
+ parser.add_argument(
+ '--testing', action='store_true',
+ help='Same as --use-urandom --create-scripts --install-subunit.')
=== modified file 'lpsetup/tests/test_handlers.py'
--- lpsetup/tests/test_handlers.py 2012-04-11 10:40:05 +0000
+++ lpsetup/tests/test_handlers.py 2012-04-20 14:53:27 +0000
@@ -15,6 +15,7 @@
handle_directories,
handle_lpuser,
handle_ssh_keys,
+ handle_testing,
handle_user,
handle_userdata,
)
@@ -151,6 +152,29 @@
handle_ssh_keys(namespace)
+class HandleTestingTest(unittest.TestCase):
+
+ context = {
+ 'create_scripts': True,
+ 'install_subunit': False,
+ 'use_urandom': False,
+ }
+
+ def test_true(self):
+ # Ensure aliased options are set to True if testing is True.
+ namespace = argparse.Namespace(testing=True, **self.context)
+ handle_testing(namespace)
+ for key in self.context:
+ self.assertTrue(getattr(namespace, key))
+
+ def test_false(self):
+ # Ensure no changes are made to aliased options if testing is False.
+ namespace = argparse.Namespace(testing=False, **self.context)
+ handle_testing(namespace)
+ for key, value in self.context.items():
+ self.assertEqual(value, getattr(namespace, key))
+
+
class HandleUserTest(HandlersTestMixin, unittest.TestCase):
def test_home_dir(self):