Merge lp:~rvb/maas/fix-power-query into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 3049
Proposed branch: lp:~rvb/maas/fix-power-query
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 86 lines (+40/-4)
2 files modified
src/provisioningserver/rpc/clusterservice.py (+4/-4)
src/provisioningserver/rpc/tests/test_clusterservice.py (+36/-0)
To merge this branch: bzr merge lp:~rvb/maas/fix-power-query
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+235442@code.launchpad.net

Commit message

Fix call to get_power_state() in cluster.PowerQuery.responder.

Description of the change

Looks like tests were not even written for this code. How this got in in the first place is anyone's guess.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (19.5 KiB)

The attempt to merge lp:~rvb/maas/fix-power-query into lp:maas failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Get:2 http://security.ubuntu.com trusty-security Release [59.7 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates Release [59.7 kB]
Get:5 http://security.ubuntu.com trusty-security/main Sources [44.3 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Get:6 http://security.ubuntu.com trusty-security/universe Sources [10.8 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Get:7 http://security.ubuntu.com trusty-security/main amd64 Packages [140 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [47.1 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Get:9 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [120 kB]
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [84.7 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [320 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [203 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Fetched 1,090 kB in 0s (1,700 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-amqplib python-bzrlib python-celery python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mimeparse python-mock python-netaddr python-netifaces python-nose python-oauth python-oops python-oops-amqp python-oops-datedir-repo python-oops-twisted python-oops-wsgi python-openssl pytho...

Revision history for this message
MAAS Lander (maas-lander) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (19.3 KiB)

The attempt to merge lp:~rvb/maas/fix-power-query into lp:maas failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Get:2 http://security.ubuntu.com trusty-security Release [59.7 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates Release [59.7 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:5 http://security.ubuntu.com trusty-security/main Sources [44.3 kB]
Get:6 http://security.ubuntu.com trusty-security/universe Sources [10.8 kB]
Get:7 http://security.ubuntu.com trusty-security/main amd64 Packages [140 kB]
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [47.1 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Get:9 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [120 kB]
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [84.7 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [320 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [203 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 1,091 kB in 0s (2,007 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-amqplib python-bzrlib python-celery python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mimeparse python-mock python-netaddr python-netifaces python-nose python-oauth python-oops python-oops-amqp python-oops-datedir-repo python-oops-twisted python-oops-wsgi python-openssl pytho...

Revision history for this message
MAAS Lander (maas-lander) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/rpc/clusterservice.py'
2--- src/provisioningserver/rpc/clusterservice.py 2014-09-17 10:57:10 +0000
3+++ src/provisioningserver/rpc/clusterservice.py 2014-09-22 15:51:19 +0000
4@@ -193,10 +193,10 @@
5
6 @cluster.PowerQuery.responder
7 def power_query(self, system_id, hostname, power_type, context):
8- state = get_power_state(
9- system_id, hostname, power_type, power_change='query',
10- context=context)
11- return {'state': state}
12+ d = get_power_state(
13+ system_id, hostname, power_type, context=context)
14+ d.addCallback(lambda x: {'state': x})
15+ return d
16
17 @cluster.ConfigureDHCPv4.responder
18 def configure_dhcpv4(self, omapi_key, subnet_configs):
19
20=== modified file 'src/provisioningserver/rpc/tests/test_clusterservice.py'
21--- src/provisioningserver/rpc/tests/test_clusterservice.py 2014-09-18 12:44:38 +0000
22+++ src/provisioningserver/rpc/tests/test_clusterservice.py 2014-09-22 15:51:19 +0000
23@@ -21,6 +21,7 @@
24 from itertools import product
25 import json
26 import os.path
27+import random
28 from random import randint
29 from urlparse import urlparse
30
31@@ -61,6 +62,7 @@
32 exceptions,
33 getRegionClient,
34 osystems as osystems_rpc_module,
35+ power as power_module,
36 region,
37 )
38 from provisioningserver.rpc.clusterservice import (
39@@ -74,6 +76,7 @@
40 running_monitors,
41 )
42 from provisioningserver.rpc.osystems import gen_operating_systems
43+from provisioningserver.rpc.power import QUERY_POWER_TYPES
44 from provisioningserver.rpc.testing import (
45 are_valid_tls_parameters,
46 call_responder,
47@@ -989,6 +992,39 @@
48 return d.addErrback(check)
49
50
51+class TestClusterProtocol_PowerQuery(MAASTestCase):
52+
53+ run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
54+
55+ def test_is_registered(self):
56+ protocol = Cluster()
57+ responder = protocol.locateResponder(
58+ cluster.PowerQuery.commandName)
59+ self.assertIsNot(responder, None)
60+
61+ @inlineCallbacks
62+ def test_returns_power_state(self):
63+ state = random.choice(['on', 'off'])
64+ perform_power_query = self.patch(
65+ power_module, "perform_power_query")
66+ perform_power_query.return_value = state
67+
68+ arguments = {
69+ 'system_id': factory.make_name(''),
70+ 'hostname': factory.make_name(''),
71+ 'power_type': random.choice(QUERY_POWER_TYPES),
72+ 'context': factory.make_name(''),
73+ }
74+ observed = yield call_responder(
75+ Cluster(), cluster.PowerQuery, arguments)
76+ self.assertEqual({'state': state}, observed)
77+ self.assertThat(
78+ perform_power_query,
79+ MockCalledOnceWith(
80+ arguments['system_id'], arguments['hostname'],
81+ arguments['power_type'], arguments['context']))
82+
83+
84 class TestClusterProtocol_ConfigureDHCP(MAASTestCase):
85
86 scenarios = (