← Back to team overview

yellow team mailing list archive

[Merge] lp:~frankban/lpsetup/haveged into lp:lpsetup

 

Francesco Banconi has proposed merging lp:~frankban/lpsetup/haveged into lp:lpsetup.

Requested reviews:
  Launchpad Yellow Squad (yellow)

For more details, see:
https://code.launchpad.net/~frankban/lpsetup/haveged/+merge/106771

== Changes ==

- Replaced rngtools with haveged.
- Added a `version` sub command: display the software version.
- Updated default paths (repository and dependencies) to reflect the ones used by rocketfuel.

== Tests ==

$ nosetests 
.............................................................
Name                          Stmts   Miss  Cover   Missing
-----------------------------------------------------------
lpsetup                           6      0   100%   
lpsetup.argparser               125      6    95%   113, 221, 278-279, 298, 307
lpsetup.exceptions                6      0   100%   
lpsetup.handlers                 65      1    98%   57
lpsetup.settings                 28      0   100%   
lpsetup.subcommands               0      0   100%   
lpsetup.subcommands.version      11      0   100%   
lpsetup.utils                   133     32    76%   96, 130-140, 155, 206, 216, 237-239, 257-263, 278-279, 291-297
-----------------------------------------------------------
TOTAL                           374     39    90%   
----------------------------------------------------------------------
Ran 61 tests in 0.409s

OK


-- 
https://code.launchpad.net/~frankban/lpsetup/haveged/+merge/106771
Your team Launchpad Yellow Squad is requested to review the proposed merge of lp:~frankban/lpsetup/haveged into lp:lpsetup.
=== modified file 'lpsetup/cli.py'
--- lpsetup/cli.py	2012-05-15 09:03:48 +0000
+++ lpsetup/cli.py	2012-05-22 10:13:19 +0000
@@ -19,6 +19,7 @@
     install,
     lxcinstall,
     update,
+    version,
     )
 
 
@@ -28,6 +29,7 @@
     parser.register_subcommand('update', update.SubCommand)
     parser.register_subcommand('lxc-install', lxcinstall.SubCommand)
     parser.register_subcommand('branch', branch.SubCommand)
+    parser.register_subcommand('version', version.SubCommand)
     args = parser.parse_args()
     try:
         return args.main(args)

=== modified file 'lpsetup/handlers.py'
--- lpsetup/handlers.py	2012-05-15 09:04:57 +0000
+++ lpsetup/handlers.py	2012-05-22 10:13:19 +0000
@@ -256,7 +256,7 @@
     if getattr(namespace, 'testing', False):
         namespace.create_scripts = True
         namespace.install_subunit = True
-        namespace.use_urandom = True
+        namespace.feed_random = True
 
 
 def handle_branch_creation(namespace):

=== modified file 'lpsetup/settings.py'
--- lpsetup/settings.py	2012-05-15 13:52:22 +0000
+++ lpsetup/settings.py	2012-05-22 10:13:19 +0000
@@ -13,8 +13,8 @@
     'ppa:bzr/ppa',
     )
 BASE_PACKAGES = ['ssh', 'bzr']
-CHECKOUT_DIR = '~/launchpad/branches'
-DEPENDENCIES_DIR = '~/launchpad/dependencies'
+CHECKOUT_DIR = '~/launchpad/lp-branches'
+DEPENDENCIES_DIR = '~/launchpad/lp-sourcedeps'
 HOSTS_CONTENT = (
     ('127.0.0.88',
         'launchpad.dev answers.launchpad.dev archive.launchpad.dev '

=== modified file 'lpsetup/subcommands/install.py'
--- lpsetup/subcommands/install.py	2012-05-15 14:02:06 +0000
+++ lpsetup/subcommands/install.py	2012-05-22 10:13:19 +0000
@@ -117,7 +117,7 @@
 
 def initialize(
     user, full_name, email, lpuser, private_key, public_key, valid_ssh_keys,
-    ssh_key_path, use_urandom, dependencies_dir, directory):
+    ssh_key_path, feed_random, dependencies_dir, directory):
     """Initialize host machine."""
     # Install necessary deb packages.  This requires Oneiric or later.
     call('apt-get', 'update')
@@ -160,12 +160,10 @@
     # Set up the codebase.
     checkout_dir = os.path.join(directory, LP_CHECKOUT)
     setup_codebase(user, valid_ssh_keys, checkout_dir, dependencies_dir)
-    # rng-tools is used to set /dev/urandom as random data source, avoiding
+    # haveged is used to fill /dev/random, avoiding
     # entropy exhaustion during automated parallel tests.
-    if use_urandom:
-        apt_get_install('rng-tools', caller=call)
-        file_append('/etc/default/rng-tools', 'HRNGDEVICE=/dev/urandom')
-        call('/etc/init.d/rng-tools', 'start')
+    if feed_random:
+        apt_get_install('haveged', caller=call)
 
 
 def setup_bzr_locations(user, lpuser, directory, template=LP_BZR_LOCATIONS):
@@ -241,7 +239,7 @@
         (initialize,
          'user', 'full_name', 'email', 'lpuser',
          'private_key', 'public_key', 'valid_ssh_keys', 'ssh_key_path',
-         'use_urandom', 'dependencies_dir', 'directory'),
+         'feed_random', 'dependencies_dir', 'directory'),
         (setup_bzr_locations,
          'user', 'lpuser', 'directory'),
         (setup_apt,
@@ -315,11 +313,11 @@
             '-N', '--no-repositories', action='store_true',
             help='Do not add APT repositories.')
         parser.add_argument(
-            '-U', '--use-urandom', action='store_true',
-            help='Use /dev/urandom to feed /dev/random and avoid '
-                 'entropy exhaustion. WARNING: this reduces the actual '
-                 "randomness of your system's random number generator and "
-                 'thereby reduces security. Use only if determined to be '
-                 'necessary for this machine, and only if the machine is '
-                 'exclusively used for tasks identified as low-risk, '
-                 'such as running tests.')
+            '--feed-random', action='store_true',
+            help='Use haveged to maintain a pool of random bytes used to '
+                 'fill /dev/random and avoid entropy exhaustion. '
+                 'WARNING: this reduces the actual randomness of your '
+                 "system's random number generator and thereby reduces "
+                 'security. Use only if determined to be necessary for this '
+                 'machine, and only if the machine is exclusively used for '
+                 'tasks identified as low-risk, such as running tests.')

=== modified file 'lpsetup/subcommands/lxcinstall.py'
--- lpsetup/subcommands/lxcinstall.py	2012-05-15 14:12:37 +0000
+++ lpsetup/subcommands/lxcinstall.py	2012-05-22 10:13:19 +0000
@@ -205,7 +205,7 @@
         (install.initialize,
          'user', 'full_name', 'email', 'lpuser',
          'private_key', 'public_key', 'valid_ssh_keys', 'ssh_key_path',
-         'use_urandom', 'dependencies_dir', 'directory'),
+         'feed_random', 'dependencies_dir', 'directory'),
         (install.setup_bzr_locations,
          'user', 'lpuser', 'directory'),
         (create_scripts,
@@ -265,4 +265,4 @@
                  'testing environment e.g. for buildbot.')
         parser.add_argument(
             '--testing', action='store_true',
-            help='Same as --use-urandom --create-scripts --install-subunit.')
+            help='Same as --feed-random --create-scripts --install-subunit.')

=== added file 'lpsetup/subcommands/version.py'
--- lpsetup/subcommands/version.py	1970-01-01 00:00:00 +0000
+++ lpsetup/subcommands/version.py	2012-05-22 10:13:19 +0000
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Version subcommand: display lpsetup version."""
+
+__metaclass__ = type
+__all__ = [
+    'SubCommand',
+    ]
+
+import os
+import sys
+
+from lpsetup import (
+    argparser,
+    get_version,
+    )
+
+
+class SubCommand(argparser.BaseSubCommand):
+    """Display the software version."""
+
+    help = __doc__
+
+    def handle(self, namespace):
+        app_name = os.path.basename(sys.argv[0])
+        print '{0} v{1}'.format(app_name, get_version())

=== added directory 'lpsetup/tests/subcommands'
=== added file 'lpsetup/tests/subcommands/__init__.py'
=== added file 'lpsetup/tests/subcommands/test_version.py'
--- lpsetup/tests/subcommands/test_version.py	1970-01-01 00:00:00 +0000
+++ lpsetup/tests/subcommands/test_version.py	2012-05-22 10:13:19 +0000
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Tests for the version sub command."""
+
+import unittest
+
+from lpsetup import get_version
+from lpsetup.subcommands import version
+from lpsetup.tests.utils import (
+    capture_output,
+    SubCommandTestMixin,
+    )
+
+
+class VersionTest(SubCommandTestMixin, unittest.TestCase):
+
+    sub_command_class = version.SubCommand
+    sub_command_name = 'subcmd'
+
+    def test_sub_command(self):
+        with capture_output() as output:
+            self.parse_and_call_main()
+        bits = output.getvalue().strip().split()
+        self.assertEqual('v' + get_version(), bits[1])

=== modified file 'lpsetup/tests/test_argparser.py'
--- lpsetup/tests/test_argparser.py	2012-03-30 10:27:46 +0000
+++ lpsetup/tests/test_argparser.py	2012-05-22 10:13:19 +0000
@@ -12,6 +12,7 @@
 from lpsetup.tests.utils import (
     capture_error,
     capture_output,
+    SubCommandTestMixin,
     )
 
 
@@ -78,28 +79,6 @@
         self.assertIn('unrecognized arguments: help', error.getvalue())
 
 
-class SubCommandTestMixin(object):
-
-    sub_command_class = examples.SubCommand
-    sub_command_name = 'subcmd'
-
-    def setUp(self):
-        self.parser = argparser.ArgumentParser()
-        self.sub_command = self.parser.register_subcommand(
-            self.sub_command_name, self.sub_command_class)
-
-    def parse_and_call_main(self, arguments=None):
-        args = [self.sub_command_name]
-        if arguments is not None:
-            args.extend(arguments.split())
-        namespace = self.parser.parse_args(args)
-        return namespace.main(namespace)
-
-    def check_output(self, expected, output):
-        value = filter(None, output.getvalue().split('\n'))
-        self.assertSequenceEqual(expected, value)
-
-
 class BaseSubCommandTest(SubCommandTestMixin, unittest.TestCase):
 
     def set_validators(self, *args):

=== modified file 'lpsetup/tests/test_handlers.py'
--- lpsetup/tests/test_handlers.py	2012-05-15 09:05:55 +0000
+++ lpsetup/tests/test_handlers.py	2012-05-22 10:13:19 +0000
@@ -198,7 +198,7 @@
     ctx = {
         'create_scripts': True,
         'install_subunit': False,
-        'use_urandom': False,
+        'feed_random': False,
         }
 
     def test_true(self):

=== modified file 'lpsetup/tests/utils.py'
--- lpsetup/tests/utils.py	2012-03-15 14:17:10 +0000
+++ lpsetup/tests/utils.py	2012-05-22 10:13:19 +0000
@@ -15,6 +15,9 @@
 from StringIO import StringIO
 import sys
 
+from lpsetup import argparser
+from lpsetup.tests import examples
+
 
 @contextmanager
 def capture(attr):
@@ -29,3 +32,25 @@
 
 capture_output = partial(capture, 'stdout')
 capture_error = partial(capture, 'stderr')
+
+
+class SubCommandTestMixin(object):
+
+    sub_command_class = examples.SubCommand
+    sub_command_name = 'subcmd'
+
+    def setUp(self):
+        self.parser = argparser.ArgumentParser()
+        self.sub_command = self.parser.register_subcommand(
+            self.sub_command_name, self.sub_command_class)
+
+    def parse_and_call_main(self, arguments=None):
+        args = [self.sub_command_name]
+        if arguments is not None:
+            args.extend(arguments.split())
+        namespace = self.parser.parse_args(args)
+        return namespace.main(namespace)
+
+    def check_output(self, expected, output):
+        value = filter(None, output.getvalue().split('\n'))
+        self.assertSequenceEqual(expected, value)