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

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 26
Proposed branch: lp:~frankban/lpsetup/haveged
Merge into: lp:lpsetup
Diff against target: 279 lines (+96/-43)
10 files modified
lpsetup/cli.py (+2/-0)
lpsetup/handlers.py (+1/-1)
lpsetup/settings.py (+2/-2)
lpsetup/subcommands/install.py (+8/-15)
lpsetup/subcommands/lxcinstall.py (+2/-2)
lpsetup/subcommands/version.py (+28/-0)
lpsetup/tests/subcommands/test_version.py (+26/-0)
lpsetup/tests/test_argparser.py (+1/-22)
lpsetup/tests/test_handlers.py (+1/-1)
lpsetup/tests/utils.py (+25/-0)
To merge this branch: bzr merge lp:~frankban/lpsetup/haveged
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Review via email: mp+106771@code.launchpad.net

Description of the change

== 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

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

Hey Francesco. Looks good.

Do you think we still need the "WARNING" message now that we are using haveged? At the least, it seems to me that the warning should be reduced: haveged seems to think that it is entirely reasonable and safe, if I've read the web pages sufficiently (http://www.irisa.fr/caps/projects/hipsor/). What do you think?

Thanks

Gary

review: Approve
Revision history for this message
Gary Poster (gary) wrote :

Oh! In future, let's change Launchpad devs to be the owner of this project, so that reviews go to the usual Launchpad group rather than Yellow alone.

Revision history for this message
Francesco Banconi (frankban) wrote :

> Hey Francesco. Looks good.
>
> Do you think we still need the "WARNING" message now that we are using
> haveged? At the least, it seems to me that the warning should be reduced:
> haveged seems to think that it is entirely reasonable and safe, if I've read
> the web pages sufficiently (http://www.irisa.fr/caps/projects/hipsor/). What
> do you think?

I agree, haveged seems to generate unpredictable data, deleting the warning.

lp:~frankban/lpsetup/haveged updated
29. By Francesco Banconi

Deleted obsolete nrgtool warning.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lpsetup/cli.py'
2--- lpsetup/cli.py 2012-05-15 09:03:48 +0000
3+++ lpsetup/cli.py 2012-05-22 12:48:20 +0000
4@@ -19,6 +19,7 @@
5 install,
6 lxcinstall,
7 update,
8+ version,
9 )
10
11
12@@ -28,6 +29,7 @@
13 parser.register_subcommand('update', update.SubCommand)
14 parser.register_subcommand('lxc-install', lxcinstall.SubCommand)
15 parser.register_subcommand('branch', branch.SubCommand)
16+ parser.register_subcommand('version', version.SubCommand)
17 args = parser.parse_args()
18 try:
19 return args.main(args)
20
21=== modified file 'lpsetup/handlers.py'
22--- lpsetup/handlers.py 2012-05-15 09:04:57 +0000
23+++ lpsetup/handlers.py 2012-05-22 12:48:20 +0000
24@@ -256,7 +256,7 @@
25 if getattr(namespace, 'testing', False):
26 namespace.create_scripts = True
27 namespace.install_subunit = True
28- namespace.use_urandom = True
29+ namespace.feed_random = True
30
31
32 def handle_branch_creation(namespace):
33
34=== modified file 'lpsetup/settings.py'
35--- lpsetup/settings.py 2012-05-15 13:52:22 +0000
36+++ lpsetup/settings.py 2012-05-22 12:48:20 +0000
37@@ -13,8 +13,8 @@
38 'ppa:bzr/ppa',
39 )
40 BASE_PACKAGES = ['ssh', 'bzr']
41-CHECKOUT_DIR = '~/launchpad/branches'
42-DEPENDENCIES_DIR = '~/launchpad/dependencies'
43+CHECKOUT_DIR = '~/launchpad/lp-branches'
44+DEPENDENCIES_DIR = '~/launchpad/lp-sourcedeps'
45 HOSTS_CONTENT = (
46 ('127.0.0.88',
47 'launchpad.dev answers.launchpad.dev archive.launchpad.dev '
48
49=== modified file 'lpsetup/subcommands/install.py'
50--- lpsetup/subcommands/install.py 2012-05-15 14:02:06 +0000
51+++ lpsetup/subcommands/install.py 2012-05-22 12:48:20 +0000
52@@ -117,7 +117,7 @@
53
54 def initialize(
55 user, full_name, email, lpuser, private_key, public_key, valid_ssh_keys,
56- ssh_key_path, use_urandom, dependencies_dir, directory):
57+ ssh_key_path, feed_random, dependencies_dir, directory):
58 """Initialize host machine."""
59 # Install necessary deb packages. This requires Oneiric or later.
60 call('apt-get', 'update')
61@@ -160,12 +160,10 @@
62 # Set up the codebase.
63 checkout_dir = os.path.join(directory, LP_CHECKOUT)
64 setup_codebase(user, valid_ssh_keys, checkout_dir, dependencies_dir)
65- # rng-tools is used to set /dev/urandom as random data source, avoiding
66+ # haveged is used to fill /dev/random, avoiding
67 # entropy exhaustion during automated parallel tests.
68- if use_urandom:
69- apt_get_install('rng-tools', caller=call)
70- file_append('/etc/default/rng-tools', 'HRNGDEVICE=/dev/urandom')
71- call('/etc/init.d/rng-tools', 'start')
72+ if feed_random:
73+ apt_get_install('haveged', caller=call)
74
75
76 def setup_bzr_locations(user, lpuser, directory, template=LP_BZR_LOCATIONS):
77@@ -241,7 +239,7 @@
78 (initialize,
79 'user', 'full_name', 'email', 'lpuser',
80 'private_key', 'public_key', 'valid_ssh_keys', 'ssh_key_path',
81- 'use_urandom', 'dependencies_dir', 'directory'),
82+ 'feed_random', 'dependencies_dir', 'directory'),
83 (setup_bzr_locations,
84 'user', 'lpuser', 'directory'),
85 (setup_apt,
86@@ -315,11 +313,6 @@
87 '-N', '--no-repositories', action='store_true',
88 help='Do not add APT repositories.')
89 parser.add_argument(
90- '-U', '--use-urandom', action='store_true',
91- help='Use /dev/urandom to feed /dev/random and avoid '
92- 'entropy exhaustion. WARNING: this reduces the actual '
93- "randomness of your system's random number generator and "
94- 'thereby reduces security. Use only if determined to be '
95- 'necessary for this machine, and only if the machine is '
96- 'exclusively used for tasks identified as low-risk, '
97- 'such as running tests.')
98+ '--feed-random', action='store_true',
99+ help='Use haveged to maintain a pool of random bytes used to '
100+ 'fill /dev/random and avoid entropy exhaustion.')
101
102=== modified file 'lpsetup/subcommands/lxcinstall.py'
103--- lpsetup/subcommands/lxcinstall.py 2012-05-15 14:12:37 +0000
104+++ lpsetup/subcommands/lxcinstall.py 2012-05-22 12:48:20 +0000
105@@ -205,7 +205,7 @@
106 (install.initialize,
107 'user', 'full_name', 'email', 'lpuser',
108 'private_key', 'public_key', 'valid_ssh_keys', 'ssh_key_path',
109- 'use_urandom', 'dependencies_dir', 'directory'),
110+ 'feed_random', 'dependencies_dir', 'directory'),
111 (install.setup_bzr_locations,
112 'user', 'lpuser', 'directory'),
113 (create_scripts,
114@@ -265,4 +265,4 @@
115 'testing environment e.g. for buildbot.')
116 parser.add_argument(
117 '--testing', action='store_true',
118- help='Same as --use-urandom --create-scripts --install-subunit.')
119+ help='Same as --feed-random --create-scripts --install-subunit.')
120
121=== added file 'lpsetup/subcommands/version.py'
122--- lpsetup/subcommands/version.py 1970-01-01 00:00:00 +0000
123+++ lpsetup/subcommands/version.py 2012-05-22 12:48:20 +0000
124@@ -0,0 +1,28 @@
125+#!/usr/bin/env python
126+# Copyright 2012 Canonical Ltd. This software is licensed under the
127+# GNU Affero General Public License version 3 (see the file LICENSE).
128+
129+"""Version subcommand: display lpsetup version."""
130+
131+__metaclass__ = type
132+__all__ = [
133+ 'SubCommand',
134+ ]
135+
136+import os
137+import sys
138+
139+from lpsetup import (
140+ argparser,
141+ get_version,
142+ )
143+
144+
145+class SubCommand(argparser.BaseSubCommand):
146+ """Display the software version."""
147+
148+ help = __doc__
149+
150+ def handle(self, namespace):
151+ app_name = os.path.basename(sys.argv[0])
152+ print '{0} v{1}'.format(app_name, get_version())
153
154=== added directory 'lpsetup/tests/subcommands'
155=== added file 'lpsetup/tests/subcommands/__init__.py'
156=== added file 'lpsetup/tests/subcommands/test_version.py'
157--- lpsetup/tests/subcommands/test_version.py 1970-01-01 00:00:00 +0000
158+++ lpsetup/tests/subcommands/test_version.py 2012-05-22 12:48:20 +0000
159@@ -0,0 +1,26 @@
160+#!/usr/bin/env python
161+# Copyright 2012 Canonical Ltd. This software is licensed under the
162+# GNU Affero General Public License version 3 (see the file LICENSE).
163+
164+"""Tests for the version sub command."""
165+
166+import unittest
167+
168+from lpsetup import get_version
169+from lpsetup.subcommands import version
170+from lpsetup.tests.utils import (
171+ capture_output,
172+ SubCommandTestMixin,
173+ )
174+
175+
176+class VersionTest(SubCommandTestMixin, unittest.TestCase):
177+
178+ sub_command_class = version.SubCommand
179+ sub_command_name = 'subcmd'
180+
181+ def test_sub_command(self):
182+ with capture_output() as output:
183+ self.parse_and_call_main()
184+ bits = output.getvalue().strip().split()
185+ self.assertEqual('v' + get_version(), bits[1])
186
187=== modified file 'lpsetup/tests/test_argparser.py'
188--- lpsetup/tests/test_argparser.py 2012-03-30 10:27:46 +0000
189+++ lpsetup/tests/test_argparser.py 2012-05-22 12:48:20 +0000
190@@ -12,6 +12,7 @@
191 from lpsetup.tests.utils import (
192 capture_error,
193 capture_output,
194+ SubCommandTestMixin,
195 )
196
197
198@@ -78,28 +79,6 @@
199 self.assertIn('unrecognized arguments: help', error.getvalue())
200
201
202-class SubCommandTestMixin(object):
203-
204- sub_command_class = examples.SubCommand
205- sub_command_name = 'subcmd'
206-
207- def setUp(self):
208- self.parser = argparser.ArgumentParser()
209- self.sub_command = self.parser.register_subcommand(
210- self.sub_command_name, self.sub_command_class)
211-
212- def parse_and_call_main(self, arguments=None):
213- args = [self.sub_command_name]
214- if arguments is not None:
215- args.extend(arguments.split())
216- namespace = self.parser.parse_args(args)
217- return namespace.main(namespace)
218-
219- def check_output(self, expected, output):
220- value = filter(None, output.getvalue().split('\n'))
221- self.assertSequenceEqual(expected, value)
222-
223-
224 class BaseSubCommandTest(SubCommandTestMixin, unittest.TestCase):
225
226 def set_validators(self, *args):
227
228=== modified file 'lpsetup/tests/test_handlers.py'
229--- lpsetup/tests/test_handlers.py 2012-05-15 09:05:55 +0000
230+++ lpsetup/tests/test_handlers.py 2012-05-22 12:48:20 +0000
231@@ -198,7 +198,7 @@
232 ctx = {
233 'create_scripts': True,
234 'install_subunit': False,
235- 'use_urandom': False,
236+ 'feed_random': False,
237 }
238
239 def test_true(self):
240
241=== modified file 'lpsetup/tests/utils.py'
242--- lpsetup/tests/utils.py 2012-03-15 14:17:10 +0000
243+++ lpsetup/tests/utils.py 2012-05-22 12:48:20 +0000
244@@ -15,6 +15,9 @@
245 from StringIO import StringIO
246 import sys
247
248+from lpsetup import argparser
249+from lpsetup.tests import examples
250+
251
252 @contextmanager
253 def capture(attr):
254@@ -29,3 +32,25 @@
255
256 capture_output = partial(capture, 'stdout')
257 capture_error = partial(capture, 'stderr')
258+
259+
260+class SubCommandTestMixin(object):
261+
262+ sub_command_class = examples.SubCommand
263+ sub_command_name = 'subcmd'
264+
265+ def setUp(self):
266+ self.parser = argparser.ArgumentParser()
267+ self.sub_command = self.parser.register_subcommand(
268+ self.sub_command_name, self.sub_command_class)
269+
270+ def parse_and_call_main(self, arguments=None):
271+ args = [self.sub_command_name]
272+ if arguments is not None:
273+ args.extend(arguments.split())
274+ namespace = self.parser.parse_args(args)
275+ return namespace.main(namespace)
276+
277+ def check_output(self, expected, output):
278+ value = filter(None, output.getvalue().split('\n'))
279+ self.assertSequenceEqual(expected, value)

Subscribers

People subscribed via source and target branches

to all changes: