Merge lp:~newell-jensen/maas/fix-1602487 into lp:~maas-committers/maas/trunk

Proposed by Newell Jensen
Status: Merged
Approved by: Newell Jensen
Approved revision: no longer in the source branch.
Merged at revision: 5198
Proposed branch: lp:~newell-jensen/maas/fix-1602487
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 372 lines (+62/-67)
3 files modified
src/maasserver/models/node.py (+11/-8)
src/maasserver/models/tests/test_node.py (+45/-56)
src/maasserver/tests/test_node_action.py (+6/-3)
To merge this branch: bzr merge lp:~newell-jensen/maas/fix-1602487
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+300387@code.launchpad.net

Commit message

Factor out the addErrback for resetting the node's status into _start from start_commissioning. Makes it so if there is an error during deployment, the status will be reset.

To post a comment you must log in.
Revision history for this message
Newell Jensen (newell-jensen) wrote :

This was testing on OIL's integration server.

Revision history for this message
Gavin Panella (allenap) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py 2016-07-15 18:57:25 +0000
+++ src/maasserver/models/node.py 2016-07-18 20:09:23 +0000
@@ -1657,7 +1657,7 @@
1657 # Node.start() has synchronous and asynchronous parts, so catch1657 # Node.start() has synchronous and asynchronous parts, so catch
1658 # exceptions arising synchronously, and chain callbacks to the1658 # exceptions arising synchronously, and chain callbacks to the
1659 # Deferred it returns for the asynchronous (post-commit) bits.1659 # Deferred it returns for the asynchronous (post-commit) bits.
1660 starting = self._start(user, commissioning_user_data)1660 starting = self._start(user, commissioning_user_data, old_status)
1661 except Exception as error:1661 except Exception as error:
1662 self.status = old_status1662 self.status = old_status
1663 self.save()1663 self.save()
@@ -1688,11 +1688,6 @@
1688 callOut, self._start_commissioning_async, is_starting,1688 callOut, self._start_commissioning_async, is_starting,
1689 self.hostname)1689 self.hostname)
16901690
1691 # If there's an error, reset the node's status.
1692 starting.addErrback(
1693 callOutToDatabase, Node._set_status, self.system_id,
1694 status=old_status)
1695
1696 def eb_start(failure, hostname):1691 def eb_start(failure, hostname):
1697 maaslog.error(1692 maaslog.error(
1698 "%s: Could not start node for commissioning: %s",1693 "%s: Could not start node for commissioning: %s",
@@ -2135,6 +2130,7 @@
21352130
2136 # Change the status of the node now to avoid races when starting2131 # Change the status of the node now to avoid races when starting
2137 # nodes in bulk.2132 # nodes in bulk.
2133 old_status = self.status
2138 self.status = NODE_STATUS.DISK_ERASING2134 self.status = NODE_STATUS.DISK_ERASING
2139 self.save()2135 self.save()
21402136
@@ -2142,7 +2138,7 @@
2142 # Node.start() has synchronous and asynchronous parts, so catch2138 # Node.start() has synchronous and asynchronous parts, so catch
2143 # exceptions arising synchronously, and chain callbacks to the2139 # exceptions arising synchronously, and chain callbacks to the
2144 # Deferred it returns for the asynchronous (post-commit) bits.2140 # Deferred it returns for the asynchronous (post-commit) bits.
2145 starting = self._start(user, disk_erase_user_data)2141 starting = self._start(user, disk_erase_user_data, old_status)
2146 except Exception as error:2142 except Exception as error:
2147 # We always mark the node as failed here, although we could2143 # We always mark the node as failed here, although we could
2148 # potentially move it back to the state it was in previously. For2144 # potentially move it back to the state it was in previously. For
@@ -3019,7 +3015,7 @@
3019 return client_idents, fallback_idents3015 return client_idents, fallback_idents
30203016
3021 @transactional3017 @transactional
3022 def _start(self, user, user_data=None):3018 def _start(self, user, user_data=None, old_status=None):
3023 """Request on given user's behalf that the node be started up.3019 """Request on given user's behalf that the node be started up.
30243020
3025 :param user: Requesting user.3021 :param user: Requesting user.
@@ -3055,6 +3051,7 @@
3055 NodeUserData.objects.set_user_data(self, user_data)3051 NodeUserData.objects.set_user_data(self, user_data)
30563052
3057 if self.status == NODE_STATUS.ALLOCATED:3053 if self.status == NODE_STATUS.ALLOCATED:
3054 old_status = self.status
3058 # Claim AUTO IP addresses for the node if it's ALLOCATED.3055 # Claim AUTO IP addresses for the node if it's ALLOCATED.
3059 # The current state being ALLOCATED is our indication that the node3056 # The current state being ALLOCATED is our indication that the node
3060 # is being deployed for the first time.3057 # is being deployed for the first time.
@@ -3084,6 +3081,12 @@
3084 callOutToDatabase, Node._set_status_expires,3081 callOutToDatabase, Node._set_status_expires,
3085 self.system_id, deployment_timeout)3082 self.system_id, deployment_timeout)
30863083
3084 if old_status is not None:
3085 # If there's an error, reset the node's status.
3086 d.addErrback(
3087 callOutToDatabase, Node._set_status, self.system_id,
3088 status=old_status)
3089
3087 # If any part of this processes fails be sure to release the grabbed3090 # If any part of this processes fails be sure to release the grabbed
3088 # auto IP addresses.3091 # auto IP addresses.
3089 if claimed_ips:3092 if claimed_ips:
30903093
=== modified file 'src/maasserver/models/tests/test_node.py'
--- src/maasserver/models/tests/test_node.py 2016-07-15 18:57:25 +0000
+++ src/maasserver/models/tests/test_node.py 2016-07-18 20:09:23 +0000
@@ -1414,7 +1414,8 @@
1414 status=NODE_STATUS.ALLOCATED, owner=owner, agent_name=agent_name)1414 status=NODE_STATUS.ALLOCATED, owner=owner, agent_name=agent_name)
1415 node_start = self.patch(node, '_start')1415 node_start = self.patch(node, '_start')
1416 # Return a post-commit hook from Node.start().1416 # Return a post-commit hook from Node.start().
1417 node_start.side_effect = lambda user, user_data: post_commit()1417 node_start.side_effect = (
1418 lambda user, user_data, old_status: post_commit())
1418 Config.objects.set_config('disk_erase_with_secure_erase', True)1419 Config.objects.set_config('disk_erase_with_secure_erase', True)
1419 Config.objects.set_config('disk_erase_with_quick_erase', True)1420 Config.objects.set_config('disk_erase_with_quick_erase', True)
1420 with post_commit_hooks:1421 with post_commit_hooks:
@@ -1435,7 +1436,8 @@
1435 status=NODE_STATUS.ALLOCATED, owner=owner, agent_name=agent_name)1436 status=NODE_STATUS.ALLOCATED, owner=owner, agent_name=agent_name)
1436 node_start = self.patch(node, '_start')1437 node_start = self.patch(node, '_start')
1437 # Return a post-commit hook from Node.start().1438 # Return a post-commit hook from Node.start().
1438 node_start.side_effect = lambda user, user_data: post_commit()1439 node_start.side_effect = (
1440 lambda user, user_data, old_status: post_commit())
1439 Config.objects.set_config('disk_erase_with_secure_erase', False)1441 Config.objects.set_config('disk_erase_with_secure_erase', False)
1440 Config.objects.set_config('disk_erase_with_quick_erase', False)1442 Config.objects.set_config('disk_erase_with_quick_erase', False)
1441 with post_commit_hooks:1443 with post_commit_hooks:
@@ -1456,26 +1458,28 @@
1456 status=NODE_STATUS.ALLOCATED, owner=owner, agent_name=agent_name)1458 status=NODE_STATUS.ALLOCATED, owner=owner, agent_name=agent_name)
1457 node_start = self.patch(node, '_start')1459 node_start = self.patch(node, '_start')
1458 # Return a post-commit hook from Node.start().1460 # Return a post-commit hook from Node.start().
1459 node_start.side_effect = lambda user, user_data: post_commit()1461 node_start.side_effect = (
1462 lambda user, user_data, old_status: post_commit())
1460 with post_commit_hooks:1463 with post_commit_hooks:
1461 node.start_disk_erasing(owner)1464 node.start_disk_erasing(owner)
1462 self.expectThat(node.owner, Equals(owner))1465 self.expectThat(node.owner, Equals(owner))
1463 self.expectThat(node.status, Equals(NODE_STATUS.DISK_ERASING))1466 self.expectThat(node.status, Equals(NODE_STATUS.DISK_ERASING))
1464 self.expectThat(node.agent_name, Equals(agent_name))1467 self.expectThat(node.agent_name, Equals(agent_name))
1465 self.assertThat(1468 self.assertThat(
1466 node_start, MockCalledOnceWith(owner, ANY))1469 node_start, MockCalledOnceWith(owner, ANY, NODE_STATUS.ALLOCATED))
14671470
1468 def test_start_disk_erasing_logs_user_request(self):1471 def test_start_disk_erasing_logs_user_request(self):
1469 owner = factory.make_User()1472 owner = factory.make_User()
1470 node = factory.make_Node(status=NODE_STATUS.ALLOCATED, owner=owner)1473 node = factory.make_Node(status=NODE_STATUS.ALLOCATED, owner=owner)
1471 node_start = self.patch(node, '_start')1474 node_start = self.patch(node, '_start')
1472 # Return a post-commit hook from Node.start().1475 # Return a post-commit hook from Node.start().
1473 node_start.side_effect = lambda user, user_data: post_commit()1476 node_start.side_effect = (
1477 lambda user, user_data, old_status: post_commit())
1474 register_event = self.patch(node, '_register_request_event')1478 register_event = self.patch(node, '_register_request_event')
1475 with post_commit_hooks:1479 with post_commit_hooks:
1476 node.start_disk_erasing(owner)1480 node.start_disk_erasing(owner)
1477 self.assertThat(1481 self.assertThat(
1478 node_start, MockCalledOnceWith(owner, ANY))1482 node_start, MockCalledOnceWith(owner, ANY, NODE_STATUS.ALLOCATED))
1479 self.assertThat(register_event, MockCalledOnceWith(1483 self.assertThat(register_event, MockCalledOnceWith(
1480 owner, EVENT_TYPES.REQUEST_NODE_ERASE_DISK,1484 owner, EVENT_TYPES.REQUEST_NODE_ERASE_DISK,
1481 action='start disk erasing', comment=None))1485 action='start disk erasing', comment=None))
@@ -1538,7 +1542,7 @@
15381542
1539 self.assertThat(1543 self.assertThat(
1540 node_start, MockCalledOnceWith(1544 node_start, MockCalledOnceWith(
1541 admin, generate_user_data.return_value))1545 admin, generate_user_data.return_value, NODE_STATUS.ALLOCATED))
1542 self.assertEqual(NODE_STATUS.FAILED_DISK_ERASING, node.status)1546 self.assertEqual(NODE_STATUS.FAILED_DISK_ERASING, node.status)
15431547
1544 def test_start_disk_erasing_sets_status_on_post_commit_error(self):1548 def test_start_disk_erasing_sets_status_on_post_commit_error(self):
@@ -2159,7 +2163,8 @@
2159 interface=True, status=NODE_STATUS.NEW, power_type='manual')2163 interface=True, status=NODE_STATUS.NEW, power_type='manual')
2160 node_start = self.patch(node, '_start')2164 node_start = self.patch(node, '_start')
2161 # Return a post-commit hook from Node.start().2165 # Return a post-commit hook from Node.start().
2162 node_start.side_effect = lambda user, user_data: post_commit()2166 node_start.side_effect = (
2167 lambda user, user_data, old_status: post_commit())
2163 admin = factory.make_admin()2168 admin = factory.make_admin()
2164 node.start_commissioning(admin)2169 node.start_commissioning(admin)
2165 post_commit_hooks.reset() # Ignore these for now.2170 post_commit_hooks.reset() # Ignore these for now.
@@ -2168,7 +2173,8 @@
2168 'status': NODE_STATUS.COMMISSIONING,2173 'status': NODE_STATUS.COMMISSIONING,
2169 }2174 }
2170 self.assertAttributes(node, expected_attrs)2175 self.assertAttributes(node, expected_attrs)
2171 self.assertThat(node_start, MockCalledOnceWith(admin, ANY))2176 self.assertThat(node_start, MockCalledOnceWith(
2177 admin, ANY, NODE_STATUS.NEW))
21722178
2173 def test_start_commissioning_sets_options(self):2179 def test_start_commissioning_sets_options(self):
2174 rack = factory.make_RackController()2180 rack = factory.make_RackController()
@@ -2177,7 +2183,8 @@
2177 bmc_connected_to=rack)2183 bmc_connected_to=rack)
2178 node_start = self.patch(node, '_start')2184 node_start = self.patch(node, '_start')
2179 # Return a post-commit hook from Node.start().2185 # Return a post-commit hook from Node.start().
2180 node_start.side_effect = lambda user, user_data: post_commit()2186 node_start.side_effect = (
2187 lambda user, user_data, old_status: post_commit())
2181 admin = factory.make_admin()2188 admin = factory.make_admin()
2182 enable_ssh = factory.pick_bool()2189 enable_ssh = factory.pick_bool()
2183 skip_networking = factory.pick_bool()2190 skip_networking = factory.pick_bool()
@@ -2197,7 +2204,8 @@
2197 def test_start_commissioning_sets_user_data(self):2204 def test_start_commissioning_sets_user_data(self):
2198 node = factory.make_Node(status=NODE_STATUS.NEW)2205 node = factory.make_Node(status=NODE_STATUS.NEW)
2199 node_start = self.patch(node, '_start')2206 node_start = self.patch(node, '_start')
2200 node_start.side_effect = lambda user, user_data: post_commit()2207 node_start.side_effect = (
2208 lambda user, user_data, old_status: post_commit())
2201 user_data = factory.make_string().encode('ascii')2209 user_data = factory.make_string().encode('ascii')
2202 generate_user_data = self.patch(2210 generate_user_data = self.patch(
2203 commissioning, 'generate_user_data')2211 commissioning, 'generate_user_data')
@@ -2205,12 +2213,14 @@
2205 admin = factory.make_admin()2213 admin = factory.make_admin()
2206 node.start_commissioning(admin)2214 node.start_commissioning(admin)
2207 post_commit_hooks.reset() # Ignore these for now.2215 post_commit_hooks.reset() # Ignore these for now.
2208 self.assertThat(node_start, MockCalledOnceWith(admin, user_data))2216 self.assertThat(node_start, MockCalledOnceWith(
2217 admin, user_data, NODE_STATUS.NEW))
22092218
2210 def test_start_commissioning_sets_min_hwe_kernel(self):2219 def test_start_commissioning_sets_min_hwe_kernel(self):
2211 node = factory.make_Node(status=NODE_STATUS.NEW)2220 node = factory.make_Node(status=NODE_STATUS.NEW)
2212 node_start = self.patch(node, '_start')2221 node_start = self.patch(node, '_start')
2213 node_start.side_effect = lambda user, user_data: post_commit()2222 node_start.side_effect = (
2223 lambda user, user_data, old_status: post_commit())
2214 user_data = factory.make_string().encode('ascii')2224 user_data = factory.make_string().encode('ascii')
2215 generate_user_data = self.patch(2225 generate_user_data = self.patch(
2216 commissioning, 'generate_user_data')2226 commissioning, 'generate_user_data')
@@ -2224,7 +2234,8 @@
2224 def test_start_commissioning_clears_node_commissioning_results(self):2234 def test_start_commissioning_clears_node_commissioning_results(self):
2225 node = factory.make_Node(status=NODE_STATUS.NEW)2235 node = factory.make_Node(status=NODE_STATUS.NEW)
2226 node_start = self.patch(node, '_start')2236 node_start = self.patch(node, '_start')
2227 node_start.side_effect = lambda user, user_data: post_commit()2237 node_start.side_effect = (
2238 lambda user, user_data, old_status: post_commit())
2228 NodeResult.objects.store_data(2239 NodeResult.objects.store_data(
2229 node, factory.make_string(),2240 node, factory.make_string(),
2230 random.randint(0, 10),2241 random.randint(0, 10),
@@ -2237,7 +2248,8 @@
2237 def test_start_commissioning_clears_storage_configuration(self):2248 def test_start_commissioning_clears_storage_configuration(self):
2238 node = factory.make_Node(status=NODE_STATUS.NEW)2249 node = factory.make_Node(status=NODE_STATUS.NEW)
2239 node_start = self.patch(node, '_start')2250 node_start = self.patch(node, '_start')
2240 node_start.side_effect = lambda user, user_data: post_commit()2251 node_start.side_effect = (
2252 lambda user, user_data, old_status: post_commit())
2241 clear_storage = self.patch_autospec(2253 clear_storage = self.patch_autospec(
2242 node, '_clear_full_storage_configuration')2254 node, '_clear_full_storage_configuration')
2243 admin = factory.make_admin()2255 admin = factory.make_admin()
@@ -2248,7 +2260,8 @@
2248 def test_start_commissioning_doesnt_clear_storage_configuration(self):2260 def test_start_commissioning_doesnt_clear_storage_configuration(self):
2249 node = factory.make_Node(status=NODE_STATUS.NEW)2261 node = factory.make_Node(status=NODE_STATUS.NEW)
2250 node_start = self.patch(node, '_start')2262 node_start = self.patch(node, '_start')
2251 node_start.side_effect = lambda user, user_data: post_commit()2263 node_start.side_effect = (
2264 lambda user, user_data, old_status: post_commit())
2252 clear_storage = self.patch_autospec(2265 clear_storage = self.patch_autospec(
2253 node, '_clear_full_storage_configuration')2266 node, '_clear_full_storage_configuration')
2254 admin = factory.make_admin()2267 admin = factory.make_admin()
@@ -2259,7 +2272,8 @@
2259 def test_start_commissioning_calls__clear_networking_configuration(self):2272 def test_start_commissioning_calls__clear_networking_configuration(self):
2260 node = factory.make_Node(status=NODE_STATUS.NEW)2273 node = factory.make_Node(status=NODE_STATUS.NEW)
2261 node_start = self.patch(node, '_start')2274 node_start = self.patch(node, '_start')
2262 node_start.side_effect = lambda user, user_data: post_commit()2275 node_start.side_effect = (
2276 lambda user, user_data, old_status: post_commit())
2263 clear_networking = self.patch_autospec(2277 clear_networking = self.patch_autospec(
2264 node, '_clear_networking_configuration')2278 node, '_clear_networking_configuration')
2265 admin = factory.make_admin()2279 admin = factory.make_admin()
@@ -2270,7 +2284,8 @@
2270 def test_start_commissioning_doesnt_call__clear_networking(self):2284 def test_start_commissioning_doesnt_call__clear_networking(self):
2271 node = factory.make_Node(status=NODE_STATUS.NEW)2285 node = factory.make_Node(status=NODE_STATUS.NEW)
2272 node_start = self.patch(node, '_start')2286 node_start = self.patch(node, '_start')
2273 node_start.side_effect = lambda user, user_data: post_commit()2287 node_start.side_effect = (
2288 lambda user, user_data, old_status: post_commit())
2274 clear_networking = self.patch_autospec(2289 clear_networking = self.patch_autospec(
2275 node, '_clear_networking_configuration')2290 node, '_clear_networking_configuration')
2276 admin = factory.make_admin()2291 admin = factory.make_admin()
@@ -2313,41 +2328,10 @@
23132328
2314 self.assertThat(2329 self.assertThat(
2315 node_start,2330 node_start,
2316 MockCalledOnceWith(admin, generate_user_data.return_value))2331 MockCalledOnceWith(
2332 admin, generate_user_data.return_value, NODE_STATUS.NEW))
2317 self.assertEqual(NODE_STATUS.NEW, node.status)2333 self.assertEqual(NODE_STATUS.NEW, node.status)
23182334
2319 def test_start_commissioning_reverts_status_on_post_commit_error(self):
2320 # When start_commissioning encounters an error in its post-commit
2321 # hook, it will revert the node to its previous status.
2322 admin = factory.make_admin()
2323 status = random.choice(
2324 (NODE_STATUS.NEW, NODE_STATUS.READY,
2325 NODE_STATUS.FAILED_COMMISSIONING))
2326 node = factory.make_Node(status=status)
2327 # Patch out some things that we don't want to do right now.
2328 self.patch(Node, '_set_status_expires')
2329 self.patch(node, '_start').return_value = None
2330 # Fake an error during the post-commit hook.
2331 error_message = factory.make_name("error")
2332 error_type = factory.make_exception_type()
2333 _start_async = self.patch_autospec(node, "_start_commissioning_async")
2334 _start_async.side_effect = error_type(error_message)
2335 # Capture calls to _set_status.
2336 self.patch_autospec(Node, "_set_status")
2337
2338 with LoggerFixture("maas") as logger:
2339 with ExpectedException(error_type):
2340 with post_commit_hooks:
2341 node.start_commissioning(admin)
2342
2343 # The status is set to be reverted to its initial status.
2344 self.assertThat(node._set_status, MockCalledOnceWith(
2345 node.system_id, status=status))
2346 # It's logged too.
2347 self.assertThat(logger.output, Contains(
2348 "%s: Could not start node for commissioning: %s\n"
2349 % (node.hostname, error_message)))
2350
2351 def test_start_commissioning_logs_and_raises_errors_in_starting(self):2335 def test_start_commissioning_logs_and_raises_errors_in_starting(self):
2352 admin = factory.make_admin()2336 admin = factory.make_admin()
2353 node = factory.make_Node(status=NODE_STATUS.NEW)2337 node = factory.make_Node(status=NODE_STATUS.NEW)
@@ -2368,7 +2352,8 @@
2368 register_event = self.patch(node, '_register_request_event')2352 register_event = self.patch(node, '_register_request_event')
2369 node_start = self.patch(node, '_start')2353 node_start = self.patch(node, '_start')
2370 # Return a post-commit hook from Node.start().2354 # Return a post-commit hook from Node.start().
2371 node_start.side_effect = lambda user, user_data: post_commit()2355 node_start.side_effect = (
2356 lambda user, user_data, old_status: post_commit())
2372 admin = factory.make_admin()2357 admin = factory.make_admin()
2373 node.start_commissioning(admin)2358 node.start_commissioning(admin)
2374 post_commit_hooks.reset() # Ignore these for now.2359 post_commit_hooks.reset() # Ignore these for now.
@@ -2489,7 +2474,8 @@
2489 enable_ssh=True)2474 enable_ssh=True)
2490 node_start = self.patch(node, 'start')2475 node_start = self.patch(node, 'start')
2491 # Return a post-commit hook from Node.start().2476 # Return a post-commit hook from Node.start().
2492 node_start.side_effect = lambda user, user_data: post_commit()2477 node_start.side_effect = (
2478 lambda user, user_data, old_status: post_commit())
2493 admin = factory.make_admin()2479 admin = factory.make_admin()
2494 node.start_commissioning(admin)2480 node.start_commissioning(admin)
2495 post_commit_hooks.reset() # Ignore these for now.2481 post_commit_hooks.reset() # Ignore these for now.
@@ -4632,6 +4618,7 @@
4632 def test__adds_callbacks_and_errbacks_to_post_commit(self):4618 def test__adds_callbacks_and_errbacks_to_post_commit(self):
4633 user = factory.make_User()4619 user = factory.make_User()
4634 node = self.make_acquired_node_with_interface(user)4620 node = self.make_acquired_node_with_interface(user)
4621 old_status = node.status
46354622
4636 post_commit_defer = self.patch(node_module, "post_commit")4623 post_commit_defer = self.patch(node_module, "post_commit")
4637 mock_power_control = self.patch(Node, "_power_control_node")4624 mock_power_control = self.patch(Node, "_power_control_node")
@@ -4645,10 +4632,12 @@
4645 callOutToDatabase, Node._set_status_expires,4632 callOutToDatabase, Node._set_status_expires,
4646 node.system_id, node.get_deployment_time()))4633 node.system_id, node.get_deployment_time()))
46474634
4648 # Adds errback to release auto ips.4635 # Adds errback to reset status and release auto ips.
4649 self.assertThat(4636 self.assertThat(
4650 post_commit_defer.addErrback, MockCalledOnceWith(4637 post_commit_defer.addErrback, MockCallsMatch(
4651 callOutToDatabase, node.release_auto_ips))4638 call(callOutToDatabase, node._set_status,
4639 node.system_id, status=old_status),
4640 call(callOutToDatabase, node.release_auto_ips)))
46524641
4653 def test_storage_layout_issues_returns_invalid_no_boot_arm64_non_efi(self):4642 def test_storage_layout_issues_returns_invalid_no_boot_arm64_non_efi(self):
4654 node = factory.make_Node(4643 node = factory.make_Node(
46554644
=== modified file 'src/maasserver/tests/test_node_action.py'
--- src/maasserver/tests/test_node_action.py 2016-07-15 00:42:25 +0000
+++ src/maasserver/tests/test_node_action.py 2016-07-18 20:09:23 +0000
@@ -292,14 +292,15 @@
292 interface=True, status=self.status,292 interface=True, status=self.status,
293 power_type='manual', power_state=POWER_STATE.OFF)293 power_type='manual', power_state=POWER_STATE.OFF)
294 node_start = self.patch(node, '_start')294 node_start = self.patch(node, '_start')
295 node_start.side_effect = lambda user, user_data: post_commit()295 node_start.side_effect = (
296 lambda user, user_data, old_status: post_commit())
296 admin = factory.make_admin()297 admin = factory.make_admin()
297 action = Commission(node, admin)298 action = Commission(node, admin)
298 with post_commit_hooks:299 with post_commit_hooks:
299 action.execute()300 action.execute()
300 self.assertEqual(NODE_STATUS.COMMISSIONING, node.status)301 self.assertEqual(NODE_STATUS.COMMISSIONING, node.status)
301 self.assertThat(302 self.assertThat(
302 node_start, MockCalledOnceWith(admin, ANY))303 node_start, MockCalledOnceWith(admin, ANY, ANY))
303304
304305
305class TestAbortAction(MAASTransactionServerTestCase):306class TestAbortAction(MAASTransactionServerTestCase):
@@ -734,6 +735,7 @@
734 interface=True, status=self.actionable_status,735 interface=True, status=self.actionable_status,
735 power_type='ipmi', power_state=POWER_STATE.OFF,736 power_type='ipmi', power_state=POWER_STATE.OFF,
736 owner=user, power_parameters=params)737 owner=user, power_parameters=params)
738 old_status = node.status
737 node_start = self.patch_autospec(node, '_start')739 node_start = self.patch_autospec(node, '_start')
738 node_start.return_value = None740 node_start.return_value = None
739741
@@ -742,7 +744,8 @@
742744
743 self.expectThat(node.status, Equals(NODE_STATUS.DISK_ERASING))745 self.expectThat(node.status, Equals(NODE_STATUS.DISK_ERASING))
744 self.assertThat(746 self.assertThat(
745 node_start, MockCalledOnceWith(user, user_data=ANY))747 node_start, MockCalledOnceWith(
748 user, user_data=ANY, old_status=old_status))
746749
747 def test_Release_passes_secure_erase_and_quick_erase(self):750 def test_Release_passes_secure_erase_and_quick_erase(self):
748 user = factory.make_User()751 user = factory.make_User()