~jimbaker/pyjuju/ssh-known_hosts

« back to all changes in this revision

Viewing changes to juju/providers/ec2/tests/test_launch.py

  • Committer: Gustavo Niemeyer
  • Date: 2011-09-16 00:37:59 UTC
  • mfrom: (348.1.13 the-big-renaming)
  • Revision ID: gustavo@niemeyer.net-20110916003759-bx3vsznroj4gv7w7
Merging the-big-renaming branch! Say hello to juju!

This is a massive change renaming and fixing several things
on the way. Unfortunately my day is finishing and I didn't
manage to get 100% of the tests passing, but there's very
few things broken right now, and I don't want to keep such
a massive change flying around.

We'll sort any details out tomorrow.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
2
2
 
 
3
import yaml
 
4
 
3
5
from twisted.internet.defer import inlineCallbacks, succeed
4
6
 
5
7
from txaws.ec2.model import Instance, SecurityGroup
6
8
 
7
 
from ensemble.errors import (
 
9
from juju.errors import (
8
10
    EnvironmentNotFound, ProviderError, ProviderInteractionError)
9
 
from ensemble.providers.ec2.machine import EC2ProviderMachine
 
11
from juju.providers.ec2.machine import EC2ProviderMachine
10
12
 
11
 
from ensemble.lib.testing import TestCase
12
 
from ensemble.lib.mocker import MATCH
 
13
from juju.lib.testing import TestCase
 
14
from juju.lib.mocker import MATCH
13
15
 
14
16
from .common import EC2TestMixin, EC2MachineLaunchMixin
15
17
 
24
26
        def verify_user_data(data):
25
27
            expect_path = os.path.join(DATA_DIR, "launch_cloud_init")
26
28
            with open(expect_path) as f:
27
 
                expect_cloud_init = f.read()
28
 
            self.assertEquals(data, expect_cloud_init)
 
29
                expect_cloud_init = yaml.load(f.read())
 
30
            self.assertEquals(yaml.load(data), expect_cloud_init)
29
31
            return True
30
32
 
31
33
        self.ec2.run_instances(
33
35
            instance_type=expect_instance_type,
34
36
            max_count=1,
35
37
            min_count=1,
36
 
            security_groups=["ensemble-moon", "ensemble-moon-1"],
 
38
            security_groups=["juju-moon", "juju-moon-1"],
37
39
            user_data=MATCH(verify_user_data))
38
40
 
39
41
        self.mocker.result(succeed([instance]))
76
78
    def test_provider_launch_existing_security_group(self):
77
79
        """Verify that the launch works if the env security group exists"""
78
80
        instance = Instance("i-foobar", "running", dns_name="x1.example.com")
79
 
        security_group = SecurityGroup("ensemble-moon", "some description")
 
81
        security_group = SecurityGroup("juju-moon", "some description")
80
82
 
81
83
        self.ec2.describe_security_groups()
82
84
        self.mocker.result(succeed([security_group]))
98
100
        """Verify that the launch works if the machine security group exists"""
99
101
        instance = Instance("i-foobar", "running", dns_name="x1.example.com")
100
102
        machine_group = SecurityGroup(
101
 
            "ensemble-moon-1", "some description")
 
103
            "juju-moon-1", "some description")
102
104
 
103
105
        self.ec2.describe_security_groups()
104
106
        self.mocker.result(succeed([machine_group]))
125
127
        that security group, generally because it is still shutting
126
128
        down."""
127
129
        machine_group = SecurityGroup(
128
 
            "ensemble-moon-1", "some description")
 
130
            "juju-moon-1", "some description")
129
131
 
130
132
        self.ec2.describe_security_groups()
131
133
        self.mocker.result(succeed([machine_group]))
142
144
        self.assertEqual(
143
145
            str(ex),
144
146
            "Unexpected EC2Error deleting security group "
145
 
            "ensemble-moon-1: There are active instances using security group "
146
 
            "'ensemble-moon-1'")
 
147
            "juju-moon-1: There are active instances using security group "
 
148
            "'juju-moon-1'")
147
149
 
148
 
    def test_launch_with_no_ensemble_s3_state(self):
 
150
    def test_launch_with_no_juju_s3_state(self):
149
151
        """
150
 
        Attempting to launch without any ensemble saved state, means
 
152
        Attempting to launch without any juju saved state, means
151
153
        we can't provide a way for a launched instance to connect
152
154
        to the zookeeper shared state. An assertion error is raised
153
155
        instead of allowing this.
160
162
        self.assertFailure(d, EnvironmentNotFound)
161
163
        return d
162
164
 
163
 
    def test_launch_with_no_ensemble_zookeeper_hosts(self):
 
165
    def test_launch_with_no_juju_zookeeper_hosts(self):
164
166
        """
165
 
        Attempting to launch without any ensemble zookeeper hosts, means
 
167
        Attempting to launch without any juju zookeeper hosts, means
166
168
        we can't provide a way for a launched instance to connect
167
169
        to the zookeeper shared state. An assertion error is raised
168
170
        instead of allowing this.