02ab18c5df
Manila currently uses file locks from oslo_concurrency to coordinate operations racing with each other to perform a particular action. In many situations, deployers may need a distributed lock to a local file lock (or even a file lock living on a shared file system). This need is accentuated if they were running Manila services in HA or if they were using Share Replication across AZs where manila-share services were running off different controllers that would not be able to share a common oslo_concurrency file lock or be protected against service/lock management failures. Integrate Tooz library with helper methods to create a locking coordinator and allow deployers to make the choice between file and distributed locks. Start the manila share service with Tooz backed coordination. Replace the locks used for Share Replication work-flows in the share manager to use Tooz based locks. Co-Authored-By: Goutham Pacha Ravi <gouthampravi@gmail.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Tom Barron <tpb@dyncloud.net> Related-Bug: #1585241 Partially-implements: bp distributed-locking-with-tooz Change-Id: I710e86bd42034fa3b93b87ff77fa48ada8661168
70 lines
2.7 KiB
Python
70 lines
2.7 KiB
Python
# Copyright 2015 Mirantis Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# 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 sys
|
|
|
|
import ddt
|
|
import mock
|
|
|
|
from manila.cmd import share as manila_share
|
|
from manila import test
|
|
|
|
CONF = manila_share.CONF
|
|
|
|
|
|
@ddt.ddt
|
|
class ManilaCmdShareTestCase(test.TestCase):
|
|
|
|
@ddt.data(None, [], ['foo', ], ['foo', 'bar', ])
|
|
def test_main(self, backends):
|
|
self.mock_object(manila_share.log, 'setup')
|
|
self.mock_object(manila_share.log, 'register_options')
|
|
self.mock_object(manila_share.utils, 'monkey_patch')
|
|
self.mock_object(manila_share.service, 'process_launcher')
|
|
self.mock_object(manila_share.service.Service, 'create')
|
|
self.launcher = manila_share.service.process_launcher.return_value
|
|
self.mock_object(self.launcher, 'launch_service')
|
|
self.mock_object(self.launcher, 'wait')
|
|
self.server = manila_share.service.Service.create.return_value
|
|
fake_host = 'fake_host'
|
|
CONF.set_override('enabled_share_backends', backends,
|
|
enforce_type=True)
|
|
CONF.set_override('host', fake_host, enforce_type=True)
|
|
sys.argv = ['manila-share']
|
|
|
|
manila_share.main()
|
|
|
|
manila_share.log.setup.assert_called_once_with(CONF, "manila")
|
|
manila_share.log.register_options.assert_called_once_with(CONF)
|
|
manila_share.utils.monkey_patch.assert_called_once_with()
|
|
manila_share.service.process_launcher.assert_called_once_with()
|
|
self.launcher.wait.assert_called_once_with()
|
|
|
|
if backends:
|
|
manila_share.service.Service.create.assert_has_calls([
|
|
mock.call(
|
|
host=fake_host + '@' + backend,
|
|
service_name=backend,
|
|
binary='manila-share',
|
|
coordination=True,
|
|
) for backend in backends
|
|
])
|
|
self.launcher.launch_service.assert_has_calls([
|
|
mock.call(self.server) for backend in backends])
|
|
else:
|
|
manila_share.service.Service.create.assert_called_once_with(
|
|
binary='manila-share')
|
|
self.launcher.launch_service.assert_called_once_with(self.server)
|