~hazmat/pyjuju/rapi-login

« back to all changes in this revision

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

  • Committer: Kapil Thangavelu
  • Date: 2012-10-20 19:23:22 UTC
  • mfrom: (605.1.11 rapi-delta)
  • Revision ID: kapil@canonical.com-20121020192322-z34z59siiyz7lhcz
Merged svc-change-units into export-import.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
from StringIO import StringIO
7
7
from twisted.internet import defer
8
8
from twisted.internet.defer import inlineCallbacks
9
 
from twisted.web.error import Error
10
9
 
11
10
from juju.errors import ProviderError
12
11
from juju.lib.mocker import ANY
72
71
        provider = self._get_provider(
73
72
            FakeMAASHTTPConnectionWithNoAvailableNodes)
74
73
        machine_data = {
75
 
            "machine-id": "foo", "constraints": {"maas-name": None}}
 
74
            "machine-id": "foo", "constraints": {"ubuntu-series": "splendid"}}
76
75
        d = provider.start_machine(machine_data)
77
76
 
78
77
        # These arbitrary fake failure values come from
94
93
        # Try to start up that node using the fake MAAS.
95
94
        provider = self._get_provider(FakeMAASHTTPConnection)
96
95
        machine_data = {
97
 
            "machine-id": machine_id, "constraints": {"maas-name": None}}
 
96
            "machine-id": "foo", "constraints": {"ubuntu-series": "splendid"}}
98
97
        machine_list = yield provider.start_machine(machine_data)
99
98
 
100
99
        # Test that it returns a list containing a single MAASMachine
118
117
        self.assertEqual("moon", target_node["hostname"])
119
118
        machine_id = "foo"
120
119
        provider = self._get_provider(FakeMAASHTTPConnection)
121
 
        constraints = {"maas-name": "moon"}
 
120
        constraints = {"maas-name": "moon", "ubuntu-series": "splendid"}
122
121
        machine_data = {"machine-id": machine_id, "constraints": constraints}
123
122
        machine_list = yield provider.start_machine(machine_data)
124
123
 
147
146
        # The following operations happen in sequence.
148
147
        mocker.order()
149
148
        # First, the node is acquired.
150
 
        mock_client.acquire_node({"maas-name": None})
 
149
        mock_client.acquire_node({"ubuntu-series": "precise"})
151
150
        mocker.result({"resource_uri": "/node/123"})
152
151
        # Second, the node is started. We simulate a failure at this stage.
153
 
        mock_client.start_node("/node/123", ANY)
 
152
        mock_client.start_node("/node/123", "precise", ANY)
154
153
        mocker.throw(ZeroDivisionError)
155
154
        # Last, the node is released.
156
155
        mock_client.release_node("/node/123")
158
157
 
159
158
        mocker.replay()
160
159
        return self.assertFailure(
161
 
            MAASLaunchMachine(mock_provider, {"maas-name": None}).run("fred"),
 
160
            MAASLaunchMachine(mock_provider,
 
161
                              {"ubuntu-series": "precise"}).run("fred"),
162
162
            ZeroDivisionError)