Merge lp:~bac/lpsetup/host2target into lp:lpsetup

Proposed by Brad Crittenden
Status: Merged
Approved by: Brad Crittenden
Approved revision: 76
Merged at revision: 74
Proposed branch: lp:~bac/lpsetup/host2target
Merge into: lp:lpsetup
Diff against target: 514 lines (+77/-73)
9 files modified
README.rst (+1/-1)
commands.rst (+11/-11)
lpsetup/cli.py (+4/-4)
lpsetup/subcommands/init_target.py (+8/-8)
lpsetup/subcommands/initlxc.py (+14/-13)
lpsetup/subcommands/install_lxc.py (+5/-6)
lpsetup/tests/integration/test_init_target.py (+8/-8)
lpsetup/tests/subcommands/test_init_target.py (+24/-20)
lpsetup/tests/subcommands/test_smoke.py (+2/-2)
To merge this branch: bzr merge lp:~bac/lpsetup/host2target
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+119795@code.launchpad.net

Commit message

Change 'host' to 'target' everywhere to make it less confusing.

Description of the change

Change 'host' to 'target' everywhere to make it less confusing.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Self-review since it is mostly mechanical changes.

review: Approve (code)
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :

Attempt to merge into lp:lpsetup failed due to conflicts:

text conflict in lpsetup/subcommands/initlxc.py

Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
Download full text (9.9 KiB)

The attempt to merge lp:~bac/lpsetup/host2target into lp:lpsetup failed. Below is the output from the failed tests.

+ set -o errexit
++ grep -v distribute_setup.py
++ find . -name build -prune -o -name '*.py'
+ pyfiles='./setup.py
./lplxcip/tests/utils.py
./lplxcip/tests/__init__.py
./lplxcip/tests/test_lxcip.py
./lplxcip/tests/test_helpers.py
./lplxcip/tests/test_utils.py
./lplxcip/lxcip.py
./lpsetup/utils.py
./lpsetup/__init__.py
./lpsetup/handlers.py
./lpsetup/tests/utils.py
./lpsetup/tests/__init__.py
./lpsetup/tests/test_argparser.py
./lpsetup/tests/test_cli.py
./lpsetup/tests/test_handlers.py
./lpsetup/tests/subcommands/__init__.py
./lpsetup/tests/subcommands/test_version.py
./lpsetup/tests/subcommands/test_initrepo.py
./lpsetup/tests/subcommands/test_init_target.py
./lpsetup/tests/subcommands/test_smoke.py
./lpsetup/tests/integration/common.py
./lpsetup/tests/integration/test_install_lxc.py
./lpsetup/tests/integration/test_init_target.py
./lpsetup/tests/test_utils.py
./lpsetup/subcommands/__init__.py
./lpsetup/subcommands/install_lxc.py
./lpsetup/subcommands/initlxc.py
./lpsetup/subcommands/init_target.py
./lpsetup/subcommands/update.py
./lpsetup/subcommands/initrepo.py
./lpsetup/subcommands/finish_init_target.py
./lpsetup/subcommands/version.py
./lpsetup/exceptions.py
./lpsetup/argparser.py
./lpsetup/settings.py
./lpsetup/cli.py'
+ pocketlint ./setup.py ./lplxcip/tests/utils.py ./lplxcip/tests/__init__.py ./lplxcip/tests/test_lxcip.py ./lplxcip/tests/test_helpers.py ./lplxcip/tests/test_utils.py ./lplxcip/lxcip.py ./lpsetup/utils.py ./lpsetup/__init__.py ./lpsetup/handlers.py ./lpsetup/tests/utils.py ./lpsetup/tests/__init__.py ./lpsetup/tests/test_argparser.py ./lpsetup/tests/test_cli.py ./lpsetup/tests/test_handlers.py ./lpsetup/tests/subcommands/__init__.py ./lpsetup/tests/subcommands/test_version.py ./lpsetup/tests/subcommands/test_initrepo.py ./lpsetup/tests/subcommands/test_init_target.py ./lpsetup/tests/subcommands/test_smoke.py ./lpsetup/tests/integration/common.py ./lpsetup/tests/integration/test_install_lxc.py ./lpsetup/tests/integration/test_init_target.py ./lpsetup/tests/test_utils.py ./lpsetup/subcommands/__init__.py ./lpsetup/subcommands/install_lxc.py ./lpsetup/subcommands/initlxc.py ./lpsetup/subcommands/init_target.py ./lpsetup/subcommands/update.py ./lpsetup/subcommands/initrepo.py ./lpsetup/subcommands/finish_init_target.py ./lpsetup/subcommands/version.py ./lpsetup/exceptions.py ./lpsetup/argparser.py ./lpsetup/settings.py ./lpsetup/cli.py
+ pep8 --exclude=build ./setup.py ./lplxcip/tests/utils.py ./lplxcip/tests/__init__.py ./lplxcip/tests/test_lxcip.py ./lplxcip/tests/test_helpers.py ./lplxcip/tests/test_utils.py ./lplxcip/lxcip.py ./lpsetup/utils.py ./lpsetup/__init__.py ./lpsetup/handlers.py ./lpsetup/tests/utils.py ./lpsetup/tests/__init__.py ./lpsetup/tests/test_argparser.py ./lpsetup/tests/test_cli.py ./lpsetup/tests/test_handlers.py ./lpsetup/tests/subcommands/__init__.py ./lpsetup/tests/subcommands/test_version.py ./lpsetup/tests/subcommands/test_initrepo.py ./lpsetup/tests/subcommands/test_init_target.py ./lpsetup/tests/subcommands/test_smoke.py ./lpsetup/tests/integration/common.py ./lpsetup/tests/inte...

lp:~bac/lpsetup/host2target updated
76. By Brad Crittenden

Fixed merge problem

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README.rst'
--- README.rst 2012-07-30 18:56:59 +0000
+++ README.rst 2012-08-16 10:07:21 +0000
@@ -88,7 +88,7 @@
88long as you specify using the '-e' command line option. The tests88long as you specify using the '-e' command line option. The tests
89are in lpsetup/tests/integration.89are in lpsetup/tests/integration.
9090
91The first, *test_init_host.py*, only tests the *init-host* command but91The first, *test_init_target.py*, only tests the *init-target* command but
92goes no further. The second, *test_install_lxc.py*, tests92goes no further. The second, *test_install_lxc.py*, tests
93*install-lxc*. If this test is run against a local LXC environment,93*install-lxc*. If this test is run against a local LXC environment,
94some changes need are first required to the host machine where the94some changes need are first required to the host machine where the
9595
=== modified file 'commands.rst'
--- commands.rst 2012-07-19 17:48:40 +0000
+++ commands.rst 2012-08-16 10:07:21 +0000
@@ -6,7 +6,7 @@
66
7usage: lp-setup [-h]7usage: lp-setup [-h]
88
9 {finish-init-host,init-host,init-lxc,init-repo,install-lxc,update,version,help}9 {finish-init-target,init-target,init-lxc,init-repo,install-lxc,update,version,help}
10 ...10 ...
1111
12Create and update Launchpad development and testing environments.12Create and update Launchpad development and testing environments.
@@ -15,11 +15,11 @@
15 -h, --help show this help message and exit15 -h, --help show this help message and exit
1616
17subcommands:17subcommands:
18 {finish-init-host,init-host,init-lxc,init-repo,install-lxc,update,version,help}18 {finish-init-target,init-target,init-lxc,init-repo,install-lxc,update,version,help}
19 Each subcommand accepts --h or --help to describe it.19 Each subcommand accepts --h or --help to describe it.
20 finish-init-host Finish the initialization of a Launchpad development20 finish-init-target Finish the initialization of a Launchpad development
21 host.21 target.
22 init-host Prepare a machine to run Launchpad. May be an LXC22 init-target Prepare a machine to run Launchpad. May be an LXC
23 container or not.23 container or not.
24 init-lxc Create an LXC container suitable for later installing24 init-lxc Create an LXC container suitable for later installing
25 a Launchpad development environment.25 a Launchpad development environment.
@@ -69,14 +69,14 @@
6969
70Create an LXC container suitable for later installing a Launchpad70Create an LXC container suitable for later installing a Launchpad
71development environment. The `lpsetup` package is installed in the71development environment. The `lpsetup` package is installed in the
72container and `init-host` is called. The LXC container is shutdown at72container and `init-target` is called. The LXC container is shutdown at
73the end of the command.73the end of the command.
7474
75Run as root on the host machine.75Run as root on the host machine.
7676
7777
78init-host78init-target
79~~~~~~~~~79~~~~~~~~~~~
8080
81Prepare a machine to run Launchpad. It may be a host machine or an81Prepare a machine to run Launchpad. It may be a host machine or an
82LXC container. It installs the base packages, creates the specified82LXC container. It installs the base packages, creates the specified
@@ -108,8 +108,8 @@
108Run as the user in the Launchpad target, either a host machine or LXC108Run as the user in the Launchpad target, either a host machine or LXC
109container.109container.
110110
111finish-init-host111finish-init-target
112~~~~~~~~~~~~~~~~112~~~~~~~~~~~~~~~~~~
113113
114Finish the initialization of a Launchpad development host.114Finish the initialization of a Launchpad development host.
115115
@@ -118,7 +118,7 @@
118been retrieved and run as root.118been retrieved and run as root.
119119
120Run as root in the Launchpad target, either a host machine or LXC120Run as root in the Launchpad target, either a host machine or LXC
121container. Must be done after `init-host` and `init-repo` have121container. Must be done after `init-target` and `init-repo` have
122completed.122completed.
123123
124TODO: rename to finish-init-target124TODO: rename to finish-init-target
125125
=== modified file 'lpsetup/cli.py'
--- lpsetup/cli.py 2012-08-13 08:42:08 +0000
+++ lpsetup/cli.py 2012-08-16 10:07:21 +0000
@@ -19,8 +19,8 @@
19 exceptions,19 exceptions,
20 )20 )
21from lpsetup.subcommands import (21from lpsetup.subcommands import (
22 finish_inithost,22 finish_init_target,
23 inithost,23 init_target,
24 initlxc,24 initlxc,
25 initrepo,25 initrepo,
26 install_lxc,26 install_lxc,
@@ -31,8 +31,8 @@
3131
3232
33SUBCOMMANDS = [33SUBCOMMANDS = [
34 ('finish-init-host', finish_inithost.SubCommand()),34 ('finish-init-target', finish_init_target.SubCommand()),
35 ('init-host', inithost.SubCommand()),35 ('init-target', init_target.SubCommand()),
36 ('init-lxc', initlxc.SubCommand()),36 ('init-lxc', initlxc.SubCommand()),
37 ('init-repo', initrepo.SubCommand()),37 ('init-repo', initrepo.SubCommand()),
38 ('install-lxc', install_lxc.SubCommand()),38 ('install-lxc', install_lxc.SubCommand()),
3939
=== renamed file 'lpsetup/subcommands/finish_inithost.py' => 'lpsetup/subcommands/finish_init_target.py'
=== renamed file 'lpsetup/subcommands/inithost.py' => 'lpsetup/subcommands/init_target.py'
--- lpsetup/subcommands/inithost.py 2012-08-15 17:18:04 +0000
+++ lpsetup/subcommands/init_target.py 2012-08-16 10:07:21 +0000
@@ -2,7 +2,7 @@
2# Copyright 2012 Canonical Ltd. This software is licensed under the2# Copyright 2012 Canonical Ltd. This software is licensed under the
3# GNU Affero General Public License version 3 (see the file LICENSE).3# GNU Affero General Public License version 3 (see the file LICENSE).
44
5"""inithost subcommand: prepare a host machine to run Launchpad."""5"""init-target subcommand: prepare a target machine to run Launchpad."""
66
7__metaclass__ = type7__metaclass__ = type
8__all__ = [8__all__ = [
@@ -133,7 +133,7 @@
133133
134134
135def initialize_base(user):135def initialize_base(user):
136 """Perform base initialization shared by inithost and initlxc."""136 """Perform base initialization shared by init-target and init-lxc."""
137 # Install necessary deb packages. This requires Oneiric or later.137 # Install necessary deb packages. This requires Oneiric or later.
138 call('apt-get', 'update')138 call('apt-get', 'update')
139 apt_get_install(*BASE_PACKAGES, caller=call)139 apt_get_install(*BASE_PACKAGES, caller=call)
@@ -148,7 +148,7 @@
148148
149149
150def initialize(user):150def initialize(user):
151 """Initialize host machine."""151 """Initialize target machine."""
152 make_version_dir()152 make_version_dir()
153 initialize_base(user)153 initialize_base(user)
154 with su(user):154 with su(user):
@@ -159,7 +159,7 @@
159 for module in LP_APACHE_MODULES.split():159 for module in LP_APACHE_MODULES.split():
160 call('a2enmod', module)160 call('a2enmod', module)
161161
162 # The user must be added to sudoers if inithost is run in a container162 # The user must be added to sudoers if init-target is run in a container
163 # and we are running the developer story.163 # and we are running the developer story.
164 # XXX 2012-07-18 frankban: add the developer/testing check.164 # XXX 2012-07-18 frankban: add the developer/testing check.
165 if running_in_container():165 if running_in_container():
@@ -188,11 +188,11 @@
188188
189 This is a separate step for several reasons::189 This is a separate step for several reasons::
190190
191 - It is directly called by *initlxc* as one of its first steps.191 - It is directly called by *init-lxc* as one of its first steps.
192 Note that *initlxc* needs the user's `.ssh` dir to be set up192 Note that *init-lxc* needs the user's `.ssh` dir to be set up
193 to be able to connect to the container.193 to be able to connect to the container.
194 - *initlxc* should be able to skip this step when re-executing194 - *init-lxc* should be able to skip this step when re-executing
195 *inithost* from inside the container, to avoid setting up the195 *init-target* from inside the container, to avoid setting up the
196 user home two times. Note: the user home is bind mounted by lxc.196 user home two times. Note: the user home is bind mounted by lxc.
197 """197 """
198 with su(user) as env:198 with su(user) as env:
199199
=== modified file 'lpsetup/subcommands/initlxc.py'
--- lpsetup/subcommands/initlxc.py 2012-08-14 15:10:12 +0000
+++ lpsetup/subcommands/initlxc.py 2012-08-16 10:07:21 +0000
@@ -2,7 +2,7 @@
2# Copyright 2012 Canonical Ltd. This software is licensed under the2# Copyright 2012 Canonical Ltd. This software is licensed under the
3# GNU Affero General Public License version 3 (see the file LICENSE).3# GNU Affero General Public License version 3 (see the file LICENSE).
44
5"""initlxc subcommand: prepare an LXC container to run Launchpad.5"""init-lxc subcommand: prepare an LXC container to run Launchpad.
66
7Run as root on the host machine to create an LXC container that can later be7Run as root on the host machine to create an LXC container that can later be
8used to install a Launchpad development environment.8used to install a Launchpad development environment.
@@ -11,7 +11,7 @@
11__metaclass__ = type11__metaclass__ = type
12__all__ = [12__all__ = [
13 'create_lxc',13 'create_lxc',
14 'inithost_in_lxc',14 'init_target_in_lxc',
15 'initialize',15 'initialize',
16 'install_lpsetup_in_lxc',16 'install_lpsetup_in_lxc',
17 'start_lxc',17 'start_lxc',
@@ -45,7 +45,7 @@
45 LXC_PACKAGES,45 LXC_PACKAGES,
46 PY26_PACKAGES,46 PY26_PACKAGES,
47 )47 )
48from lpsetup.subcommands import inithost48from lpsetup.subcommands import init_target
49from lpsetup.utils import (49from lpsetup.utils import (
50 call,50 call,
51 get_container_path,51 get_container_path,
@@ -60,13 +60,13 @@
6060
61def initialize(user, install_haveged):61def initialize(user, install_haveged):
62 """Initialize the LXC host."""62 """Initialize the LXC host."""
63 inithost.initialize_base(user)63 init_target.initialize_base(user)
64 if install_haveged:64 if install_haveged:
65 # haveged is used to fill /dev/random, avoiding65 # haveged is used to fill /dev/random, avoiding
66 # entropy exhaustion during automated parallel tests.66 # entropy exhaustion during automated parallel tests.
67 apt_get_install('haveged', caller=call)67 apt_get_install('haveged', caller=call)
6868
69initialize.description = inithost.initialize_base.description + """If \69initialize.description = init_target.initialize_base.description + """If \
70 requested, install haveged in order to fill /dev/random, avoiding \70 requested, install haveged in order to fill /dev/random, avoiding \
71 entropy exhaustion during automated parallel tests.71 entropy exhaustion during automated parallel tests.
72"""72"""
@@ -207,16 +207,16 @@
207install_lpsetup_in_lxc.description = None207install_lpsetup_in_lxc.description = None
208208
209209
210def inithost_in_lxc(lxc_name, ssh_key_path, user, email, full_name, lpuser,210def init_target_in_lxc(lxc_name, ssh_key_path, user, email, full_name, lpuser,
211 ssh_key_name, home_dir):211 ssh_key_name, home_dir):
212 """Prepare the Launchpad environment inside an LXC."""212 """Prepare the Launchpad environment inside an LXC."""
213 # Use ssh to call this script from inside the container.213 # Use ssh to call this script from inside the container.
214 args = ['init-host', '--yes', '-u', user, '-E', email, '-f', full_name,214 args = ['init-target', '--yes', '-u', user, '-E', email, '-f', full_name,
215 '-l', lpuser, '-S', ssh_key_name, '--skip-steps', 'setup_home']215 '-l', lpuser, '-S', ssh_key_name, '--skip-steps', 'setup_home']
216 cmd = this_command(home_dir, args)216 cmd = this_command(home_dir, args)
217 ssh(lxc_name, cmd, key=ssh_key_path)217 ssh(lxc_name, cmd, key=ssh_key_path)
218218
219inithost_in_lxc.description = 'Initialize the LXC instance $lxc_name.\n'219init_target_in_lxc.description = 'Initialize the LXC instance $lxc_name.\n'
220220
221221
222def stop_lxc(lxc_name, ssh_key_path):222def stop_lxc(lxc_name, ssh_key_path):
@@ -228,7 +228,7 @@
228stop_lxc.description = 'Stop the LXC instance $lxc_name.\n'228stop_lxc.description = 'Stop the LXC instance $lxc_name.\n'
229229
230230
231class SubCommand(inithost.SubCommand):231class SubCommand(init_target.SubCommand):
232 """Create an LXC container suitable for later installing a Launchpad232 """Create an LXC container suitable for later installing a Launchpad
233 development environment.233 development environment.
234 """234 """
@@ -242,8 +242,8 @@
242 install_lpsetup_in_lxc,242 install_lpsetup_in_lxc,
243 ['lxc_name', 'ssh_key_path', 'lxc_os', 'user', 'home_dir',243 ['lxc_name', 'ssh_key_path', 'lxc_os', 'user', 'home_dir',
244 'lpsetup_branch'])244 'lpsetup_branch'])
245 inithost_in_lxc_step = (245 init_target_in_lxc_step = (
246 inithost_in_lxc,246 init_target_in_lxc,
247 ['lxc_name', 'ssh_key_path', 'user', 'email', 'full_name', 'lpuser',247 ['lxc_name', 'ssh_key_path', 'user', 'email', 'full_name', 'lpuser',
248 'ssh_key_name', 'home_dir'])248 'ssh_key_name', 'home_dir'])
249 stop_lxc_step = (249 stop_lxc_step = (
@@ -252,13 +252,14 @@
252252
253 base_steps = (253 base_steps = (
254 (initialize, ['user', 'install_haveged']),254 (initialize, ['user', 'install_haveged']),
255 inithost.SubCommand.setup_home_step,255 init_target.SubCommand.setup_home_step,
256 create_lxc_step,256 create_lxc_step,
257 start_lxc_step,257 start_lxc_step,
258 wait_for_lxc_step,258 wait_for_lxc_step,
259 install_lpsetup_in_lxc_step,259 install_lpsetup_in_lxc_step,
260 init_target_in_lxc_step,
260 )261 )
261 steps = base_steps + (inithost_in_lxc_step, stop_lxc_step)262 steps = base_steps + (stop_lxc_step, )
262263
263 help = __doc__264 help = __doc__
264 root_required = True265 root_required = True
265266
=== modified file 'lpsetup/subcommands/install_lxc.py'
--- lpsetup/subcommands/install_lxc.py 2012-08-15 17:27:24 +0000
+++ lpsetup/subcommands/install_lxc.py 2012-08-16 10:07:21 +0000
@@ -7,7 +7,7 @@
7__metaclass__ = type7__metaclass__ = type
8__all__ = [8__all__ = [
9 'create_scripts',9 'create_scripts',
10 'finish_inithost_in_lxc',10 'finish_init_target_in_lxc',
11 'init_repo_in_lxc',11 'init_repo_in_lxc',
12 'SubCommand',12 'SubCommand',
13 'update_in_lxc',13 'update_in_lxc',
@@ -127,12 +127,12 @@
127 update.update_tree.description)127 update.update_tree.description)
128128
129129
130def finish_inithost_in_lxc(130def finish_init_target_in_lxc(
131 lxc_name, ssh_key_path, home_dir, user, target_dir):131 lxc_name, ssh_key_path, home_dir, user, target_dir):
132 args = ['finish-init-host', target_dir, '--user', user, '--yes']132 args = ['finish-init-target', target_dir, '--user', user, '--yes']
133 cmd_in_lxc(lxc_name, ssh_key_path, home_dir, args)133 cmd_in_lxc(lxc_name, ssh_key_path, home_dir, args)
134134
135finish_inithost_in_lxc.description = """Set up the database, make and \135finish_init_target_in_lxc.description = """Set up the database, make and \
136 install Launchpad inside the LXC instance $lxc_name.136 install Launchpad inside the LXC instance $lxc_name.
137"""137"""
138138
@@ -145,14 +145,13 @@
145 (create_scripts, ['lxc_name', 'ssh_key_path', 'user'],145 (create_scripts, ['lxc_name', 'ssh_key_path', 'user'],
146 lambda namespace: namespace.create_scripts),146 lambda namespace: namespace.create_scripts),
147 # Run inside the container:147 # Run inside the container:
148 initlxc.SubCommand.inithost_in_lxc_step,
149 (init_repo_in_lxc,148 (init_repo_in_lxc,
150 ['lxc_name', 'ssh_key_path', 'home_dir', 'user', 'source', 'use_http',149 ['lxc_name', 'ssh_key_path', 'home_dir', 'user', 'source', 'use_http',
151 'branch_name', 'checkout_name', 'repository', 'no_checkout']),150 'branch_name', 'checkout_name', 'repository', 'no_checkout']),
152 (update_in_lxc,151 (update_in_lxc,
153 ['lxc_name', 'ssh_key_path', 'home_dir', 'user', 'external_path',152 ['lxc_name', 'ssh_key_path', 'home_dir', 'user', 'external_path',
154 'target_dir', 'lp_source_deps', 'use_http']),153 'target_dir', 'lp_source_deps', 'use_http']),
155 (finish_inithost_in_lxc,154 (finish_init_target_in_lxc,
156 ['lxc_name', 'ssh_key_path', 'home_dir', 'user', 'target_dir']),155 ['lxc_name', 'ssh_key_path', 'home_dir', 'user', 'target_dir']),
157 # Run on host:156 # Run on host:
158 initlxc.SubCommand.stop_lxc_step,157 initlxc.SubCommand.stop_lxc_step,
159158
=== renamed file 'lpsetup/tests/integration/test_init_host.py' => 'lpsetup/tests/integration/test_init_target.py'
--- lpsetup/tests/integration/test_init_host.py 2012-07-27 08:07:45 +0000
+++ lpsetup/tests/integration/test_init_target.py 2012-08-16 10:07:21 +0000
@@ -2,7 +2,7 @@
2# Copyright 2012 Canonical Ltd. This software is licensed under the2# Copyright 2012 Canonical Ltd. This software is licensed under the
3# GNU Affero General Public License version 3 (see the file LICENSE).3# GNU Affero General Public License version 3 (see the file LICENSE).
44
5"""A simple, integration test of init-host.5"""A simple, integration test of init-target.
66
7Tests initialization of the host without init-lxc in order to demonstrate that7Tests initialization of the host without init-lxc in order to demonstrate that
8it can be run in isolation, as part of a non-LXC environment.8it can be run in isolation, as part of a non-LXC environment.
@@ -13,22 +13,22 @@
13from common import IntegrationTestBase13from common import IntegrationTestBase
1414
1515
16class InitHostTest(IntegrationTestBase):16class InitTargetTest(IntegrationTestBase):
1717
18 test_type = 'init-host tests'18 test_type = 'init-target tests'
19 default_juju_env = 'lpsetup-testing-ec2'19 default_juju_env = 'lpsetup-testing-ec2'
20 juju_target = 'ubuntu/0'20 juju_target = 'ubuntu/0'
2121
22 def do_test(self):22 def do_test(self):
23 """Run an integration test that only address host issues.23 """Run an integration test that only address target issues.
2424
25 Can be run on EC2 or LXC as the host machine.25 Can be run on EC2 or LXC as the target machine.
26 """26 """
27 # Since the most common scenario is to have bzr whoami setup, we do27 # Since the most common scenario is to have bzr whoami setup, we do
28 # that instead of providing the arguments directly to lpsetup.28 # that instead of providing the arguments directly to lpsetup.
29 super(InitHostTest, self).do_test()29 super(InitTargetTest, self).do_test()
30 self.on_remote('cd lpsetup; ./lp-setup init-host --yes')30 self.on_remote('cd lpsetup; ./lp-setup init-target --yes')
3131
3232
33if __name__ == '__main__':33if __name__ == '__main__':
34 sys.exit(InitHostTest().run())34 sys.exit(InitTargetTest().run())
3535
=== renamed file 'lpsetup/tests/subcommands/test_inithost.py' => 'lpsetup/tests/subcommands/test_init_target.py'
--- lpsetup/tests/subcommands/test_inithost.py 2012-08-14 12:07:46 +0000
+++ lpsetup/tests/subcommands/test_init_target.py 2012-08-16 10:07:21 +0000
@@ -2,7 +2,7 @@
2# Copyright 2012 Canonical Ltd. This software is licensed under the2# Copyright 2012 Canonical Ltd. This software is licensed under the
3# GNU Affero General Public License version 3 (see the file LICENSE).3# GNU Affero General Public License version 3 (see the file LICENSE).
44
5"""Tests for the inithost subcommand."""5"""Tests for the init-target subcommand."""
66
7import os7import os
8import shutil8import shutil
@@ -10,12 +10,12 @@
10import tempfile10import tempfile
11import unittest11import unittest
1212
13from lpsetup.subcommands import inithost13from lpsetup.subcommands import init_target
14from lpsetup.tests.utils import get_random_string14from lpsetup.tests.utils import get_random_string
1515
1616
17class WriteFileContentsTestCase(unittest.TestCase):17class WriteFileContentsTestCase(unittest.TestCase):
18 """Tests for inithost.write_file_contents()."""18 """Tests for init_target.write_file_contents()."""
1919
20 def setUp(self):20 def setUp(self):
21 temp_file = tempfile.NamedTemporaryFile()21 temp_file = tempfile.NamedTemporaryFile()
@@ -25,11 +25,12 @@
25 self.temp_filename = temp_file.name25 self.temp_filename = temp_file.name
2626
27 def test_write_file_contents_writes_file_contents(self):27 def test_write_file_contents_writes_file_contents(self):
28 # inithost.write_file_contents writes the supplied file contents28 # init_target.write_file_contents writes the supplied file contents
29 # to a given file using the mode provided and chmods the file to29 # to a given file using the mode provided and chmods the file to
30 # 0644 for the current user.30 # 0644 for the current user.
31 self.addCleanup(os.remove, self.temp_filename)31 self.addCleanup(os.remove, self.temp_filename)
32 inithost.write_file_contents(self.temp_filename, 'Hello, world!', 'w')32 init_target.write_file_contents(
33 self.temp_filename, 'Hello, world!', 'w')
33 with open(self.temp_filename, 'r') as the_file:34 with open(self.temp_filename, 'r') as the_file:
34 contents = the_file.read()35 contents = the_file.read()
35 self.assertEqual('Hello, world!', contents)36 self.assertEqual('Hello, world!', contents)
@@ -47,29 +48,32 @@
47 # contents differ from `contents`, write_file_contents() raises an48 # contents differ from `contents`, write_file_contents() raises an
48 # Exception.49 # Exception.
49 self.addCleanup(os.remove, self.temp_filename)50 self.addCleanup(os.remove, self.temp_filename)
50 inithost.write_file_contents(self.temp_filename, 'Hello, world!', 'w')51 init_target.write_file_contents(
52 self.temp_filename, 'Hello, world!', 'w')
51 self.assertRaises(53 self.assertRaises(
52 Exception, inithost.write_file_contents, self.temp_filename,54 Exception, init_target.write_file_contents, self.temp_filename,
53 'Hello again!', 'w')55 'Hello again!', 'w')
5456
55 def test_write_file_contents_returns_if_file_contents_dont_change(self):57 def test_write_file_contents_returns_if_file_contents_dont_change(self):
56 # If the existing file's contents don't differ from `contents`,58 # If the existing file's contents don't differ from `contents`,
57 # write_file_contents() will simply return.59 # write_file_contents() will simply return.
58 self.addCleanup(os.remove, self.temp_filename)60 self.addCleanup(os.remove, self.temp_filename)
59 inithost.write_file_contents(self.temp_filename, 'Hello, world!', 'w')61 init_target.write_file_contents(
62 self.temp_filename, 'Hello, world!', 'w')
60 # This second call shouldn't raise an exception.63 # This second call shouldn't raise an exception.
61 inithost.write_file_contents(self.temp_filename, 'Hello, world!', 'w')64 init_target.write_file_contents(
65 self.temp_filename, 'Hello, world!', 'w')
6266
63 def test_write_file_contents_accepts_modes_a_or_w(self):67 def test_write_file_contents_accepts_modes_a_or_w(self):
64 # Passing a `mode` other than "a" or "w" to write_file_contents()68 # Passing a `mode` other than "a" or "w" to write_file_contents()
65 # will cause an Exception.69 # will cause an Exception.
66 self.assertRaises(70 self.assertRaises(
67 AssertionError, inithost.write_file_contents,71 AssertionError, init_target.write_file_contents,
68 '/tmp/foo', 'Hello, world!', 'a+')72 '/tmp/foo', 'Hello, world!', 'a+')
6973
7074
71class SetupSSHTest(unittest.TestCase):75class SetupSSHTest(unittest.TestCase):
72 """Tests for inithost.setup_ssh()."""76 """Tests for init_target.setup_ssh()."""
7377
74 def setUp(self):78 def setUp(self):
75 temp_file = tempfile.NamedTemporaryFile()79 temp_file = tempfile.NamedTemporaryFile()
@@ -82,14 +86,14 @@
8286
83 def test_setup_ssh_generates_keys_if_not_present(self):87 def test_setup_ssh_generates_keys_if_not_present(self):
84 # If SSH keys do not exist, the function will generate some.88 # If SSH keys do not exist, the function will generate some.
85 inithost.setup_ssh(self.ssh_dir, False, self.temp_filename)89 init_target.setup_ssh(self.ssh_dir, False, self.temp_filename)
86 self.assertTrue(os.path.exists(self.temp_filename))90 self.assertTrue(os.path.exists(self.temp_filename))
87 self.assertTrue(os.path.exists(self.temp_filename + '.pub'))91 self.assertTrue(os.path.exists(self.temp_filename + '.pub'))
8892
89 def test_setup_ssh_generates_authorized_keys(self):93 def test_setup_ssh_generates_authorized_keys(self):
90 # setup_ssh() also generates an authorized_keys file containing94 # setup_ssh() also generates an authorized_keys file containing
91 # the public key.95 # the public key.
92 inithost.setup_ssh(self.ssh_dir, False, self.temp_filename)96 init_target.setup_ssh(self.ssh_dir, False, self.temp_filename)
93 authorized_keys = os.path.join(self.ssh_dir, 'authorized_keys')97 authorized_keys = os.path.join(self.ssh_dir, 'authorized_keys')
94 self.assertTrue(os.path.exists(authorized_keys))98 self.assertTrue(os.path.exists(authorized_keys))
95 public_key = open(self.temp_filename + '.pub').read()99 public_key = open(self.temp_filename + '.pub').read()
@@ -98,7 +102,7 @@
98 def test_setup_ssh_generates_known_hosts(self):102 def test_setup_ssh_generates_known_hosts(self):
99 # setup_ssh() also generates a `known_host` file containing103 # setup_ssh() also generates a `known_host` file containing
100 # 'bazaar.launchpad.net'.104 # 'bazaar.launchpad.net'.
101 inithost.setup_ssh(self.ssh_dir, False, self.temp_filename)105 init_target.setup_ssh(self.ssh_dir, False, self.temp_filename)
102 known_hosts = os.path.join(self.ssh_dir, 'known_hosts')106 known_hosts = os.path.join(self.ssh_dir, 'known_hosts')
103 self.assertTrue(os.path.exists(known_hosts))107 self.assertTrue(os.path.exists(known_hosts))
104 self.assertIn('bazaar.launchpad.net', open(known_hosts).read())108 self.assertIn('bazaar.launchpad.net', open(known_hosts).read())
@@ -107,7 +111,7 @@
107 # If the ssh_dir passed to setup_ssh() doesn't exist, it111 # If the ssh_dir passed to setup_ssh() doesn't exist, it
108 # will be created.112 # will be created.
109 shutil.rmtree(self.ssh_dir)113 shutil.rmtree(self.ssh_dir)
110 inithost.setup_ssh(self.ssh_dir, False, self.temp_filename)114 init_target.setup_ssh(self.ssh_dir, False, self.temp_filename)
111 self.assertTrue(os.path.exists(self.ssh_dir))115 self.assertTrue(os.path.exists(self.ssh_dir))
112 self.assertTrue(os.path.isdir(self.ssh_dir))116 self.assertTrue(os.path.isdir(self.ssh_dir))
113117
@@ -123,14 +127,14 @@
123127
124 def test_version_dir_creation(self):128 def test_version_dir_creation(self):
125 # If the version path does not exist, it is created.129 # If the version path does not exist, it is created.
126 inithost.make_version_dir(mkdirs=self.mkdirs)130 init_target.make_version_dir(mkdirs=self.mkdirs)
127 self.assertIn(inithost.get_version_path(), self.directories_made)131 self.assertIn(init_target.get_version_path(), self.directories_made)
128132
129 def test_originals_dir_creation(self):133 def test_originals_dir_creation(self):
130 # If the version path contains an "originals" directory for backups of134 # If the version path contains an "originals" directory for backups of
131 # files that we modify.135 # files that we modify.
132 inithost.make_version_dir(mkdirs=self.mkdirs)136 init_target.make_version_dir(mkdirs=self.mkdirs)
133 self.assertIn(inithost.get_version_path(), self.directories_made)137 self.assertIn(init_target.get_version_path(), self.directories_made)
134138
135139
136def create(filename, contents=None):140def create(filename, contents=None):
@@ -156,7 +160,7 @@
156 destination_dir = lambda: self.tempdir160 destination_dir = lambda: self.tempdir
157 contents = get_random_string()161 contents = get_random_string()
158 create(source, contents)162 create(source, contents)
159 inithost.make_backup(source, destination_dir)163 init_target.make_backup(source, destination_dir)
160 get_backup_path = destination_dir() + os.path.sep + source164 get_backup_path = destination_dir() + os.path.sep + source
161 self.assertTrue(os.path.exists(get_backup_path))165 self.assertTrue(os.path.exists(get_backup_path))
162 self.assertEqual(file(get_backup_path).read(), contents)166 self.assertEqual(file(get_backup_path).read(), contents)
163167
=== modified file 'lpsetup/tests/subcommands/test_smoke.py'
--- lpsetup/tests/subcommands/test_smoke.py 2012-08-10 08:34:16 +0000
+++ lpsetup/tests/subcommands/test_smoke.py 2012-08-16 10:07:21 +0000
@@ -27,8 +27,8 @@
27 # and verify that a non-error exit code is returned.27 # and verify that a non-error exit code is returned.
28 required_args = ['-f', 'Example User', '-E', 'email@example.com']28 required_args = ['-f', 'Example User', '-E', 'email@example.com']
29 name_args_map = {29 name_args_map = {
30 'finish-init-host': [],30 'finish-init-target': [],
31 'init-host': required_args,31 'init-target': required_args,
32 'init-lxc': required_args,32 'init-lxc': required_args,
33 'init-repo': [],33 'init-repo': [],
34 'install-lxc': required_args,34 'install-lxc': required_args,

Subscribers

People subscribed via source and target branches