
* After this patch we can switch scheduler implementations in the configuration. All functionality related to scheduling jobs is now expressed vi the internal API classes Scheduler and SchedulerJob. Patch also adds another entry point into setup.cfg where we can register a new scheduler implementation. * The new scheduler (which is now called DefaultScheduler) still should be considered experimental and requires a lot of testing and optimisations. * Fixed and refactored "with-items" tests. Before the patch they were breaking the "black box" testing principle and relied on on some either purely implementation or volatile data (e.g. checks of the internal 'capacity' property) * Fixed all other relevant tests. Change-Id: I340f886615d416a1db08e4516f825d200f76860d
92 lines
2.8 KiB
Python
92 lines
2.8 KiB
Python
# Copyright 2017 - Brocade Communications Systems, Inc.
|
|
# Copyright 2018 - Extreme Networks, Inc.
|
|
#
|
|
# 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 eventlet
|
|
|
|
from mistral.api import service as api_service
|
|
from mistral.cmd import launch
|
|
from mistral.scheduler import base as sched_base
|
|
from mistral.tests.unit import base
|
|
|
|
|
|
class ServiceLauncherTest(base.DbTestCase):
|
|
def setUp(self):
|
|
super(ServiceLauncherTest, self).setUp()
|
|
|
|
self.override_config('enabled', False, group='cron_trigger')
|
|
|
|
launch.reset_server_managers()
|
|
sched_base.destroy_system_scheduler()
|
|
|
|
def test_launch_all(self):
|
|
eventlet.spawn(launch.launch_any, launch.LAUNCH_OPTIONS.keys())
|
|
|
|
for i in range(0, 50):
|
|
svr_proc_mgr = launch.get_server_process_manager()
|
|
svr_thrd_mgr = launch.get_server_thread_manager()
|
|
|
|
if svr_proc_mgr and svr_thrd_mgr:
|
|
break
|
|
|
|
eventlet.sleep(0.1)
|
|
|
|
self.assertIsNotNone(svr_proc_mgr)
|
|
self.assertIsNotNone(svr_thrd_mgr)
|
|
|
|
api_server = api_service.WSGIService('mistral_api')
|
|
api_workers = api_server.workers
|
|
|
|
self._await(lambda: len(svr_proc_mgr.children.keys()) == api_workers)
|
|
self._await(lambda: len(svr_thrd_mgr.services.services) == 4)
|
|
|
|
def test_launch_process(self):
|
|
eventlet.spawn(launch.launch_any, ['api'])
|
|
|
|
for i in range(0, 50):
|
|
svr_proc_mgr = launch.get_server_process_manager()
|
|
|
|
if svr_proc_mgr:
|
|
break
|
|
|
|
eventlet.sleep(0.1)
|
|
|
|
svr_thrd_mgr = launch.get_server_thread_manager()
|
|
|
|
self.assertIsNotNone(svr_proc_mgr)
|
|
self.assertIsNone(svr_thrd_mgr)
|
|
|
|
api_server = api_service.WSGIService('mistral_api')
|
|
api_workers = api_server.workers
|
|
|
|
self._await(lambda: len(svr_proc_mgr.children.keys()) == api_workers)
|
|
|
|
def test_launch_thread(self):
|
|
eventlet.spawn(launch.launch_any, ['engine'])
|
|
|
|
for i in range(0, 50):
|
|
svr_thrd_mgr = launch.get_server_thread_manager()
|
|
|
|
if svr_thrd_mgr:
|
|
break
|
|
|
|
eventlet.sleep(0.1)
|
|
|
|
svr_proc_mgr = launch.get_server_process_manager()
|
|
|
|
self.assertIsNone(svr_proc_mgr)
|
|
self.assertIsNotNone(svr_thrd_mgr)
|
|
|
|
self._await(lambda: len(svr_thrd_mgr.services.services) == 1)
|