Autodetect number of instances
Change-Id: I8137986d9c0933b6e5046b0abaf3e6f2f1059959 Partially-Implements: blueprint multinode
This commit is contained in:
53
kolla_mesos/tests/fakes/mesos.py
Normal file
53
kolla_mesos/tests/fakes/mesos.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# 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 functools
|
||||
|
||||
import requests_mock
|
||||
|
||||
|
||||
MESOS_STATE = {
|
||||
'slaves': [
|
||||
{'attributes': {'openstack_role': 'controller'}},
|
||||
{'attributes': {'openstack_role': 'controller'}},
|
||||
{'attributes': {'openstack_role': 'controller'}},
|
||||
{'attributes': {'openstack_role': 'compute'}},
|
||||
{'attributes': {'openstack_role': 'compute'}},
|
||||
{'attributes': {'openstack_role': 'storage'}},
|
||||
{'attributes': {'openstack_role': 'storage'}}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
class FakeMesosStateSlaves(object):
|
||||
"""Contextmanager and decorator for mocking Mesos API Response.
|
||||
|
||||
This response provides a list of slaves for testing the logic about
|
||||
counting the OpenStack nodes.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.mocker = requests_mock.mocker.Mocker()
|
||||
|
||||
def __enter__(self):
|
||||
self.mocker.start()
|
||||
self.mocker.get('http://127.0.0.1:5050/state.json', json=MESOS_STATE)
|
||||
|
||||
def __exit__(self, *args):
|
||||
self.mocker.stop()
|
||||
|
||||
def __call__(self, f):
|
||||
@functools.wraps(f)
|
||||
def wrapper(*args, **kwargs):
|
||||
with self:
|
||||
return f(*args, **kwargs)
|
||||
return wrapper
|
||||
Reference in New Issue
Block a user