Merge lp:~jimbaker/pyjuju/env-origin into lp:pyjuju
- env-origin
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Gustavo Niemeyer |
Approved revision: | 380 |
Merged at revision: | 382 |
Proposed branch: | lp:~jimbaker/pyjuju/env-origin |
Merge into: | lp:pyjuju |
Diff against target: |
608 lines (+337/-27) 19 files modified
docs/source/provider-configuration-ec2.rst (+9/-3) juju/providers/common/cloudinit.py (+78/-2) juju/providers/common/launch.py (+9/-2) juju/providers/common/tests/data/cloud_init_bootstrap (+0/-2) juju/providers/common/tests/data/cloud_init_bootstrap_zookeepers (+0/-2) juju/providers/common/tests/data/cloud_init_branch_trunk (+17/-0) juju/providers/common/tests/data/cloud_init_normal (+0/-2) juju/providers/common/tests/data/cloud_init_ppa (+15/-0) juju/providers/common/tests/test_cloudinit.py (+109/-3) juju/providers/ec2/tests/common.py (+1/-0) juju/providers/ec2/tests/data/bootstrap_cloud_init (+0/-2) juju/providers/ec2/tests/data/launch_cloud_init (+0/-2) juju/providers/ec2/tests/data/launch_cloud_init_branch (+20/-0) juju/providers/ec2/tests/data/launch_cloud_init_ppa (+15/-0) juju/providers/ec2/tests/test_bootstrap.py (+1/-0) juju/providers/ec2/tests/test_launch.py (+60/-2) juju/providers/orchestra/tests/common.py (+3/-1) juju/providers/orchestra/tests/data/bootstrap_user_data (+0/-2) juju/providers/orchestra/tests/data/launch_user_data (+0/-2) |
To merge this branch: | bzr merge lp:~jimbaker/pyjuju/env-origin |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gustavo Niemeyer | Approve | ||
William Reade (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
Implements optional environment settings juju-origin (which replaces juju-branch).
Does not implement juju-version or support for deb repositories, per attached bug.
Functionally tested for not setting juju-origin, setting it to the standard PPA (the only one supported now), and LP branches.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
William Reade (fwereade) wrote : | # |
[0]
+ :type branch: str or None
two of these, should be "origin" and "version" instead of "branch"
[1]
+ version=
Won't that lead to version being "None" rather than None? If so, maybe add a test for that path.
Otherwise looks very nice, +1.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gustavo Niemeyer (niemeyer) wrote : | # |
[6]
+ PPA (use a `ppa:` prefix, eg `ppa:juju/pkgs`). Otherwise, the
+ utilized source will be based on the machine running the
+ bootstrap command (distribution, PPA, or branch).
s/eg/e.g./
In the following sentence, please use this wording:
Otherwise, juju will attempt to detect the correct origin based on
its run location and the installed juju package.
Also this should be fixed according to the rest of this review.
[7]
+ def _parse_policy(self, output):
(...)
+ def get_default_
(...)
Neither of these methods seem to need any information from "self",
which means they are actually independent functions rather than
methods.
[8]
+ if k != "juju":
+ # Sanity check: no record at all, the only possibility is that
+ # this being run as a branch
+ return "lp:juju"
+ for k, v in parse:
+ if k == "Installed" and v == "(none)":
+ return _PPA
+ if k == "Version table":
+ break
+ for _, version_info in parse:
+ if "ppa.launchpad.net" in version_info:
+ return _PPA
As we talked yesterday online, all of this logic is idempotent, and should
be part of a single function, called parse_juju_
and not part of the same function that interacts with the system (calling
"apt-cache policy juju").
[9]
+cat <<EOF
+juju:
+ Installed: (none)
+ Candidate: good-magic-1.0
+ Version table:
+ *** good-magic-1.0
+ 500 http://
+ 100 /var/lib/
+EOF
This is testing the idempotent parse_juju_
data inside the test file, and test the function trivially:
def test_foo(self):
origin, source = parse_juju_
self.assertEqu
self.assertEqu
It's really that simple! :-)
Kill most of these apt-cache dummies, please. You only need one test
of these, to ensure that the system interaction is really working as
it should. All the variations should be tested in the above fashion.
[10]
+ elif origin.
+ cloud_init.
This is bogus. This should be `if origin == "ppa":`, otherwise you're
promising something and delivering something else. Please fix the
branch and documentation.
[11]
+class OriginPolicyTes
+
+ def setup_origin_
(...)
+class EC2MachineLaunc
+ OriginPolicyTes
Ouch!
Please drop the mixin.. this is a single simple function,
so let's handle it as such.
[12]
--- juju/providers/
The number of these files and the way we copy them blindly on every
minor detail we want to test is pretty sad. That's fine for this
branch, but it'd be awesome to figure a better way to test this in
the future.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gustavo Niemeyer (niemeyer) wrote : | # |
[13]
+ juju-origin:
+ The origin of juju deployed to machines within an environment
+ is set by this option. This option can be set to a bzr branch
+ pushed to Launchpad (use a `lp:` prefix, e.g., `lp:juju`); to
+ the PPA by using `ppa`; or to the juju distribution by using
+ `distro`. If this option cannot be parsed, the distribution is
+ used.
This sentence is not reading correctly in a few ways (e.g. the
juju _origin_ is not really deployed, and there's no such thing
as a juju distribution.. it's the Ubuntu distribution).
Please use this:
juju-origin:
Defines where juju should be obtained for installing in
machines. Can be set to a "lp..." branch url, to "ppa" for
getting packages from the official juju PPA, or to "distro"
for using packages from the official Ubuntu repositories.
[14]
Jim, please read this excerpt from our conversation again, *carefully*:
<niemeyer> 1) Grab the installed version from the "Installed:" line
<niemeyer> 2) If this is "(none)" return "branch"
<niemeyer> 3) Otherwise, store the version in a variable, and keep parsing
<niemeyer> 4) Find the version table, and find the installed version
<niemeyer> 5) For each line in the given version, if it contains "ppa.launchpad.
<niemeyer> 6) If you reach the end of the installed version, return "distro"
Compare to what is in the branch right now.
[15]
+ if k == "Installed" and v == "(none)":
+ return "ppa", None
Compare with the summary above.
If there's no juju package installed in the system, it means the
user is not using the ppa.
[16]
+ for _, version_info in parse:
+ if "ppa.launchpad.net" in version_info:
+ return "ppa", None
Compare with the summary above.
Which version is this? The existence of _any_ version that comes from
a PPA in the apt cache is not an indication that the _installed_
version comes from a PPA. The indication that it comes from _a_ ppa
is not an indication that it comes from _our_ ppa either.
[17]
+ def test_distro_
+ data = (
+ "juju:\n"
+ " Installed: (none)\n"
+ " Candidate: good-magic-1.0\n"
Much better, thank you.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Baker (jimbaker) wrote : | # |
I do not see my reply that I emailed to the lp gateway last night, so I'm reposting:
I have made the desired changes, merged trunk, and retested against EC2 for
the various combinations (other than distro, of course).
Please note that some of the branches that were recently merged into trunk
have broken it, as indicated here: http://
remerge trunk as soon as that's fixed.
- Jim
On Wed, Sep 28, 2011 at 7:18 PM, Gustavo Niemeyer <email address hidden>wrote:
> Review: Needs Fixing
>
> [13]
>
> + juju-origin:
> + The origin of juju deployed to machines within an environment
> + is set by this option. This option can be set to a bzr branch
> + pushed to Launchpad (use a `lp:` prefix, e.g., `lp:juju`); to
> + the PPA by using `ppa`; or to the juju distribution by using
> + `distro`. If this option cannot be parsed, the distribution is
> + used.
>
> This sentence is not reading correctly in a few ways (e.g. the
> juju _origin_ is not really deployed, and there's no such thing
> as a juju distribution.. it's the Ubuntu distribution).
>
> Please use this:
>
> juju-origin:
> Defines where juju should be obtained for installing in
> machines. Can be set to a "lp..." branch url, to "ppa" for
> getting packages from the official juju PPA, or to "distro"
> for using packages from the official Ubuntu repositories.
>
>
Used this text as suggested.
>
> [14]
>
> Jim, please read this excerpt from our conversation again, *carefully*:
>
> <niemeyer> 1) Grab the installed version from the "Installed:" line
> <niemeyer> 2) If this is "(none)" return "branch"
> <niemeyer> 3) Otherwise, store the version in a variable, and keep parsing
> <niemeyer> 4) Find the version table, and find the installed version
> <niemeyer> 5) For each line in the given version, if it contains "
> ppa.launchpad.
> <niemeyer> 6) If you reach the end of the installed version, return
> "distro"
>
> Compare to what is in the branch right now.
>
>
> [15]
>
> + if k == "Installed" and v == "(none)":
> + return "ppa", None
>
> Compare with the summary above.
>
> If there's no juju package installed in the system, it means the
> user is not using the ppa.
>
Changed the logic above and the impacted test
>
>
> [16]
>
> + for _, version_info in parse:
> + if "ppa.launchpad.net" in version_info:
> + return "ppa", None
>
> Compare with the summary above.
>
> Which version is this? The existence of _any_ version that comes from
> a PPA in the apt cache is not an indication that the _installed_
> version comes from a PPA. The indication that it comes from _a_ ppa
> is not an indication that it comes from _our_ ppa either.
>
>
Got it. It's now using the precise test as you specified earlier. Sorry
about that.
>
> [17]
>
> + def test_distro_
> + data = (
> + "juju:\n"
> + " Installed: (none)\n"
> + " Candidate: good-magic-1.0\n"
>
> Much better, thank you.
>
>
Thanks!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gustavo Niemeyer (niemeyer) wrote : | # |
<jimbaker> niemeyer, hi
<niemeyer> jimbaker: Hi
<niemeyer> jimbaker: Please re-read points 3, 4 and 5
<niemeyer> jimbaker: and compare to the implementation
<jimbaker> niemeyer, ok
<niemeyer> jimbaker: Is there anything missing there?
<niemeyer> jimbaker: Maybe I'm just missing.. where's that: 3) Otherwise, store the version in a variable, and keep parsing
<jimbaker> niemeyer, #3 - python-txzookeeper dependency is no longer relevant; #4, it uses the original implementation; #5, there is no attempt to test deb repositories, since they are no longer supported
<niemeyer> jimbaker: 4) Find the version table, and find the installed version
<niemeyer> ?
* ejat has quit (Remote host closed the connection)
<jimbaker> niemeyer, ok, i'm referring to the review points. you are referring to a list from irc
<niemeyer> jimbaker: yeah
<jimbaker> looking at that now
<jimbaker> niemeyer, ok, i believe what you are saying here is that 6) refers to the installed version, which was stored earlier in 3), is that correct?
<niemeyer> 1) Grab the installed version from the "Installed:" line
<niemeyer> 2) If this is "(none)" return "branch"
<niemeyer> 3) Otherwise, store the version in a variable, and keep parsing
<niemeyer> 4) Find the version table, and find the installed version
<niemeyer> jimbaker: Is there any ambiguity here?
<jimbaker> niemeyer, correct, there is no ambiguity. the version table has more information than i have assumed, and this parse needs to take it in account
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Baker (jimbaker) wrote : | # |
> <niemeyer> 1) Grab the installed version from the "Installed:" line
> <niemeyer> 2) If this is "(none)" return "branch"
> <niemeyer> 3) Otherwise, store the version in a variable, and keep parsing
> <niemeyer> 4) Find the version table, and find the installed version
> <niemeyer> jimbaker: Is there any ambiguity here?
> <jimbaker> niemeyer, correct, there is no ambiguity. the version table has
> more information than i have assumed, and this parse needs to take it in
> account
The algorithm in parse_juju_origin, and its helper function, has been reworked as described.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gustavo Niemeyer (niemeyer) wrote : | # |
[18]
345 + " *** 0.5+bzr366-
346 + " 500 http://
347 + "natty/main amd64 Packages\n"
348 + " *** 0.5+bzr356-
349 + " 500 http://
Your multiple versions test has the PPA both in the installed and in the
non-installed version, so it's not really verifying the bug that you have
just fixed.
Change the URL in the non-installed version in this test so it doesn't come
from the PPA so that we ensure that it's really testing the installed version.
Also add a non-installed version that comes from the ppa in the distro test,
to ensure it's not being considered.
Please ensure tests pass with this and that a real interaction passes as well
before merging.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gustavo Niemeyer (niemeyer) wrote : | # |
I'm taking this over after a conversation on IRC.
Pushed the following changes onto lp:~niemeyer/juju/env-origin, reviewed by Kapil:
- Implementation redone completely.
- Do not crash on missing apt-cache.
- Exported and tested get_default_origin.
- Tests tweaked to explore edge cases.
Preview Diff
1 | === modified file 'docs/source/provider-configuration-ec2.rst' | |||
2 | --- docs/source/provider-configuration-ec2.rst 2011-09-15 17:41:55 +0000 | |||
3 | +++ docs/source/provider-configuration-ec2.rst 2011-09-29 23:50:28 +0000 | |||
4 | @@ -24,9 +24,15 @@ | |||
5 | 24 | An S3 bucket unique to the environment, where some runtime metadata and | 24 | An S3 bucket unique to the environment, where some runtime metadata and |
6 | 25 | charms are stored. | 25 | charms are stored. |
7 | 26 | 26 | ||
11 | 27 | juju-branch: | 27 | juju-origin: |
12 | 28 | Allow a juju bzr branch to be utilized for all machines within an | 28 | Defines where juju should be obtained for installing in |
13 | 29 | environment. | 29 | machines. Can be set to a "lp:..." branch url, to "ppa" for |
14 | 30 | getting packages from the official juju PPA, or to "distro" | ||
15 | 31 | for using packages from the official Ubuntu repositories. | ||
16 | 32 | |||
17 | 33 | If this option is not set, juju will attempt to detect the | ||
18 | 34 | correct origin based on its run location and the installed | ||
19 | 35 | juju package. | ||
20 | 30 | 36 | ||
21 | 31 | default-instance-type: | 37 | default-instance-type: |
22 | 32 | The instance type to be used for machines launched within the juju | 38 | The instance type to be used for machines launched within the juju |
23 | 33 | 39 | ||
24 | === modified file 'juju/providers/common/cloudinit.py' | |||
25 | --- juju/providers/common/cloudinit.py 2011-09-23 20:35:02 +0000 | |||
26 | +++ juju/providers/common/cloudinit.py 2011-09-29 23:50:28 +0000 | |||
27 | @@ -1,3 +1,5 @@ | |||
28 | 1 | from subprocess import Popen, PIPE | ||
29 | 2 | |||
30 | 1 | from juju.errors import CloudInitError | 3 | from juju.errors import CloudInitError |
31 | 2 | from juju.providers.common.utils import format_cloud_init | 4 | from juju.providers.common.utils import format_cloud_init |
32 | 3 | from juju.state.auth import make_identity | 5 | from juju.state.auth import make_identity |
33 | @@ -54,6 +56,80 @@ | |||
34 | 54 | % zookeeper_hosts] | 56 | % zookeeper_hosts] |
35 | 55 | 57 | ||
36 | 56 | 58 | ||
37 | 59 | def _get_apt_cache_policy(): | ||
38 | 60 | return Popen(["apt-cache", "policy", "juju"], stdout=PIPE).\ | ||
39 | 61 | communicate()[0] | ||
40 | 62 | |||
41 | 63 | |||
42 | 64 | def _parse_apt_cache_policy(data): | ||
43 | 65 | """Flatten apt-cache policy output to generate (key, value) pairs.""" | ||
44 | 66 | |||
45 | 67 | # Need to parse in two different phases, so set up iterator now | ||
46 | 68 | data = iter(data.split("\n")) | ||
47 | 69 | |||
48 | 70 | # Parse preamble | ||
49 | 71 | for row in data: | ||
50 | 72 | split = row.split(":", 1) | ||
51 | 73 | if len(split) != 2: | ||
52 | 74 | yield None, None | ||
53 | 75 | k, v = split[0].strip(), split[1].strip() | ||
54 | 76 | yield k, v | ||
55 | 77 | if k == "Version table": | ||
56 | 78 | break | ||
57 | 79 | |||
58 | 80 | # Parse version table into tag, priorities | ||
59 | 81 | tag = None | ||
60 | 82 | for row in data: | ||
61 | 83 | row = row.strip() | ||
62 | 84 | if row.startswith("***"): | ||
63 | 85 | tag = row | ||
64 | 86 | elif tag: | ||
65 | 87 | yield tag, row | ||
66 | 88 | |||
67 | 89 | |||
68 | 90 | def parse_juju_origin(data): | ||
69 | 91 | """Parse output of apt-cache to determine how juju was installed.""" | ||
70 | 92 | parse = _parse_apt_cache_policy(data) | ||
71 | 93 | k, _ = parse.next() | ||
72 | 94 | if k != "juju": | ||
73 | 95 | # Sanity check: no record at all, the only possibility is that | ||
74 | 96 | # this being run as a branch | ||
75 | 97 | return "branch", "lp:juju" | ||
76 | 98 | |||
77 | 99 | version = None | ||
78 | 100 | for k, v in parse: | ||
79 | 101 | if k == "Installed": | ||
80 | 102 | if v == "(none)": | ||
81 | 103 | return "branch", "lp:juju" | ||
82 | 104 | version = v | ||
83 | 105 | if k == "Version table": | ||
84 | 106 | break | ||
85 | 107 | |||
86 | 108 | for tag, priority in parse: | ||
87 | 109 | if (version in tag and | ||
88 | 110 | "http://ppa.launchpad.net/juju/pkgs/" in priority): | ||
89 | 111 | return "ppa", None | ||
90 | 112 | |||
91 | 113 | return "distro", None | ||
92 | 114 | |||
93 | 115 | |||
94 | 116 | def _get_default_origin(): | ||
95 | 117 | """Select the best fit for running juju on cloudinit. | ||
96 | 118 | |||
97 | 119 | Used if not otherwise specified by juju-origin. | ||
98 | 120 | """ | ||
99 | 121 | import juju | ||
100 | 122 | if not juju.__file__.startswith("/usr/"): | ||
101 | 123 | return "lp:juju" | ||
102 | 124 | origin, source = parse_juju_origin(_get_apt_cache_policy()) | ||
103 | 125 | if origin == "branch": | ||
104 | 126 | return source | ||
105 | 127 | elif origin == "ppa": | ||
106 | 128 | return _PPA | ||
107 | 129 | else: | ||
108 | 130 | return _DISTRO | ||
109 | 131 | |||
110 | 132 | |||
111 | 57 | class CloudInit(object): | 133 | class CloudInit(object): |
112 | 58 | """Encapsulates juju-specific machine initialisation. | 134 | """Encapsulates juju-specific machine initialisation. |
113 | 59 | 135 | ||
114 | @@ -65,7 +141,7 @@ | |||
115 | 65 | self._machine_id = None | 141 | self._machine_id = None |
116 | 66 | self._instance_id = None | 142 | self._instance_id = None |
117 | 67 | self._provider_type = None | 143 | self._provider_type = None |
119 | 68 | self._source = _PPA | 144 | self._source = _get_default_origin() |
120 | 69 | self._ssh_keys = [] | 145 | self._ssh_keys = [] |
121 | 70 | self._provision = False | 146 | self._provision = False |
122 | 71 | self._zookeeper = False | 147 | self._zookeeper = False |
123 | @@ -103,7 +179,7 @@ | |||
124 | 103 | or fewer than one options, are specified. | 179 | or fewer than one options, are specified. |
125 | 104 | 180 | ||
126 | 105 | Note that you don't need to call this method; the juju source | 181 | Note that you don't need to call this method; the juju source |
128 | 106 | defaults to the juju PPA. | 182 | defaults to what is returned by `get_default_origin`. |
129 | 107 | """ | 183 | """ |
130 | 108 | if len(filter(None, (branch, ppa, distro))) != 1: | 184 | if len(filter(None, (branch, ppa, distro))) != 1: |
131 | 109 | raise CloudInitError("Please specify one source") | 185 | raise CloudInitError("Please specify one source") |
132 | 110 | 186 | ||
133 | === modified file 'juju/providers/common/launch.py' | |||
134 | --- juju/providers/common/launch.py 2011-09-22 13:23:00 +0000 | |||
135 | +++ juju/providers/common/launch.py 2011-09-29 23:50:28 +0000 | |||
136 | @@ -76,8 +76,15 @@ | |||
137 | 76 | cloud_init.add_ssh_key(get_user_authorized_keys(config)) | 76 | cloud_init.add_ssh_key(get_user_authorized_keys(config)) |
138 | 77 | cloud_init.set_machine_id(machine_id) | 77 | cloud_init.set_machine_id(machine_id) |
139 | 78 | cloud_init.set_zookeeper_machines(zookeepers) | 78 | cloud_init.set_zookeeper_machines(zookeepers) |
142 | 79 | if config.get("juju-branch"): | 79 | origin = config.get("juju-origin") |
143 | 80 | cloud_init.set_juju_source(config["juju-branch"]) | 80 | if origin: |
144 | 81 | if origin.startswith("lp:"): | ||
145 | 82 | cloud_init.set_juju_source(branch=origin) | ||
146 | 83 | elif origin == "ppa": | ||
147 | 84 | cloud_init.set_juju_source(ppa=True) | ||
148 | 85 | else: | ||
149 | 86 | # Ignore other values, just use the distro for sanity | ||
150 | 87 | cloud_init.set_juju_source(distro=True) | ||
151 | 81 | if self._master: | 88 | if self._master: |
152 | 82 | cloud_init.enable_bootstrap() | 89 | cloud_init.enable_bootstrap() |
153 | 83 | cloud_init.set_zookeeper_secret(config["admin-secret"]) | 90 | cloud_init.set_zookeeper_secret(config["admin-secret"]) |
154 | 84 | 91 | ||
155 | === modified file 'juju/providers/common/tests/data/cloud_init_bootstrap' | |||
156 | --- juju/providers/common/tests/data/cloud_init_bootstrap 2011-09-23 20:35:02 +0000 | |||
157 | +++ juju/providers/common/tests/data/cloud_init_bootstrap 2011-09-29 23:50:28 +0000 | |||
158 | @@ -1,8 +1,6 @@ | |||
159 | 1 | #cloud-config | 1 | #cloud-config |
160 | 2 | apt-update: true | 2 | apt-update: true |
161 | 3 | apt-upgrade: true | 3 | apt-upgrade: true |
162 | 4 | apt_sources: | ||
163 | 5 | - {source: 'ppa:juju/pkgs'} | ||
164 | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'localhost:2181', | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'localhost:2181', |
165 | 7 | machine-id: passport} | 5 | machine-id: passport} |
166 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
167 | 9 | 7 | ||
168 | === modified file 'juju/providers/common/tests/data/cloud_init_bootstrap_zookeepers' | |||
169 | --- juju/providers/common/tests/data/cloud_init_bootstrap_zookeepers 2011-09-23 20:35:02 +0000 | |||
170 | +++ juju/providers/common/tests/data/cloud_init_bootstrap_zookeepers 2011-09-29 23:50:28 +0000 | |||
171 | @@ -1,8 +1,6 @@ | |||
172 | 1 | #cloud-config | 1 | #cloud-config |
173 | 2 | apt-update: true | 2 | apt-update: true |
174 | 3 | apt-upgrade: true | 3 | apt-upgrade: true |
175 | 4 | apt_sources: | ||
176 | 5 | - {source: 'ppa:juju/pkgs'} | ||
177 | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181,localhost:2181', | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181,localhost:2181', |
178 | 7 | machine-id: passport} | 5 | machine-id: passport} |
179 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
180 | 9 | 7 | ||
181 | === added file 'juju/providers/common/tests/data/cloud_init_branch_trunk' | |||
182 | --- juju/providers/common/tests/data/cloud_init_branch_trunk 1970-01-01 00:00:00 +0000 | |||
183 | +++ juju/providers/common/tests/data/cloud_init_branch_trunk 2011-09-29 23:50:28 +0000 | |||
184 | @@ -0,0 +1,17 @@ | |||
185 | 1 | #cloud-config | ||
186 | 2 | apt-update: true | ||
187 | 3 | apt-upgrade: true | ||
188 | 4 | apt_sources: | ||
189 | 5 | - {source: 'ppa:juju/pkgs'} | ||
190 | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | ||
191 | 7 | machine-id: passport} | ||
192 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | ||
193 | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-argparse, python-txaws, | ||
194 | 10 | python-zookeeper] | ||
195 | 11 | runcmd: [sudo apt-get install -y python-txzookeeper, sudo mkdir -p /usr/lib/juju, | ||
196 | 12 | 'cd /usr/lib/juju && sudo /usr/bin/bzr co lp:juju juju', | ||
197 | 13 | cd /usr/lib/juju/juju && sudo python setup.py develop, sudo mkdir -p /var/lib/juju, | ||
198 | 14 | sudo mkdir -p /var/log/juju, 'JUJU_MACHINE_ID=passport JUJU_ZOOKEEPER=cotswold:2181,longleat:2181 | ||
199 | 15 | python -m juju.agents.machine -n --logfile=/var/log/juju/machine-agent.log | ||
200 | 16 | --pidfile=/var/run/juju/machine-agent.pid'] | ||
201 | 17 | ssh_authorized_keys: [chubb] | ||
202 | 0 | 18 | ||
203 | === modified file 'juju/providers/common/tests/data/cloud_init_normal' | |||
204 | --- juju/providers/common/tests/data/cloud_init_normal 2011-09-15 19:29:57 +0000 | |||
205 | +++ juju/providers/common/tests/data/cloud_init_normal 2011-09-29 23:50:28 +0000 | |||
206 | @@ -1,8 +1,6 @@ | |||
207 | 1 | #cloud-config | 1 | #cloud-config |
208 | 2 | apt-update: true | 2 | apt-update: true |
209 | 3 | apt-upgrade: true | 3 | apt-upgrade: true |
210 | 4 | apt_sources: | ||
211 | 5 | - {source: 'ppa:juju/pkgs'} | ||
212 | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | 4 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', |
213 | 7 | machine-id: passport} | 5 | machine-id: passport} |
214 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
215 | 9 | 7 | ||
216 | === added file 'juju/providers/common/tests/data/cloud_init_ppa' | |||
217 | --- juju/providers/common/tests/data/cloud_init_ppa 1970-01-01 00:00:00 +0000 | |||
218 | +++ juju/providers/common/tests/data/cloud_init_ppa 2011-09-29 23:50:28 +0000 | |||
219 | @@ -0,0 +1,15 @@ | |||
220 | 1 | #cloud-config | ||
221 | 2 | apt-update: true | ||
222 | 3 | apt-upgrade: true | ||
223 | 4 | apt_sources: | ||
224 | 5 | - {'source': 'ppa:juju/pkgs'} | ||
225 | 6 | machine-data: {juju-provider-type: dummy, juju-zookeeper-hosts: 'cotswold:2181,longleat:2181', | ||
226 | 7 | machine-id: passport} | ||
227 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | ||
228 | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-argparse, python-txaws, | ||
229 | 10 | python-zookeeper] | ||
230 | 11 | runcmd: [sudo apt-get -y install juju, sudo mkdir -p /var/lib/juju, sudo mkdir | ||
231 | 12 | -p /var/log/juju, 'JUJU_MACHINE_ID=passport JUJU_ZOOKEEPER=cotswold:2181,longleat:2181 | ||
232 | 13 | python -m juju.agents.machine -n --logfile=/var/log/juju/machine-agent.log | ||
233 | 14 | --pidfile=/var/run/juju/machine-agent.pid'] | ||
234 | 15 | ssh_authorized_keys: [chubb] | ||
235 | 0 | 16 | ||
236 | === modified file 'juju/providers/common/tests/test_cloudinit.py' | |||
237 | --- juju/providers/common/tests/test_cloudinit.py 2011-09-22 13:23:00 +0000 | |||
238 | +++ juju/providers/common/tests/test_cloudinit.py 2011-09-29 23:50:28 +0000 | |||
239 | @@ -1,12 +1,14 @@ | |||
240 | 1 | import os | 1 | import os |
241 | 2 | import stat | ||
242 | 2 | 3 | ||
243 | 3 | import yaml | 4 | import yaml |
244 | 4 | 5 | ||
245 | 5 | from juju.errors import CloudInitError | 6 | from juju.errors import CloudInitError |
246 | 6 | from juju.lib.testing import TestCase | 7 | from juju.lib.testing import TestCase |
248 | 7 | from juju.providers.common.cloudinit import CloudInit | 8 | from juju.providers.common.cloudinit import CloudInit, parse_juju_origin |
249 | 8 | from juju.providers.dummy import DummyMachine | 9 | from juju.providers.dummy import DummyMachine |
250 | 9 | 10 | ||
251 | 11 | |||
252 | 10 | DATA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data") | 12 | DATA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data") |
253 | 11 | 13 | ||
254 | 12 | 14 | ||
255 | @@ -30,6 +32,7 @@ | |||
256 | 30 | cloud_init.set_provider_type("dummy") | 32 | cloud_init.set_provider_type("dummy") |
257 | 31 | cloud_init.set_instance_id_accessor("token") | 33 | cloud_init.set_instance_id_accessor("token") |
258 | 32 | cloud_init.set_zookeeper_secret("seekrit") | 34 | cloud_init.set_zookeeper_secret("seekrit") |
259 | 35 | cloud_init.set_juju_source(distro=True) | ||
260 | 33 | if with_zookeepers: | 36 | if with_zookeepers: |
261 | 34 | cloud_init.set_zookeeper_machines([ | 37 | cloud_init.set_zookeeper_machines([ |
262 | 35 | DummyMachine("blah", "blah", "cotswold"), | 38 | DummyMachine("blah", "blah", "cotswold"), |
263 | @@ -74,12 +77,34 @@ | |||
264 | 74 | self.assertEquals(str(error), "Please specify one source") | 77 | self.assertEquals(str(error), "Please specify one source") |
265 | 75 | 78 | ||
266 | 76 | def test_render_normal(self): | 79 | def test_render_normal(self): |
268 | 77 | self.assert_render(self.construct_normal(), "cloud_init_normal") | 80 | path = os.environ.get("PATH", "") |
269 | 81 | alt_apt_cache_path = self.makeDir() | ||
270 | 82 | filename = os.path.join(alt_apt_cache_path, "apt-cache") | ||
271 | 83 | with open(filename, "w") as f: | ||
272 | 84 | f.write( | ||
273 | 85 | "#!/bin/bash\n" | ||
274 | 86 | "cat <<EOF\n" | ||
275 | 87 | "juju:\n" | ||
276 | 88 | " Installed: good-magic-1.0\n" | ||
277 | 89 | " Candidate: good-magic-1.0\n" | ||
278 | 90 | " Version table:\n" | ||
279 | 91 | " *** good-magic-1.0\n" | ||
280 | 92 | " 500 http://us.archive.ubuntu.com/ubuntu/ " | ||
281 | 93 | "natty/main amd64 Packages\n" | ||
282 | 94 | " 100 /var/lib/dpkg/status\n" | ||
283 | 95 | "EOF\n") | ||
284 | 96 | os.chmod(filename, stat.S_IEXEC | stat.S_IREAD) | ||
285 | 97 | updated_path = alt_apt_cache_path + ":" + path | ||
286 | 98 | self.change_environment(PATH=updated_path) | ||
287 | 99 | import juju | ||
288 | 100 | self.patch(juju, "__file__", | ||
289 | 101 | "/usr/lib/pymodules/python2.7/juju/__init__.pyc") | ||
290 | 102 | self.assert_render(self.construct_normal(), "cloud_init_distro") | ||
291 | 78 | 103 | ||
292 | 79 | def test_render_ppa_source(self): | 104 | def test_render_ppa_source(self): |
293 | 80 | cloud_init = self.construct_normal() | 105 | cloud_init = self.construct_normal() |
294 | 81 | cloud_init.set_juju_source(ppa=True) | 106 | cloud_init.set_juju_source(ppa=True) |
296 | 82 | self.assert_render(cloud_init, "cloud_init_normal") | 107 | self.assert_render(cloud_init, "cloud_init_ppa") |
297 | 83 | 108 | ||
298 | 84 | def test_render_distro_source(self): | 109 | def test_render_distro_source(self): |
299 | 85 | cloud_init = self.construct_normal() | 110 | cloud_init = self.construct_normal() |
300 | @@ -91,9 +116,90 @@ | |||
301 | 91 | cloud_init.set_juju_source(branch="lp:blah/juju/blah-blah") | 116 | cloud_init.set_juju_source(branch="lp:blah/juju/blah-blah") |
302 | 92 | self.assert_render(cloud_init, "cloud_init_branch") | 117 | self.assert_render(cloud_init, "cloud_init_branch") |
303 | 93 | 118 | ||
304 | 119 | def test_render_branch_source_if_not_installed(self): | ||
305 | 120 | import juju | ||
306 | 121 | self.patch(juju, "__file__", "/not/installed/under/usr") | ||
307 | 122 | cloud_init = self.construct_normal() | ||
308 | 123 | self.assert_render(cloud_init, "cloud_init_branch_trunk") | ||
309 | 124 | |||
310 | 94 | def test_render_bootstrap(self): | 125 | def test_render_bootstrap(self): |
311 | 95 | self.assert_render(self.construct_bootstrap(), "cloud_init_bootstrap") | 126 | self.assert_render(self.construct_bootstrap(), "cloud_init_bootstrap") |
312 | 96 | 127 | ||
313 | 97 | def test_render_bootstrap_with_zookeepers(self): | 128 | def test_render_bootstrap_with_zookeepers(self): |
314 | 98 | self.assert_render( | 129 | self.assert_render( |
315 | 99 | self.construct_bootstrap(True), "cloud_init_bootstrap_zookeepers") | 130 | self.construct_bootstrap(True), "cloud_init_bootstrap_zookeepers") |
316 | 131 | |||
317 | 132 | |||
318 | 133 | class ParseJujuOriginTest(TestCase): | ||
319 | 134 | |||
320 | 135 | def test_distro_installed(self): | ||
321 | 136 | data = ( | ||
322 | 137 | "juju:\n" | ||
323 | 138 | " Installed: good-magic-1.0\n" | ||
324 | 139 | " Candidate: good-magic-1.0\n" | ||
325 | 140 | " Version table:\n" | ||
326 | 141 | " *** good-magic-1.0 0\n" | ||
327 | 142 | " 500 http://us.archive.ubuntu.com/ubuntu/ " | ||
328 | 143 | "natty/main amd64 Packages\n" | ||
329 | 144 | " 100 /var/lib/dpkg/status\n") | ||
330 | 145 | |||
331 | 146 | origin, source = parse_juju_origin(data) | ||
332 | 147 | self.assertEqual(origin, "distro") | ||
333 | 148 | self.assertEqual(source, None) | ||
334 | 149 | |||
335 | 150 | def test_multiple_versions_available(self): | ||
336 | 151 | data = ( | ||
337 | 152 | "juju:\n" | ||
338 | 153 | " Installed: 0.5+bzr366-1juju1~natty1\n" | ||
339 | 154 | " Candidate: 0.5+bzr366-1juju1~natty1\n" | ||
340 | 155 | " Version table:\n" | ||
341 | 156 | " *** bad-magic-0.5 0\n" | ||
342 | 157 | " 500 http://us.archive.ubuntu.com/ubuntu/ " | ||
343 | 158 | "natty/main amd64 Packages\n" | ||
344 | 159 | " 100 /var/lib/dpkg/status\n" | ||
345 | 160 | " *** 0.5+bzr366-1juju1~natty1 0\n" | ||
346 | 161 | " 500 http://ppa.launchpad.net/juju/pkgs/ubuntu/ " | ||
347 | 162 | "natty/main amd64 Packages\n" | ||
348 | 163 | " *** 0.5+bzr356-1juju1~natty1 0\n" | ||
349 | 164 | " 500 http://ppa.launchpad.net/juju/pkgs/ubuntu/ " | ||
350 | 165 | "natty/main amd64 Packages\n") | ||
351 | 166 | |||
352 | 167 | origin, source = parse_juju_origin(data) | ||
353 | 168 | self.assertEqual(origin, "ppa") | ||
354 | 169 | self.assertEqual(source, None) | ||
355 | 170 | |||
356 | 171 | def test_distro_not_installed(self): | ||
357 | 172 | data = ( | ||
358 | 173 | "juju:\n" | ||
359 | 174 | " Installed: (none)\n" | ||
360 | 175 | " Candidate: good-magic-1.0\n" | ||
361 | 176 | " Version table:\n" | ||
362 | 177 | " *** good-magic-1.0 0\n" | ||
363 | 178 | " 500 http://us.archive.ubuntu.com/ubuntu/ " | ||
364 | 179 | "natty/main amd64 Packages\n" | ||
365 | 180 | " 100 /var/lib/dpkg/status\n") | ||
366 | 181 | |||
367 | 182 | origin, source = parse_juju_origin(data) | ||
368 | 183 | self.assertEqual(origin, "branch") | ||
369 | 184 | self.assertEqual(source, "lp:juju") | ||
370 | 185 | |||
371 | 186 | def test_ppa_installed(self): | ||
372 | 187 | data = ( | ||
373 | 188 | "juju:\n" | ||
374 | 189 | " Installed: 0.5+bzr356-1juju1~natty1\n" | ||
375 | 190 | " Candidate: 0.5+bzr356-1juju1~natty1\n" | ||
376 | 191 | " Version table:\n" | ||
377 | 192 | " *** 0.5+bzr356-1juju1~natty1 0\n" | ||
378 | 193 | " 500 http://ppa.launchpad.net/juju/pkgs/ubuntu/ " | ||
379 | 194 | "natty/main amd64 Packages\n" | ||
380 | 195 | " 100 /var/lib/dpkg/status\n") | ||
381 | 196 | |||
382 | 197 | origin, source = parse_juju_origin(data) | ||
383 | 198 | self.assertEqual(origin, "ppa") | ||
384 | 199 | self.assertEqual(source, None) | ||
385 | 200 | |||
386 | 201 | def test_juju_package_is_unknown(self): | ||
387 | 202 | data = "N: Unable to locate package juju" | ||
388 | 203 | origin, source = parse_juju_origin(data) | ||
389 | 204 | self.assertEqual(origin, "branch") | ||
390 | 205 | self.assertEqual(source, "lp:juju") | ||
391 | 100 | 206 | ||
392 | === modified file 'juju/providers/ec2/tests/common.py' | |||
393 | --- juju/providers/ec2/tests/common.py 2011-09-22 13:23:00 +0000 | |||
394 | +++ juju/providers/ec2/tests/common.py 2011-09-29 23:50:28 +0000 | |||
395 | @@ -22,6 +22,7 @@ | |||
396 | 22 | 22 | ||
397 | 23 | def get_config(self): | 23 | def get_config(self): |
398 | 24 | return {"type": "ec2", | 24 | return {"type": "ec2", |
399 | 25 | "juju-origin": "distro", | ||
400 | 25 | "admin-secret": "magic-beans", | 26 | "admin-secret": "magic-beans", |
401 | 26 | "access-key": "0f62e973d5f8", | 27 | "access-key": "0f62e973d5f8", |
402 | 27 | "secret-key": "3e5a7c653f59", | 28 | "secret-key": "3e5a7c653f59", |
403 | 28 | 29 | ||
404 | === modified file 'juju/providers/ec2/tests/data/bootstrap_cloud_init' | |||
405 | --- juju/providers/ec2/tests/data/bootstrap_cloud_init 2011-09-23 20:35:02 +0000 | |||
406 | +++ juju/providers/ec2/tests/data/bootstrap_cloud_init 2011-09-29 23:50:28 +0000 | |||
407 | @@ -1,8 +1,6 @@ | |||
408 | 1 | #cloud-config | 1 | #cloud-config |
409 | 2 | apt-update: true | 2 | apt-update: true |
410 | 3 | apt-upgrade: true | 3 | apt-upgrade: true |
411 | 4 | apt_sources: | ||
412 | 5 | - {source: 'ppa:juju/pkgs'} | ||
413 | 6 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'localhost:2181', | 4 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'localhost:2181', |
414 | 7 | machine-id: '0'} | 5 | machine-id: '0'} |
415 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
416 | 9 | 7 | ||
417 | === modified file 'juju/providers/ec2/tests/data/launch_cloud_init' | |||
418 | --- juju/providers/ec2/tests/data/launch_cloud_init 2011-09-15 19:29:57 +0000 | |||
419 | +++ juju/providers/ec2/tests/data/launch_cloud_init 2011-09-29 23:50:28 +0000 | |||
420 | @@ -1,8 +1,6 @@ | |||
421 | 1 | #cloud-config | 1 | #cloud-config |
422 | 2 | apt-update: true | 2 | apt-update: true |
423 | 3 | apt-upgrade: true | 3 | apt-upgrade: true |
424 | 4 | apt_sources: | ||
425 | 5 | - {source: 'ppa:juju/pkgs'} | ||
426 | 6 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'es.example.internal:2181', | 4 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'es.example.internal:2181', |
427 | 7 | machine-id: '1'} | 5 | machine-id: '1'} |
428 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
429 | 9 | 7 | ||
430 | === added file 'juju/providers/ec2/tests/data/launch_cloud_init_branch' | |||
431 | --- juju/providers/ec2/tests/data/launch_cloud_init_branch 1970-01-01 00:00:00 +0000 | |||
432 | +++ juju/providers/ec2/tests/data/launch_cloud_init_branch 2011-09-29 23:50:28 +0000 | |||
433 | @@ -0,0 +1,20 @@ | |||
434 | 1 | #cloud-config | ||
435 | 2 | apt-update: true | ||
436 | 3 | apt-upgrade: true | ||
437 | 4 | apt_sources: | ||
438 | 5 | - {source: 'ppa:juju/pkgs'} | ||
439 | 6 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'es.example.internal:2181', | ||
440 | 7 | machine-id: '1'} | ||
441 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | ||
442 | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-argparse, python-txaws, | ||
443 | 10 | python-zookeeper] | ||
444 | 11 | runcmd: [sudo apt-get install -y python-txzookeeper, | ||
445 | 12 | sudo mkdir -p /usr/lib/juju, | ||
446 | 13 | 'cd /usr/lib/juju && sudo /usr/bin/bzr co lp:~wizard/juju-juicebar juju', | ||
447 | 14 | cd /usr/lib/juju/juju && sudo python setup.py develop, | ||
448 | 15 | sudo mkdir -p /var/lib/juju, | ||
449 | 16 | sudo mkdir -p /var/log/juju, | ||
450 | 17 | 'JUJU_MACHINE_ID=1 JUJU_ZOOKEEPER=es.example.internal:2181 | ||
451 | 18 | python -m juju.agents.machine -n --logfile=/var/log/juju/machine-agent.log | ||
452 | 19 | --pidfile=/var/run/juju/machine-agent.pid'] | ||
453 | 20 | ssh_authorized_keys: [zebra] | ||
454 | 0 | 21 | ||
455 | === added file 'juju/providers/ec2/tests/data/launch_cloud_init_ppa' | |||
456 | --- juju/providers/ec2/tests/data/launch_cloud_init_ppa 1970-01-01 00:00:00 +0000 | |||
457 | +++ juju/providers/ec2/tests/data/launch_cloud_init_ppa 2011-09-29 23:50:28 +0000 | |||
458 | @@ -0,0 +1,15 @@ | |||
459 | 1 | #cloud-config | ||
460 | 2 | apt-update: true | ||
461 | 3 | apt-upgrade: true | ||
462 | 4 | apt_sources: | ||
463 | 5 | - {source: 'ppa:juju/pkgs'} | ||
464 | 6 | machine-data: {juju-provider-type: ec2, juju-zookeeper-hosts: 'es.example.internal:2181', | ||
465 | 7 | machine-id: '1'} | ||
466 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | ||
467 | 9 | packages: [bzr, byobu, tmux, python-setuptools, python-twisted, python-argparse, python-txaws, | ||
468 | 10 | python-zookeeper] | ||
469 | 11 | runcmd: [sudo apt-get -y install juju, sudo mkdir -p /var/lib/juju, sudo mkdir | ||
470 | 12 | -p /var/log/juju, 'JUJU_MACHINE_ID=1 JUJU_ZOOKEEPER=es.example.internal:2181 | ||
471 | 13 | python -m juju.agents.machine -n --logfile=/var/log/juju/machine-agent.log | ||
472 | 14 | --pidfile=/var/run/juju/machine-agent.pid'] | ||
473 | 15 | ssh_authorized_keys: [zebra] | ||
474 | 0 | 16 | ||
475 | === modified file 'juju/providers/ec2/tests/test_bootstrap.py' | |||
476 | --- juju/providers/ec2/tests/test_bootstrap.py 2011-09-22 13:23:00 +0000 | |||
477 | +++ juju/providers/ec2/tests/test_bootstrap.py 2011-09-29 23:50:28 +0000 | |||
478 | @@ -13,6 +13,7 @@ | |||
479 | 13 | 13 | ||
480 | 14 | from .common import EC2TestMixin, EC2MachineLaunchMixin | 14 | from .common import EC2TestMixin, EC2MachineLaunchMixin |
481 | 15 | 15 | ||
482 | 16 | |||
483 | 16 | DATA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data") | 17 | DATA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data") |
484 | 17 | 18 | ||
485 | 18 | 19 | ||
486 | 19 | 20 | ||
487 | === modified file 'juju/providers/ec2/tests/test_launch.py' | |||
488 | --- juju/providers/ec2/tests/test_launch.py 2011-09-16 00:36:31 +0000 | |||
489 | +++ juju/providers/ec2/tests/test_launch.py 2011-09-29 23:50:28 +0000 | |||
490 | @@ -21,10 +21,11 @@ | |||
491 | 21 | class EC2MachineLaunchTest(EC2TestMixin, EC2MachineLaunchMixin, TestCase): | 21 | class EC2MachineLaunchTest(EC2TestMixin, EC2MachineLaunchMixin, TestCase): |
492 | 22 | 22 | ||
493 | 23 | def _mock_launch(self, instance, expect_ami="ami-default", | 23 | def _mock_launch(self, instance, expect_ami="ami-default", |
495 | 24 | expect_instance_type="m1.small"): | 24 | expect_instance_type="m1.small", |
496 | 25 | cloud_init="launch_cloud_init"): | ||
497 | 25 | 26 | ||
498 | 26 | def verify_user_data(data): | 27 | def verify_user_data(data): |
500 | 27 | expect_path = os.path.join(DATA_DIR, "launch_cloud_init") | 28 | expect_path = os.path.join(DATA_DIR, cloud_init) |
501 | 28 | with open(expect_path) as f: | 29 | with open(expect_path) as f: |
502 | 29 | expect_cloud_init = yaml.load(f.read()) | 30 | expect_cloud_init = yaml.load(f.read()) |
503 | 30 | self.assertEquals(yaml.load(data), expect_cloud_init) | 31 | self.assertEquals(yaml.load(data), expect_cloud_init) |
504 | @@ -75,6 +76,63 @@ | |||
505 | 75 | return d | 76 | return d |
506 | 76 | 77 | ||
507 | 77 | @inlineCallbacks | 78 | @inlineCallbacks |
508 | 79 | def test_provider_launch_using_branch(self): | ||
509 | 80 | """Can use a juju branch to launch a machine""" | ||
510 | 81 | self.ec2.describe_security_groups() | ||
511 | 82 | self.mocker.result(succeed([])) | ||
512 | 83 | self._mock_create_group() | ||
513 | 84 | self._mock_create_machine_group("1") | ||
514 | 85 | self._mock_launch_utils(region="us-east-1") | ||
515 | 86 | self._mock_get_zookeeper_hosts() | ||
516 | 87 | self._mock_launch( | ||
517 | 88 | self.get_instance("i-foobar"), | ||
518 | 89 | cloud_init="launch_cloud_init_branch") | ||
519 | 90 | self.mocker.replay() | ||
520 | 91 | |||
521 | 92 | provider = self.get_provider() | ||
522 | 93 | provider.config["juju-origin"] = "lp:~wizard/juju-juicebar" | ||
523 | 94 | machines = yield provider.start_machine({"machine-id": "1"}) | ||
524 | 95 | self.assert_machine(machines[0], "i-foobar", "") | ||
525 | 96 | |||
526 | 97 | @inlineCallbacks | ||
527 | 98 | def test_provider_launch_using_ppa(self): | ||
528 | 99 | """Can use the juju ppa to launch a machine""" | ||
529 | 100 | self.ec2.describe_security_groups() | ||
530 | 101 | self.mocker.result(succeed([])) | ||
531 | 102 | self._mock_create_group() | ||
532 | 103 | self._mock_create_machine_group("1") | ||
533 | 104 | self._mock_launch_utils(region="us-east-1") | ||
534 | 105 | self._mock_get_zookeeper_hosts() | ||
535 | 106 | self._mock_launch( | ||
536 | 107 | self.get_instance("i-foobar"), | ||
537 | 108 | cloud_init="launch_cloud_init_ppa") | ||
538 | 109 | self.mocker.replay() | ||
539 | 110 | |||
540 | 111 | provider = self.get_provider() | ||
541 | 112 | provider.config["juju-origin"] = "ppa" | ||
542 | 113 | machines = yield provider.start_machine({"machine-id": "1"}) | ||
543 | 114 | self.assert_machine(machines[0], "i-foobar", "") | ||
544 | 115 | |||
545 | 116 | @inlineCallbacks | ||
546 | 117 | def test_provider_launch_using_explicit_distro(self): | ||
547 | 118 | """Can set juju-origin explicitly to `distro`""" | ||
548 | 119 | self.ec2.describe_security_groups() | ||
549 | 120 | self.mocker.result(succeed([])) | ||
550 | 121 | self._mock_create_group() | ||
551 | 122 | self._mock_create_machine_group("1") | ||
552 | 123 | self._mock_launch_utils(region="us-east-1") | ||
553 | 124 | self._mock_get_zookeeper_hosts() | ||
554 | 125 | self._mock_launch( | ||
555 | 126 | self.get_instance("i-foobar"), | ||
556 | 127 | cloud_init="launch_cloud_init") | ||
557 | 128 | self.mocker.replay() | ||
558 | 129 | |||
559 | 130 | provider = self.get_provider() | ||
560 | 131 | provider.config["juju-origin"] = "distro" | ||
561 | 132 | machines = yield provider.start_machine({"machine-id": "1"}) | ||
562 | 133 | self.assert_machine(machines[0], "i-foobar", "") | ||
563 | 134 | |||
564 | 135 | @inlineCallbacks | ||
565 | 78 | def test_provider_launch_existing_security_group(self): | 136 | def test_provider_launch_existing_security_group(self): |
566 | 79 | """Verify that the launch works if the env security group exists""" | 137 | """Verify that the launch works if the env security group exists""" |
567 | 80 | instance = Instance("i-foobar", "running", dns_name="x1.example.com") | 138 | instance = Instance("i-foobar", "running", dns_name="x1.example.com") |
568 | 81 | 139 | ||
569 | === modified file 'juju/providers/orchestra/tests/common.py' | |||
570 | --- juju/providers/orchestra/tests/common.py 2011-09-22 13:23:00 +0000 | |||
571 | +++ juju/providers/orchestra/tests/common.py 2011-09-29 23:50:28 +0000 | |||
572 | @@ -13,7 +13,9 @@ | |||
573 | 13 | 13 | ||
574 | 14 | DATA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data") | 14 | DATA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data") |
575 | 15 | 15 | ||
577 | 16 | CONFIG = {"orchestra-server": "somewhe.re", | 16 | CONFIG = {"type": "orchestra", |
578 | 17 | "juju-origin": "distro", | ||
579 | 18 | "orchestra-server": "somewhe.re", | ||
580 | 17 | "orchestra-user": "user", | 19 | "orchestra-user": "user", |
581 | 18 | "orchestra-pass": "pass", | 20 | "orchestra-pass": "pass", |
582 | 19 | "acquired-mgmt-class": "acquired", | 21 | "acquired-mgmt-class": "acquired", |
583 | 20 | 22 | ||
584 | === modified file 'juju/providers/orchestra/tests/data/bootstrap_user_data' | |||
585 | --- juju/providers/orchestra/tests/data/bootstrap_user_data 2011-09-23 20:35:02 +0000 | |||
586 | +++ juju/providers/orchestra/tests/data/bootstrap_user_data 2011-09-29 23:50:28 +0000 | |||
587 | @@ -1,8 +1,6 @@ | |||
588 | 1 | #cloud-config | 1 | #cloud-config |
589 | 2 | apt-update: true | 2 | apt-update: true |
590 | 3 | apt-upgrade: true | 3 | apt-upgrade: true |
591 | 4 | apt_sources: | ||
592 | 5 | - {source: 'ppa:juju/pkgs'} | ||
593 | 6 | machine-data: {juju-provider-type: orchestra, juju-zookeeper-hosts: 'localhost:2181', | 4 | machine-data: {juju-provider-type: orchestra, juju-zookeeper-hosts: 'localhost:2181', |
594 | 7 | machine-id: '0'} | 5 | machine-id: '0'} |
595 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
596 | 9 | 7 | ||
597 | === modified file 'juju/providers/orchestra/tests/data/launch_user_data' | |||
598 | --- juju/providers/orchestra/tests/data/launch_user_data 2011-09-16 14:07:03 +0000 | |||
599 | +++ juju/providers/orchestra/tests/data/launch_user_data 2011-09-29 23:50:28 +0000 | |||
600 | @@ -1,8 +1,6 @@ | |||
601 | 1 | #cloud-config | 1 | #cloud-config |
602 | 2 | apt-update: true | 2 | apt-update: true |
603 | 3 | apt-upgrade: true | 3 | apt-upgrade: true |
604 | 4 | apt_sources: | ||
605 | 5 | - {source: 'ppa:juju/pkgs'} | ||
606 | 6 | machine-data: {juju-provider-type: orchestra, juju-zookeeper-hosts: 'jennifer:2181', | 4 | machine-data: {juju-provider-type: orchestra, juju-zookeeper-hosts: 'jennifer:2181', |
607 | 7 | machine-id: '42'} | 5 | machine-id: '42'} |
608 | 8 | output: {all: '| tee -a /var/log/cloud-init-output.log'} | 6 | output: {all: '| tee -a /var/log/cloud-init-output.log'} |
[1]
The documentation must be changed accordingly.
[2]
Please drop the version support. Without pinning, this doesn't guarantee that
the version will stay as suggested, and we shouldn't be looking into pinning
right now.
[3]
238 + # XXX needed for python-txzookeeper dependency
239 return ["ppa:juju/pkgs"]
That's a *major* one. Why? Please synchronize with SpamapS and ensure that's not
needed anymore.
[4]
213 + # Classify origins so the proper install script is later selected startswith( "deb ") or \ startswith( "ppa:") or \ startswith( "http:" ) or \ startswith( "https: ")): startswith( "lp:"):
214 + if origin is None:
215 + self._origin_type = _DISTRO
216 + elif (origin.
217 + origin.
218 + origin.
219 + origin.
220 + self._origin_type = _DEBIAN
221 + elif origin.
222 + self._origin_type = _BRANCH
Why is this changing? The original version of this logic was significantly
simpler and cleaner, and seems to support all the cases we're trying to
support right now.
[5]
I'm _very_ concerned about your summary. The support for other package sources
besides branches is precisely what this branch is introducing, and you seem to
claim this wasn't tested at all.
Please do make sure this stuff is tested.