launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #08141
[Merge] lp:~rvb/maas/power-job4 into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/power-job4 into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/power-job4/+merge/107068
This branch fixes the tests I broke in lp:~rvb/maas/power-job3. Now a node needs to have a MAC address to be started.
--
https://code.launchpad.net/~rvb/maas/power-job4/+merge/107068
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/power-job4 into lp:maas.
=== modified file 'src/maasserver/testing/factory.py'
--- src/maasserver/testing/factory.py 2012-05-03 08:48:25 +0000
+++ src/maasserver/testing/factory.py 2012-05-23 16:34:35 +0000
@@ -82,8 +82,8 @@
finally:
NODE_TRANSITIONS[None] = valid_initial_states
- def make_node(self, hostname='', set_hostname=False, status=None,
- architecture=ARCHITECTURE.i386, updated=None,
+ def make_node(self, mac=False, hostname='', set_hostname=False,
+ status=None, architecture=ARCHITECTURE.i386, updated=None,
created=None, **kwargs):
# hostname=None is a valid value, hence the set_hostname trick.
if hostname is '' and set_hostname:
@@ -94,6 +94,8 @@
hostname=hostname, status=status, architecture=architecture,
**kwargs)
self._save_node_unchecked(node)
+ if mac:
+ self.make_mac_address(node=node)
# Update the 'updated'/'created' fields with a call to 'update'
# preventing a call to save() from overriding the values.
=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py 2012-05-18 06:14:28 +0000
+++ src/maasserver/tests/test_api.py 2012-05-23 16:34:35 +0000
@@ -701,20 +701,20 @@
self.assertEqual(httplib.FORBIDDEN, response.status_code)
def test_POST_start_returns_node(self):
- node = factory.make_node(owner=self.logged_in_user)
+ node = factory.make_node(owner=self.logged_in_user, mac=True)
response = self.client.post(self.get_node_uri(node), {'op': 'start'})
self.assertEqual(httplib.OK, response.status_code)
self.assertEqual(
node.system_id, json.loads(response.content)['system_id'])
def test_POST_start_may_be_repeated(self):
- node = factory.make_node(owner=self.logged_in_user)
+ node = factory.make_node(owner=self.logged_in_user, mac=True)
self.client.post(self.get_node_uri(node), {'op': 'start'})
response = self.client.post(self.get_node_uri(node), {'op': 'start'})
self.assertEqual(httplib.OK, response.status_code)
def test_POST_start_stores_user_data(self):
- node = factory.make_node(owner=self.logged_in_user)
+ node = factory.make_node(owner=self.logged_in_user, mac=True)
user_data = (
b'\xff\x00\xff\xfe\xff\xff\xfe' +
factory.getRandomString().encode('ascii'))
=== modified file 'src/maasserver/tests/test_node_action.py'
--- src/maasserver/tests/test_node_action.py 2012-05-08 16:22:48 +0000
+++ src/maasserver/tests/test_node_action.py 2012-05-23 16:34:35 +0000
@@ -29,9 +29,10 @@
RetryCommissioning,
StartNode,
)
-from maasserver.provisioning import get_provisioning_api_proxy
from maasserver.testing.factory import factory
from maasserver.testing.testcase import TestCase
+from maastesting.celery import CeleryFixture
+from provisioningserver.enum import POWER_TYPE
ALL_STATUSES = NODE_STATUS_CHOICES_DICT.keys()
@@ -187,22 +188,28 @@
urlparse(unicode(e)).path)
def test_AcceptAndCommission_starts_commissioning(self):
- node = factory.make_node(status=NODE_STATUS.DECLARED)
+ fixture = self.useFixture(CeleryFixture())
+ node = factory.make_node(
+ mac=True, status=NODE_STATUS.DECLARED,
+ power_type=POWER_TYPE.WAKE_ON_LAN)
action = AcceptAndCommission(node, factory.make_admin())
action.execute()
self.assertEqual(NODE_STATUS.COMMISSIONING, node.status)
self.assertEqual(
- 'start',
- get_provisioning_api_proxy().power_status.get(node.system_id))
+ 'provisioningserver.tasks.power_on',
+ fixture.tasks[0]['task'].name)
def test_RetryCommissioning_starts_commissioning(self):
- node = factory.make_node(status=NODE_STATUS.FAILED_TESTS)
+ fixture = self.useFixture(CeleryFixture())
+ node = factory.make_node(
+ mac=True, status=NODE_STATUS.FAILED_TESTS,
+ power_type=POWER_TYPE.WAKE_ON_LAN)
action = RetryCommissioning(node, factory.make_admin())
action.execute()
self.assertEqual(NODE_STATUS.COMMISSIONING, node.status)
self.assertEqual(
- 'start',
- get_provisioning_api_proxy().power_status.get(node.system_id))
+ 'provisioningserver.tasks.power_on',
+ fixture.tasks[0]['task'].name)
def test_StartNode_inhibit_allows_user_with_SSH_key(self):
user_with_key = factory.make_user()
@@ -218,11 +225,14 @@
self.assertIn("SSH key", inhibition)
def test_StartNode_acquires_and_starts_node(self):
- node = factory.make_node(status=NODE_STATUS.READY)
+ fixture = self.useFixture(CeleryFixture())
+ node = factory.make_node(
+ mac=True, status=NODE_STATUS.READY,
+ power_type=POWER_TYPE.WAKE_ON_LAN)
user = factory.make_user()
StartNode(node, user).execute()
self.assertEqual(NODE_STATUS.ALLOCATED, node.status)
self.assertEqual(user, node.owner)
self.assertEqual(
- 'start',
- get_provisioning_api_proxy().power_status.get(node.system_id))
+ 'provisioningserver.tasks.power_on',
+ fixture.tasks[0]['task'].name)