~gz/pyjuju/debug_openstack_placement

« back to all changes in this revision

Viewing changes to juju/providers/common/tests/test_cloudinit.py

  • Committer: Clint Byrum
  • Date: 2012-10-06 14:38:12 UTC
  • mfrom: (486.4.39 local-cloud-img)
  • Revision ID: clint@fewbar.com-20121006143812-id2qq4i2ui75yy8h
Refactor local provider to use Cloud Images [r=hazmat][f=915520,930430,996358,997677,1037803,1038927]

- Boots a full container with cloud-init each time, No more template container + clone
- Removes upstart job for storage server. Also fixes machine-agent to be killable on destroy-env
- Uses LXC's default networking rather than libvirt. Removes dependency on libvirt entirely.
- Regresses HTTPS apt support for local provider because cloud-init doesn't have a way to make the
distinction.
- Regresses performance for the case where the download is cached. rsync'ing from the debootstrap
is a little faster than extracting the tar.gz. Also we now do a full apt-get upgrade, so all updates
have to be unpacked/configured.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
from juju.providers.common.cloudinit import (
10
10
    CloudInit, parse_juju_origin, get_default_origin)
11
11
from juju.providers.dummy import DummyMachine
 
12
from juju.machine import ProviderMachine
12
13
import juju
13
14
 
14
15
 
57
58
        self.assertEquals(
58
59
            str(error),
59
60
            "Incomplete cloud-init: you need to call add_ssh_key, "
60
 
            "set_machine_id, set_provider_type, set_zookeeper_machines")
 
61
            "set_zookeeper_machines")
61
62
 
62
63
    def test_render_validate_bootstrap(self):
63
64
        cloud_init = CloudInit()
66
67
        self.assertEquals(
67
68
            str(error),
68
69
            "Incomplete cloud-init: you need to call add_ssh_key, "
69
 
            "set_machine_id, set_provider_type, set_instance_id_accessor, "
 
70
            "set_provider_type, set_instance_id_accessor, "
70
71
            "set_zookeeper_secret, set_constraints")
71
72
 
72
73
    def test_source_validate(self):
138
139
        self.assert_render(
139
140
            self.construct_bootstrap(True), "cloud_init_bootstrap_zookeepers")
140
141
 
 
142
    def test_render_no_machine_id(self):
 
143
        self.patch(juju, "__file__", "/not/installed/under/usr")
 
144
        cloud_init = CloudInit()
 
145
        cloud_init.add_ssh_key("chubb")
 
146
        cloud_init.set_provider_type("dummy")
 
147
        cloud_init.set_zookeeper_machines([
 
148
            DummyMachine("blah", "blah", "cotswold"),
 
149
            DummyMachine("blah", "blah", "longleat")])
 
150
        cloud_init.set_juju_source(distro=True)
 
151
        self.assert_render(cloud_init, "cloud_init_no_machine_id")
 
152
 
 
153
    def test_render_apt_proxy(self):
 
154
        cloud_init = self.construct_normal()
 
155
        cloud_init.set_juju_source(ppa=True)
 
156
        cloud_init.set_apt_proxy('superproxy:37337')
 
157
        self.assert_render(cloud_init, "cloud_init_ppa_apt_proxy")
 
158
 
 
159
    def test_set_zookeeper_machines(self):
 
160
        machine1 = ProviderMachine('i-100', 'foo1', 'foo1.private')
 
161
        machine2 = ProviderMachine('i-200', 'foo2', 'foo2.private')
 
162
        cloud_init = CloudInit()
 
163
        cloud_init.set_zookeeper_machines([machine1, machine2])
 
164
        self.assertEqual(['foo1.private', 'foo2.private'], cloud_init._zookeeper_hosts)
 
165
 
 
166
    def test_set_zookeeper_hosts(self):
 
167
        cloud_init = CloudInit()
 
168
        cloud_init.set_zookeeper_hosts(['bar1.private', 'bar2.private'])
 
169
        self.assertEqual(['bar1.private', 'bar2.private'], cloud_init._zookeeper_hosts)
 
170
 
 
171
    def test_set_zookeeper_hosts_tuple(self):
 
172
        cloud_init = CloudInit()
 
173
        cloud_init.set_zookeeper_hosts([('bar1.private', 9999)])
 
174
        self.assertEqual('bar1.private:9999', cloud_init._join_zookeeper_hosts())
141
175
 
142
176
class ParseJujuOriginTest(TestCase):
143
177