
Seeing as the power of Turbo-Hipster is in its pluggable design, this change allows the configuration to be spit up allowing each plug in to maintain it's own part of the configuration including overwriting any default configuration. There is a new configuration parameter 'conf_d', which is mapped to a directory: "conf_d": "/etc/turbo-hipster/conf.d" worker_server.py grabs all files inside this directory and attempts to load them. If it fails, the error is logged. The motivating factor for this change for me, is that it allows the deployment of turbo-hipster via puppet much simpler. The base TH puppet class will create the config.json, whereas there puppet TH plug in classes can pop extra configuration into the conf_d directory. Change-Id: Ied20b46d4caa642d130097f3fe019df9c0ec5851
73 lines
2.6 KiB
Python
73 lines
2.6 KiB
Python
#!/usr/bin/python2
|
|
#
|
|
# Copyright 2013 Rackspace Australia
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
|
|
import os
|
|
import testtools
|
|
import time
|
|
import yaml
|
|
from fakes import FakeZuulManager, FakeGearmanServer,\
|
|
FakeRealDbUpgradeRunner
|
|
|
|
CONFIG_DIR = os.path.join(os.path.dirname(__file__), 'etc')
|
|
with open(os.path.join(CONFIG_DIR, 'config.yaml'), 'r') as config_stream:
|
|
CONFIG = yaml.safe_load(config_stream)
|
|
|
|
|
|
class TestZuulManager(testtools.TestCase):
|
|
def setUp(self):
|
|
super(TestZuulManager, self).setUp()
|
|
self.config = CONFIG
|
|
self.gearman_server = FakeGearmanServer(
|
|
self.config['zuul_server']['gearman_port'])
|
|
self.config['zuul_server']['gearman_port'] = self.gearman_server.port
|
|
|
|
self.task = FakeRealDbUpgradeRunner(self.config,
|
|
self.config['plugins'][0],
|
|
'test-worker-1', self)
|
|
self.tasks = dict(FakeRealDbUpgradeRunner_worker=self.task)
|
|
|
|
self.gearman_manager = FakeZuulManager(self.config, self.tasks, self)
|
|
|
|
def tearDown(self):
|
|
super(TestZuulManager, self).tearDown()
|
|
self.gearman_server.shutdown()
|
|
|
|
def test_manager_function_registered(self):
|
|
""" Check the manager is set up correctly and registered with the
|
|
gearman server with an appropriate function """
|
|
|
|
# Give the gearman server up to 5 seconds to register the function
|
|
for x in range(500):
|
|
time.sleep(0.01)
|
|
if len(self.gearman_server.functions) > 0:
|
|
break
|
|
|
|
hostname = os.uname()[1]
|
|
function_name = 'stop:turbo-hipster-manager-%s' % hostname
|
|
|
|
self.assertIn(function_name, self.gearman_server.functions)
|
|
|
|
def test_task_registered_with_manager(self):
|
|
""" Check the FakeRealDbUpgradeRunner_worker task is registered """
|
|
self.assertIn('FakeRealDbUpgradeRunner_worker',
|
|
self.gearman_manager.tasks.keys())
|
|
|
|
def test_stop_task(self):
|
|
""" Check that the manager successfully stops a task when requested
|
|
"""
|
|
pass
|