# Path: aodh/coordination.py
# LOG = log.getLogger(__name__)
# OPTS = [
#     cfg.StrOpt('backend_url',
#                help='The backend URL to use for distributed coordination. If '
#                     'left empty, alarm evaluation won\'t do workload '
#                     'partitioning and will only function correctly if a '
#                     'single instance of the service is running.'),
#     cfg.FloatOpt('heartbeat_interval',
#                  default=1.0,
#                  deprecated_name='heartbeat',
#                  help='Number of seconds between heartbeats for distributed '
#                       'coordination.'),
#     cfg.FloatOpt('check_watchers',
#                  default=10.0,
#                  deprecated_for_removal=True,
#                  deprecated_reason='This parameter is no longer used.',
#                  help='Number of seconds between checks to see if group '
#                       'membership has changed'),
#     cfg.IntOpt('retry_backoff',
#                default=1,
#                help='Retry backoff factor when retrying to connect with'
#                     ' coordination backend'),
#     cfg.IntOpt('max_retry_interval',
#                default=30,
#                help='Maximum number of seconds between retry to join '
#                     'partitioning group')
# ]
# class ErrorJoiningPartitioningGroup(Exception):
# class MemberNotInGroupError(Exception):
# class HashRing(object):
# class PartitionCoordinator(object):
#     def __init__(self):
#     def __init__(self, group_id, members, my_id):
#     def __init__(self, nodes, replicas=100):
#     def _hash(key):
#     def _get_position_on_ring(self, key):
#     def get_node(self, key):
#     def __init__(self, conf, my_id=None):
#     def start(self):
#     def stop(self):
#     def is_active(self):
#     def heartbeat(self):
#     def join_group(self, group_id):
#         def _inner():
#     def leave_group(self, group_id):
#     def _get_members(self, group_id):
#     def extract_my_subset(self, group_id, universal_set):
# 
# Path: aodh/service.py
# OPTS = [
#     cfg.IntOpt('http_timeout',
#                default=600,
#                help='Timeout seconds for HTTP requests. Set it to None to '
#                     'disable timeout.'),
#     cfg.IntOpt('evaluation_interval',
#                default=60,
#                help='Period of evaluation cycle, should'
#                ' be >= than configured pipeline interval for'
#                ' collection of underlying meters.'),
# ]
# EVALUATOR_OPTS = [
#     cfg.IntOpt('workers',
#                default=1,
#                min=1,
#                help='Number of workers for evaluator service. '
#                'default value is 1.')
# ]
# NOTIFIER_OPTS = [
#     cfg.IntOpt('workers',
#                default=1,
#                min=1,
#                help='Number of workers for notifier service. '
#                'default value is 1.')
# ]
# LISTENER_OPTS = [
#     cfg.IntOpt('workers',
#                default=1,
#                min=1,
#                help='Number of workers for listener service. '
#                     'default value is 1.')
# ]
# def prepare_service(argv=None, config_files=None):
# 
# Path: aodh/tests/base.py
# class BaseTestCase(base.BaseTestCase):
# class SkipNotImplementedMeta(type):
#     def setup_messaging(self, conf, exchange=None):
#     def assertTimestampEqual(self, first, second, msg=None):
#     def assertIsEmpty(self, obj):
#     def assertIsNotEmpty(self, obj):
#     def assertDictContains(self, parent, child):
#     def path_get(project_file=None):
#     def assert_single_item(self, items, **filters):
#     def assert_multiple_items(self, items, count, **filters):
#         def _matches(item, **props):
# def _skip_decorator(func):
#     def skip_if_not_implemented(*args, **kwargs):
#     def __new__(cls, name, bases, local):


from unittest import mock
from oslo_config import fixture as fixture_config
from aodh import coordination
from aodh import service
from aodh.tests import base
import tooz.coordination
#      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.





class MockToozCoordinator(object):
    def __init__(self, member_id, shared_storage):
        self._member_id = member_id
        self._groups = shared_storage
        self.is_started = False

    def start(self):
        self.is_started = True

    def stop(self):
        pass

    def heartbeat(self):
        pass

    def create_group(self, group_id):
        if group_id in self._groups:
            return MockAsyncError(

# Path: aodh/coordination.py
# LOG = log.getLogger(__name__)
# OPTS = [
#     cfg.StrOpt('backend_url',
#                help='The backend URL to use for distributed coordination. If '
#                     'left empty, alarm evaluation won\'t do workload '
#                     'partitioning and will only function correctly if a '
#                     'single instance of the service is running.'),
#     cfg.FloatOpt('heartbeat_interval',
#                  default=1.0,
#                  deprecated_name='heartbeat',
#                  help='Number of seconds between heartbeats for distributed '
#                       'coordination.'),
#     cfg.FloatOpt('check_watchers',
#                  default=10.0,
#                  deprecated_for_removal=True,
#                  deprecated_reason='This parameter is no longer used.',
#                  help='Number of seconds between checks to see if group '
#                       'membership has changed'),
#     cfg.IntOpt('retry_backoff',
#                default=1,
#                help='Retry backoff factor when retrying to connect with'
#                     ' coordination backend'),
#     cfg.IntOpt('max_retry_interval',
#                default=30,
#                help='Maximum number of seconds between retry to join '
#                     'partitioning group')
# ]
# class ErrorJoiningPartitioningGroup(Exception):
# class MemberNotInGroupError(Exception):
# class HashRing(object):
# class PartitionCoordinator(object):
#     def __init__(self):
#     def __init__(self, group_id, members, my_id):
#     def __init__(self, nodes, replicas=100):
#     def _hash(key):
#     def _get_position_on_ring(self, key):
#     def get_node(self, key):
#     def __init__(self, conf, my_id=None):
#     def start(self):
#     def stop(self):
#     def is_active(self):
#     def heartbeat(self):
#     def join_group(self, group_id):
#         def _inner():
#     def leave_group(self, group_id):
#     def _get_members(self, group_id):
#     def extract_my_subset(self, group_id, universal_set):
# 
# Path: aodh/service.py
# OPTS = [
#     cfg.IntOpt('http_timeout',
#                default=600,
#                help='Timeout seconds for HTTP requests. Set it to None to '
#                     'disable timeout.'),
#     cfg.IntOpt('evaluation_interval',
#                default=60,
#                help='Period of evaluation cycle, should'
#                ' be >= than configured pipeline interval for'
#                ' collection of underlying meters.'),
# ]
# EVALUATOR_OPTS = [
#     cfg.IntOpt('workers',
#                default=1,
#                min=1,
#                help='Number of workers for evaluator service. '
#                'default value is 1.')
# ]
# NOTIFIER_OPTS = [
#     cfg.IntOpt('workers',
#                default=1,
#                min=1,
#                help='Number of workers for notifier service. '
#                'default value is 1.')
# ]
# LISTENER_OPTS = [
#     cfg.IntOpt('workers',
#                default=1,
#                min=1,
#                help='Number of workers for listener service. '
#                     'default value is 1.')
# ]
# def prepare_service(argv=None, config_files=None):
# 
# Path: aodh/tests/base.py
# class BaseTestCase(base.BaseTestCase):
# class SkipNotImplementedMeta(type):
#     def setup_messaging(self, conf, exchange=None):
#     def assertTimestampEqual(self, first, second, msg=None):
#     def assertIsEmpty(self, obj):
#     def assertIsNotEmpty(self, obj):
#     def assertDictContains(self, parent, child):
#     def path_get(project_file=None):
#     def assert_single_item(self, items, **filters):
#     def assert_multiple_items(self, items, count, **filters):
#         def _matches(item, **props):
# def _skip_decorator(func):
#     def skip_if_not_implemented(*args, **kwargs):
#     def __new__(cls, name, bases, local):


# Path: aodh/tests/unit/test_coordination.py
from unittest import mock
from oslo_config import fixture as fixture_config
from aodh import coordination
from aodh import service
from aodh.tests import base
import tooz.coordination

#      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.





class MockToozCoordinator(object):
    def __init__(self, member_id, shared_storage):
        self._member_id = member_id
        self._groups = shared_storage
        self.is_started = False

    def start(self):
        self.is_started = True

    def stop(self):
        pass

    def heartbeat(self):
        pass

    def create_group(self, group_id):
        if group_id in self._groups:
            return MockAsyncError(

                tooz.coordination.GroupAlreadyExist(group_id))