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
=== modified file 'src/provisioningserver/rpc/clusterservice.py'
--- src/provisioningserver/rpc/clusterservice.py 2014-09-17 10:57:10 +0000
+++ src/provisioningserver/rpc/clusterservice.py 2014-09-22 15:51:19 +0000
@@ -193,10 +193,10 @@
193193
194 @cluster.PowerQuery.responder194 @cluster.PowerQuery.responder
195 def power_query(self, system_id, hostname, power_type, context):195 def power_query(self, system_id, hostname, power_type, context):
196 state = get_power_state(196 d = get_power_state(
197 system_id, hostname, power_type, power_change='query',197 system_id, hostname, power_type, context=context)
198 context=context)198 d.addCallback(lambda x: {'state': x})
199 return {'state': state}199 return d
200200
201 @cluster.ConfigureDHCPv4.responder201 @cluster.ConfigureDHCPv4.responder
202 def configure_dhcpv4(self, omapi_key, subnet_configs):202 def configure_dhcpv4(self, omapi_key, subnet_configs):
203203
=== modified file 'src/provisioningserver/rpc/tests/test_clusterservice.py'
--- src/provisioningserver/rpc/tests/test_clusterservice.py 2014-09-18 12:44:38 +0000
+++ src/provisioningserver/rpc/tests/test_clusterservice.py 2014-09-22 15:51:19 +0000
@@ -21,6 +21,7 @@
21from itertools import product21from itertools import product
22import json22import json
23import os.path23import os.path
24import random
24from random import randint25from random import randint
25from urlparse import urlparse26from urlparse import urlparse
2627
@@ -61,6 +62,7 @@
61 exceptions,62 exceptions,
62 getRegionClient,63 getRegionClient,
63 osystems as osystems_rpc_module,64 osystems as osystems_rpc_module,
65 power as power_module,
64 region,66 region,
65 )67 )
66from provisioningserver.rpc.clusterservice import (68from provisioningserver.rpc.clusterservice import (
@@ -74,6 +76,7 @@
74 running_monitors,76 running_monitors,
75 )77 )
76from provisioningserver.rpc.osystems import gen_operating_systems78from provisioningserver.rpc.osystems import gen_operating_systems
79from provisioningserver.rpc.power import QUERY_POWER_TYPES
77from provisioningserver.rpc.testing import (80from provisioningserver.rpc.testing import (
78 are_valid_tls_parameters,81 are_valid_tls_parameters,
79 call_responder,82 call_responder,
@@ -989,6 +992,39 @@
989 return d.addErrback(check)992 return d.addErrback(check)
990993
991994
995class TestClusterProtocol_PowerQuery(MAASTestCase):
996
997 run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
998
999 def test_is_registered(self):
1000 protocol = Cluster()
1001 responder = protocol.locateResponder(
1002 cluster.PowerQuery.commandName)
1003 self.assertIsNot(responder, None)
1004
1005 @inlineCallbacks
1006 def test_returns_power_state(self):
1007 state = random.choice(['on', 'off'])
1008 perform_power_query = self.patch(
1009 power_module, "perform_power_query")
1010 perform_power_query.return_value = state
1011
1012 arguments = {
1013 'system_id': factory.make_name(''),
1014 'hostname': factory.make_name(''),
1015 'power_type': random.choice(QUERY_POWER_TYPES),
1016 'context': factory.make_name(''),
1017 }
1018 observed = yield call_responder(
1019 Cluster(), cluster.PowerQuery, arguments)
1020 self.assertEqual({'state': state}, observed)
1021 self.assertThat(
1022 perform_power_query,
1023 MockCalledOnceWith(
1024 arguments['system_id'], arguments['hostname'],
1025 arguments['power_type'], arguments['context']))
1026
1027
992class TestClusterProtocol_ConfigureDHCP(MAASTestCase):1028class TestClusterProtocol_ConfigureDHCP(MAASTestCase):
9931029
994 scenarios = (1030 scenarios = (