~ubuntu-branches/ubuntu/raring/maas/raring-proposed

« back to all changes in this revision

Viewing changes to src/maasserver/tests/test_node.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-17 08:28:36 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20120717082836-ucb2vou8tqg353eq
Tags: 0.1+bzr777+dfsg-0ubuntu1
* New upstream release
* Only run 'maas' command as root. (LP: #974046)
  - debian/extras/maas: Check id.
  - debian/maas.install: Install in 'sbin'.
* debian/maas.postinst:
  - restart apache2 after everything gets processed.
  - Update version to handle upgrades.
* debian/extras/maas-provision: Add wrapper to access 'maasprovisiong'
  command line.
* debian/patches/99_temporary_fix_path.patch: Dropped. No longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
        node.release()
259
259
        self.assertEqual((NODE_STATUS.READY, None), (node.status, node.owner))
260
260
 
 
261
    def test_release_powers_off_node(self):
 
262
        # Test that releasing a node causes a 'power_off' celery job.
 
263
        node = factory.make_node(
 
264
            status=NODE_STATUS.ALLOCATED, owner=factory.make_user(),
 
265
            power_type=POWER_TYPE.VIRSH)
 
266
        # Prevent actual job script from running.
 
267
        self.patch(PowerAction, 'run_shell', lambda *args, **kwargs: ('', ''))
 
268
        node.release()
 
269
        self.assertEqual(
 
270
            (1, 'provisioningserver.tasks.power_off'),
 
271
            (len(self.celery.tasks), self.celery.tasks[0]['task'].name))
 
272
 
261
273
    def test_accept_enlistment_gets_node_out_of_declared_state(self):
262
274
        # If called on a node in Declared state, accept_enlistment()
263
275
        # changes the node's status, and returns the node.
607
619
                user, {'name': factory.getRandomString()}))
608
620
 
609
621
    def test_stop_nodes_stops_nodes(self):
 
622
        # We don't actually want to fire off power events, but we'll go
 
623
        # through the motions right up to the point where we'd normally
 
624
        # run shell commands.
 
625
        self.patch(PowerAction, 'run_shell', lambda *args, **kwargs: ('', ''))
610
626
        user = factory.make_user()
611
 
        node = self.make_node(user)
 
627
        node, mac = self.make_node_with_mac(
 
628
                user, power_type=POWER_TYPE.VIRSH)
612
629
        output = Node.objects.stop_nodes([node.system_id], user)
613
630
 
614
631
        self.assertItemsEqual([node], output)
615
 
        power_status = get_provisioning_api_proxy().power_status
616
 
        self.assertEqual('stop', power_status[node.system_id])
 
632
        self.assertEqual(
 
633
            (1, 'provisioningserver.tasks.power_off'),
 
634
            (
 
635
                len(self.celery.tasks),
 
636
                self.celery.tasks[0]['task'].name,
 
637
            ))
617
638
 
618
639
    def test_stop_nodes_ignores_uneditable_nodes(self):
619
640
        nodes = [