launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12406
[Merge] lp:~rvb/maas/route-tasks-2 into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/route-tasks-2 into lp:maas.
Commit message:
Add proper tasks routing.
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~rvb/maas/route-tasks-2/+merge/126046
= Pre-imp =
This was discussed with Julian.
= Notes =
- CELERY_CREATE_MISSING_QUEUES is True by default but I think it's better to make it explicit.
- This branch uses two ways to route tasks:
- the "master" tasks are routed declaratively using task(queue=$QUEUE_NAME). That's easy to do and easy to test. Note that I could not find an easy way to patch the value of $QUEUE_NAME in the tests to better illustrate that the queue used is $QUEUE_NAME. The problem seems to be that the decorator is applied when the module is loaded so patching $QUEUE_NAME in a test won't change the reference to the original value of $QUEUE_NAME that the decorator holds. Suggestions welcome.
- the other tasks, which need to be routed to a specific router, use the 'queue' parameter of the call to task.apply_async. I had to refactor most of the calls to task.delay(*args, **kwargs) (which is nothing more than a shortcut) into task.apply_async(queue='queue', args=args, kwargs=kwargs).
- The master worker queues are named 'celery' right now. This can be changed in the futur but this is to avoid any problem with the existing code used to launch the (master) worker in the current version of the packaging (This code does not specify a queue when running celeryd and thus the default queue named 'celery' is used.)
- I had to rewrite how write_dhcp_config works a bit. It was calling restart_dhcp_server directly without even firing off a task (it was simply calling the method). I changed that in a way that lets the caller (src/maasserver/dhcp.py) specify a callback task. This way, all the routing is in the hands of the caller.
--
https://code.launchpad.net/~rvb/maas/route-tasks-2/+merge/126046
Your team MAAS Maintainers is requested to review the proposed merge of lp:~rvb/maas/route-tasks-2 into lp:maas.
=== modified file 'etc/celeryconfig.py'
--- etc/celeryconfig.py 2012-09-24 06:06:47 +0000
+++ etc/celeryconfig.py 2012-09-24 16:51:20 +0000
@@ -17,6 +17,7 @@
from datetime import timedelta
+from kombu.common import Broadcast
from maas import import_settings
# Location of power action templates. Use an absolute path, or leave as
@@ -55,6 +56,9 @@
import_settings(maas_local_celeryconfig)
+CELERY_CREATE_MISSING_QUEUES = True
+
+
CELERY_IMPORTS = (
# Tasks.
"provisioningserver.tasks",
@@ -71,16 +75,18 @@
CELERY_IGNORE_RESULT = True
+DNS_WORKER_QUEUE = 'celery'
+BOOT_IMAGES_WORKER_QUEUE = 'celery'
+COMMON_WORKER_QUEUE = 'common'
+
+
CELERYBEAT_SCHEDULE = {
- # XXX JeroenVermeulen 2012-08-24, bug=1039366: once we have multiple
- # workers, make sure each worker gets one of these.
'unconditional-dhcp-lease-upload': {
'task': 'provisioningserver.tasks.upload_dhcp_leases',
'schedule': timedelta(minutes=1),
+ 'options': {'queue': Broadcast(COMMON_WORKER_QUEUE)}
},
- # XXX JeroenVermeulen 2012-09-12, bug=1039366: this task should run
- # only on the master worker.
'report-boot-images': {
'task': 'provisioningserver.tasks.report_boot_images',
'schedule': timedelta(minutes=5),
=== modified file 'services/celeryd/run'
--- services/celeryd/run 2012-08-24 08:39:18 +0000
+++ services/celeryd/run 2012-09-24 16:51:20 +0000
@@ -16,10 +16,6 @@
export PYTHONPATH=$PYTHONPATH:`pwd`/src:`pwd`/etc
export CELERY_CONFIG_MODULE=democeleryconfig
-# XXX JeroenVermeulen 2012-08-24, bug=1039366: To support multiple workers,
-# either pass the --beat only to the master (and make upload_dhcp tasks go
-# to all workers) or pass --beat to each worker (and make sure each routes
-# scheduled tasks only to itself).
# XXX JeroenVermeulen 2012-08-23, bug=1040529: Use fghack to kludge around
# hanging celery shutdown.
-exec fghack "$(type -p celeryd)" -l INFO --beat
+exec fghack "$(type -p celeryd)" -l INFO --beat -Q celery,common
=== modified file 'src/maasserver/dhcp.py'
--- src/maasserver/dhcp.py 2012-09-20 09:21:35 +0000
+++ src/maasserver/dhcp.py 2012-09-24 16:51:20 +0000
@@ -20,24 +20,12 @@
NODEGROUP_STATUS,
NODEGROUPINTERFACE_MANAGEMENT,
)
-from maasserver.models import NodeGroup
from maasserver.server_address import get_maas_facing_server_address
from netaddr import IPAddress
-from provisioningserver.tasks import write_dhcp_config
-
-
-def is_dhcp_disabled_until_task_routing_in_place(nodegroup):
- """Until proper task routing is in place, disable DHCP for non-master
- nodegroups.
-
- # XXX: rvb 2012-09-19 bug=1039366: Tasks are not routed yet.
- Until proper task routing is in place, the only DHCP config which can be
- written is the one for the master nodegroup.
- """
- if nodegroup == NodeGroup.objects.ensure_master():
- return False
- else:
- return True
+from provisioningserver.tasks import (
+ restart_dhcp_server,
+ write_dhcp_config,
+ )
def is_dhcp_managed(nodegroup):
@@ -60,10 +48,6 @@
if not is_dhcp_managed(nodegroup):
return
- # XXX: rvb 2012-09-19 bug=1039366: Tasks are not routed yet.
- if is_dhcp_disabled_until_task_routing_in_place(nodegroup):
- return
-
# Use the server's address (which is where the central TFTP
# server is) for the next_server setting. We'll want to proxy
# it on the local worker later, and then we can use
@@ -74,11 +58,16 @@
subnet = str(
IPAddress(interface.ip_range_low) &
IPAddress(interface.subnet_mask))
- write_dhcp_config.delay(
+ reload_dhcp_server_subtask = restart_dhcp_server.subtask(
+ options={'queue': nodegroup.uuid})
+ task_kwargs = dict(
subnet=subnet, next_server=next_server, omapi_key=nodegroup.dhcp_key,
subnet_mask=interface.subnet_mask,
broadcast_ip=interface.broadcast_ip,
router_ip=interface.router_ip,
dns_servers=get_dns_server_address(),
ip_range_low=interface.ip_range_low,
- ip_range_high=interface.ip_range_high)
+ ip_range_high=interface.ip_range_high,
+ callback=reload_dhcp_server_subtask,
+ )
+ write_dhcp_config.apply_async(queue=nodegroup.uuid, kwargs=task_kwargs)
=== modified file 'src/maasserver/migrations/0028_add_node_hardware_details.py'
--- src/maasserver/migrations/0028_add_node_hardware_details.py 2012-09-20 14:25:15 +0000
+++ src/maasserver/migrations/0028_add_node_hardware_details.py 2012-09-24 16:51:20 +0000
@@ -1,8 +1,10 @@
# encoding: utf-8
import datetime
+
+from django.db import models
from south.db import db
from south.v2 import SchemaMigration
-from django.db import models
+
class Migration(SchemaMigration):
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py 2012-09-24 11:19:14 +0000
+++ src/maasserver/models/node.py 2012-09-24 16:51:20 +0000
@@ -49,7 +49,10 @@
NODE_STATUS_CHOICES_DICT,
)
from maasserver.exceptions import NodeStateViolation
-from maasserver.fields import JSONObjectField, XMLField
+from maasserver.fields import (
+ JSONObjectField,
+ XMLField,
+ )
from maasserver.models.cleansave import CleanSave
from maasserver.models.config import Config
from maasserver.models.tag import Tag
@@ -281,7 +284,9 @@
node_power_type = node.get_effective_power_type()
# WAKE_ON_LAN does not support poweroff.
if node_power_type != POWER_TYPE.WAKE_ON_LAN:
- power_off.delay(node_power_type, **power_params)
+ power_off.apply_async(
+ queue=node.nodegroup.uuid, args=[node_power_type],
+ kwargs=power_params)
processed_nodes.append(node)
return processed_nodes
@@ -318,7 +323,9 @@
else:
do_start = True
if do_start:
- power_on.delay(node_power_type, **power_params)
+ power_on.apply_async(
+ queue=node.nodegroup.uuid, args=[node_power_type],
+ kwargs=power_params)
processed_nodes.append(node)
return processed_nodes
=== modified file 'src/maasserver/models/nodegroup.py'
--- src/maasserver/models/nodegroup.py 2012-09-24 06:48:02 +0000
+++ src/maasserver/models/nodegroup.py 2012-09-24 16:51:20 +0000
@@ -181,5 +181,8 @@
# XXX JeroenVermeulen 2012-08-21, bug=1039362: the DHCP
# server is currently always local to the worker system, so
# use 127.0.0.1 as the DHCP server address.
- add_new_dhcp_host_map.delay(
- new_leases, '127.0.0.1', self.dhcp_key)
+ task_kwargs = dict(
+ mappings=new_leases, server_address='127.0.0.1',
+ shared_key=self.dhcp_key)
+ add_new_dhcp_host_map.apply_async(
+ queue=self.uuid, kwargs=task_kwargs)
=== modified file 'src/maasserver/refresh_worker.py'
--- src/maasserver/refresh_worker.py 2012-09-10 14:27:00 +0000
+++ src/maasserver/refresh_worker.py 2012-09-24 16:51:20 +0000
@@ -38,6 +38,4 @@
'nodegroup_uuid': nodegroup.uuid,
}
- # XXX JeroenVermeulen 2012-08-21, bug=1039366: Route this to the
- # right worker, once we support it.
- refresh_secrets.delay(**items)
+ refresh_secrets.apply_async(queue=nodegroup.uuid, kwargs=items)
=== modified file 'src/maasserver/tests/test_dhcp.py'
--- src/maasserver/tests/test_dhcp.py 2012-09-20 09:02:39 +0000
+++ src/maasserver/tests/test_dhcp.py 2012-09-24 16:51:20 +0000
@@ -24,7 +24,7 @@
from maasserver.testing.factory import factory
from maasserver.testing.testcase import TestCase
from maastesting.celery import CeleryFixture
-from mock import Mock
+from provisioningserver import tasks
from testresources import FixtureResource
@@ -34,15 +34,6 @@
('celery', FixtureResource(CeleryFixture())),
)
- def setUp(self):
- super(TestDHCP, self).setUp()
- # XXX: rvb 2012-09-19 bug=1039366: Tasks are not routed yet.
- # This call to self.patch() can be removed once the bug referenced
- # above will be fixed.
- self.patch(
- dhcp, 'is_dhcp_disabled_until_task_routing_in_place',
- Mock(return_value=False))
-
def test_is_dhcp_managed_follows_nodegroup_status(self):
expected_results = {
NODEGROUP_STATUS.PENDING: False,
@@ -90,14 +81,47 @@
expected_params["dns_servers"] = get_dns_server_address()
expected_params["subnet"] = '192.168.100.0'
- mocked_task.delay.assert_called_once_with(**expected_params)
+ result_params = mocked_task.apply_async.call_args[1]['kwargs']
+ # The check that the callback is correct is done in
+ # test_configure_dhcp_restart_dhcp_server.
+ del result_params['callback']
+
+ self.assertEqual(expected_params, result_params)
+
+ def test_configure_dhcp_restart_dhcp_server(self):
+ self.patch(tasks, "sudo_write_file")
+ mocked_check_call = self.patch(tasks, "check_call")
+ self.patch(settings, "DHCP_CONNECT", True)
+ nodegroup = factory.make_node_group(status=NODEGROUP_STATUS.ACCEPTED)
+ configure_dhcp(nodegroup)
+ self.assertEqual(
+ mocked_check_call.call_args[0][0],
+ ['sudo', '-n', 'service', 'maas-dhcp-server', 'restart'])
def test_dhcp_config_gets_written_when_nodegroup_becomes_active(self):
nodegroup = factory.make_node_group(status=NODEGROUP_STATUS.PENDING)
self.patch(settings, "DHCP_CONNECT", True)
self.patch(dhcp, 'write_dhcp_config')
nodegroup.accept()
- self.assertEqual(1, dhcp.write_dhcp_config.delay.call_count)
+ self.assertEqual(1, dhcp.write_dhcp_config.apply_async.call_count)
+
+ def test_write_dhcp_config_task_routed_to_nodegroup_worker(self):
+ nodegroup = factory.make_node_group(status=NODEGROUP_STATUS.PENDING)
+ self.patch(settings, "DHCP_CONNECT", True)
+ self.patch(dhcp, 'write_dhcp_config')
+ nodegroup.accept()
+ self.assertEqual(
+ nodegroup.uuid,
+ dhcp.write_dhcp_config.apply_async.call_args[1]['queue'])
+
+ def test_write_dhcp_config_restart_task_routed_to_nodegroup_worker(self):
+ nodegroup = factory.make_node_group(status=NODEGROUP_STATUS.PENDING)
+ self.patch(settings, "DHCP_CONNECT", True)
+ self.patch(tasks, 'sudo_write_file')
+ task = self.patch(dhcp, 'restart_dhcp_server')
+ nodegroup.accept()
+ self.assertEqual(
+ nodegroup.uuid, task.subtask.call_args[1]['options']['queue'])
def test_dhcp_config_gets_written_when_nodegroupinterface_changes(self):
nodegroup = factory.make_node_group(status=NODEGROUP_STATUS.ACCEPTED)
@@ -107,33 +131,10 @@
new_router_ip = factory.getRandomIPAddress()
interface.router_ip = new_router_ip
interface.save()
+ async_mock = dhcp.write_dhcp_config.apply_async
self.assertEqual(
(1, new_router_ip),
(
- dhcp.write_dhcp_config.delay.call_count,
- dhcp.write_dhcp_config.delay.call_args[1]['router_ip'],
+ dhcp.write_dhcp_config.apply_async.call_count,
+ async_mock.call_args[1]['kwargs']['router_ip'],
))
-
-
-class TestDHCPDisabledMultipleNodegroup(TestCase):
- """Writing DHCP config files is disabled for non-master Nodegroups.
-
- # XXX: rvb 2012-09-19 bug=1039366: Tasks are not routed yet.
- These tests could be removed once proper routing is in place.
- """
-
- def test_dhcp_config_does_not_get_written_for_non_master_nodegroup(self):
- nodegroup = factory.make_node_group(status=NODEGROUP_STATUS.PENDING)
- self.patch(settings, "DHCP_CONNECT", True)
- self.patch(dhcp, 'write_dhcp_config')
- nodegroup.accept()
- self.assertEqual(0, dhcp.write_dhcp_config.delay.call_count)
-
- def test_dhcp_config_gets_written_for_master_nodegroup(self):
- # Create a fake master nodegroup with a configured interface.
- nodegroup = factory.make_node_group(
- name='master', uuid='master', status=NODEGROUP_STATUS.PENDING)
- self.patch(settings, "DHCP_CONNECT", True)
- self.patch(dhcp, 'write_dhcp_config')
- nodegroup.accept()
- self.assertEqual(1, dhcp.write_dhcp_config.delay.call_count)
=== modified file 'src/maasserver/tests/test_node.py'
--- src/maasserver/tests/test_node.py 2012-09-24 11:19:14 +0000
+++ src/maasserver/tests/test_node.py 2012-09-24 16:51:20 +0000
@@ -32,6 +32,7 @@
Config,
MACAddress,
Node,
+ node as node_module,
)
from maasserver.models.node import NODE_TRANSITIONS
from maasserver.models.user import create_auth_token
@@ -677,8 +678,7 @@
# run shell commands.
self.patch(PowerAction, 'run_shell', lambda *args, **kwargs: ('', ''))
user = factory.make_user()
- node, mac = self.make_node_with_mac(
- user, power_type=POWER_TYPE.VIRSH)
+ node, mac = self.make_node_with_mac(user, power_type=POWER_TYPE.VIRSH)
output = Node.objects.stop_nodes([node.system_id], user)
self.assertItemsEqual([node], output)
@@ -689,6 +689,14 @@
self.celery.tasks[0]['task'].name,
))
+ def test_stop_nodes_task_routed_to_nodegroup_worker(self):
+ user = factory.make_user()
+ node, mac = self.make_node_with_mac(user, power_type=POWER_TYPE.VIRSH)
+ task = self.patch(node_module, 'power_off')
+ Node.objects.stop_nodes([node.system_id], user)
+ self.assertEqual(
+ node.nodegroup.uuid, task.apply_async.call_args[1]['queue'])
+
def test_stop_nodes_ignores_uneditable_nodes(self):
nodes = [
self.make_node_with_mac(
@@ -715,6 +723,15 @@
self.celery.tasks[0]['kwargs']['mac_address'],
))
+ def test_start_nodes_task_routed_to_nodegroup_worker(self):
+ user = factory.make_user()
+ node, mac = self.make_node_with_mac(
+ user, power_type=POWER_TYPE.WAKE_ON_LAN)
+ task = self.patch(node_module, 'power_on')
+ Node.objects.start_nodes([node.system_id], user)
+ self.assertEqual(
+ node.nodegroup.uuid, task.apply_async.call_args[1]['queue'])
+
def test_start_nodes_uses_default_power_type_if_not_node_specific(self):
# If the node has a power_type set to POWER_TYPE.DEFAULT,
# NodeManager.start_node(this_node) should use the default
=== modified file 'src/maasserver/tests/test_nodegroup.py'
--- src/maasserver/tests/test_nodegroup.py 2012-09-24 06:06:47 +0000
+++ src/maasserver/tests/test_nodegroup.py 2012-09-24 16:51:20 +0000
@@ -12,15 +12,14 @@
__metaclass__ = type
__all__ = []
-from django.conf import settings
-import maasserver
-from maasserver.dns import get_dns_server_address
from maasserver.enum import (
NODEGROUP_STATUS,
NODEGROUPINTERFACE_MANAGEMENT,
)
-from maasserver.models import NodeGroup
-from maasserver.server_address import get_maas_facing_server_address
+from maasserver.models import (
+ NodeGroup,
+ nodegroup as nodegroup_module,
+ )
from maasserver.testing import reload_object
from maasserver.testing.factory import factory
from maasserver.testing.testcase import TestCase
@@ -197,6 +196,14 @@
nodegroup.add_dhcp_host_maps(leases)
self.assertEqual([], Omshell.create.extract_args())
+ def test_fires_tasks_routed_to_nodegroup_worker(self):
+ nodegroup = factory.make_node_group()
+ task = self.patch(nodegroup_module, 'add_new_dhcp_host_map')
+ leases = factory.make_random_leases()
+ nodegroup.add_dhcp_host_maps(leases)
+ self.assertEqual(
+ nodegroup.uuid, task.apply_async.call_args[1]['queue'])
+
def test_get_managed_interface_returns_managed_interface(self):
nodegroup = factory.make_node_group()
interface = nodegroup.nodegroupinterface_set.all()[0]
=== modified file 'src/maasserver/tests/test_refresh_worker.py'
--- src/maasserver/tests/test_refresh_worker.py 2012-09-10 14:27:00 +0000
+++ src/maasserver/tests/test_refresh_worker.py 2012-09-24 16:51:20 +0000
@@ -13,6 +13,7 @@
__all__ = []
from apiclient.creds import convert_tuple_to_string
+from maasserver import refresh_worker as refresh_worker_module
from maasserver.models.user import get_creds_tuple
from maasserver.refresh_worker import refresh_worker
from maasserver.testing.factory import factory
@@ -57,3 +58,10 @@
self.assertEqual(
[(nodegroup.uuid, )],
refresh_functions['nodegroup_uuid'].extract_args())
+
+ def test_refresh_worker_task_routed_to_nodegroup_worker(self):
+ nodegroup = factory.make_node_group()
+ task = self.patch(refresh_worker_module, 'refresh_secrets')
+ refresh_worker(nodegroup)
+ self.assertEqual(
+ nodegroup.uuid, task.apply_async.call_args[1]['queue'])
=== modified file 'src/maastesting/celery.py'
--- src/maastesting/celery.py 2012-05-23 14:43:16 +0000
+++ src/maastesting/celery.py 2012-09-24 16:51:20 +0000
@@ -66,5 +66,14 @@
signals.task_postrun.connect(on_task_postrun, weak=False)
self.addCleanup(lambda: self.cleanup_tasks())
+ def get_task_routing(self):
+ """Get a mapping between the name of the tasks and the queue they
+ were sent to.
+ """
+ return {
+ task_info['task'].name: task_info['task'].queue
+ for task_info in self.tasks
+ }
+
def cleanup_tasks(self):
self.tasks = []
=== modified file 'src/provisioningserver/tasks.py'
--- src/provisioningserver/tasks.py 2012-09-17 11:45:35 +0000
+++ src/provisioningserver/tasks.py 2012-09-24 16:51:20 +0000
@@ -30,8 +30,10 @@
from celery.task import task
from celeryconfig import (
+ BOOT_IMAGES_WORKER_QUEUE,
DHCP_CONFIG_FILE,
DHCP_INTERFACES_FILE,
+ DNS_WORKER_QUEUE,
)
from provisioningserver import boot_images
from provisioningserver.auth import (
@@ -155,7 +157,7 @@
RNDC_COMMAND_RETRY_DELAY = 2
-@task(max_retries=RNDC_COMMAND_MAX_RETRY)
+@task(max_retries=RNDC_COMMAND_MAX_RETRY, queue=DNS_WORKER_QUEUE)
def rndc_command(arguments, retry=False, callback=None):
"""Use rndc to execute a command.
:param arguments: Argument list passed down to the rndc command.
@@ -177,7 +179,7 @@
callback.delay()
-@task
+@task(queue=DNS_WORKER_QUEUE)
def write_full_dns_config(zones=None, callback=None, **kwargs):
"""Write out the DNS configuration files: the main configuration
file and the zone files.
@@ -198,7 +200,7 @@
callback.delay()
-@task
+@task(queue=DNS_WORKER_QUEUE)
def write_dns_config(zones=(), callback=None, **kwargs):
"""Write out the DNS configuration file.
@@ -215,7 +217,7 @@
callback.delay()
-@task
+@task(queue=DNS_WORKER_QUEUE)
def write_dns_zone_config(zone, callback=None, **kwargs):
"""Write out a DNS zone configuration file.
@@ -231,7 +233,7 @@
callback.delay()
-@task
+@task(queue=DNS_WORKER_QUEUE)
def setup_rndc_configuration(callback=None):
"""Write out the two rndc configuration files (rndc.conf and
named.conf.rndc).
@@ -306,7 +308,7 @@
@task
-def write_dhcp_config(**kwargs):
+def write_dhcp_config(callback=None, **kwargs):
"""Write out the DHCP configuration file and restart the DHCP server.
:param dhcp_interfaces: Space-separated list of interfaces that the
@@ -315,7 +317,8 @@
"""
sudo_write_file(DHCP_CONFIG_FILE, config.get_config(**kwargs))
sudo_write_file(DHCP_INTERFACES_FILE, kwargs.get('dhcp_interfaces', ''))
- restart_dhcp_server()
+ if callback is not None:
+ callback.delay()
@task
@@ -329,7 +332,7 @@
# =====================================================================
-@task
+@task(queue=BOOT_IMAGES_WORKER_QUEUE)
def report_boot_images():
"""For master worker only: report available netboot images."""
boot_images.report_to_server()
=== modified file 'src/provisioningserver/tests/test_tasks.py'
--- src/provisioningserver/tests/test_tasks.py 2012-09-17 11:53:03 +0000
+++ src/provisioningserver/tests/test_tasks.py 2012-09-24 16:51:20 +0000
@@ -25,8 +25,10 @@
from apiclient.maas_client import MAASClient
from apiclient.testing.credentials import make_api_credentials
from celeryconfig import (
+ BOOT_IMAGES_WORKER_QUEUE,
DHCP_CONFIG_FILE,
DHCP_INTERFACES_FILE,
+ DNS_WORKER_QUEUE,
)
from maastesting.celery import CeleryFixture
from maastesting.factory import factory
@@ -244,7 +246,6 @@
mocked_proc.communicate = Mock(return_value=('output', 'error output'))
mocked_popen = self.patch(
utils, "Popen", Mock(return_value=mocked_proc))
- mocked_check_call = self.patch(tasks, "check_call")
config_params = self.make_dhcp_config_params()
write_dhcp_config(**config_params)
@@ -264,12 +265,6 @@
["sudo", "-n", "maas-provision", "atomic-write", "--filename",
DHCP_INTERFACES_FILE, "--mode", "0744"], stdin=PIPE)
- # Finally it should restart the dhcp server.
- check_call_args = mocked_check_call.call_args
- self.assertEqual(
- check_call_args[0][0],
- ['sudo', '-n', 'service', 'maas-dhcp-server', 'restart'])
-
def test_restart_dhcp_server_sends_command(self):
recorder = FakeMethod()
self.patch(tasks, 'check_call', recorder)
@@ -317,6 +312,9 @@
)),
result)
+ def test_write_dns_config_attached_to_dns_worker_queue(self):
+ self.assertEqual(write_dns_config.queue, DNS_WORKER_QUEUE)
+
def test_write_dns_zone_config_writes_file(self):
command = factory.getRandomString()
zone_name = factory.getRandomString()
@@ -345,6 +343,9 @@
)),
result)
+ def test_write_dns_zone_config_attached_to_dns_worker_queue(self):
+ self.assertEqual(write_dns_zone_config.queue, DNS_WORKER_QUEUE)
+
def test_setup_rndc_configuration_writes_files(self):
command = factory.getRandomString()
result = setup_rndc_configuration.delay(
@@ -367,6 +368,9 @@
)),
result)
+ def test_setup_rndc_configuration_attached_to_dns_worker_queue(self):
+ self.assertEqual(setup_rndc_configuration.queue, DNS_WORKER_QUEUE)
+
def test_rndc_command_execute_command(self):
command = factory.getRandomString()
result = rndc_command.delay(command)
@@ -407,6 +411,9 @@
self.assertRaises(
CalledProcessError, rndc_command.delay, command, retry=True)
+ def test_rndc_command_attached_to_dns_worker_queue(self):
+ self.assertEqual(rndc_command.queue, DNS_WORKER_QUEUE)
+
def test_write_full_dns_config_sets_up_config(self):
# write_full_dns_config writes the config file, writes
# the zone files, and reloads the dns service.
@@ -439,6 +446,9 @@
FileExists(),
)))
+ def test_write_full_dns_attached_to_dns_worker_queue(self):
+ self.assertEqual(write_full_dns_config.queue, DNS_WORKER_QUEUE)
+
class TestBootImagesTasks(PservTestCase):
@@ -459,3 +469,6 @@
self.assertItemsEqual(
[image],
json.loads(MAASClient.post.call_args[1]['images']))
+
+ def test_report_boot_images_attached_to_boot_images_worker_queue(self):
+ self.assertEqual(write_dns_config.queue, BOOT_IMAGES_WORKER_QUEUE)
Follow ups