lib/ovsdb: Allow interface to work with CMR
The interface code curretly strictly gates operation based on information from `goal-state`. This information is however not available when used with CMR. Since the ovn-central charm currently must be at least 3 units, we can assume a minimum of 3 units to be joined when the expected count from `goal-state` is 1. Also replace os-testr with stestr. Closes-Bug: #1976537 Change-Id: I5b91d3caa466383fec76a393556668eb3b59ec63
This commit is contained in:
parent
6b52c09958
commit
9eb098b23d
@ -156,9 +156,15 @@ class OVSDB(reactive.Endpoint):
|
||||
False otherwise.
|
||||
:rtype: bool
|
||||
"""
|
||||
if len(self.all_joined_units) == len(
|
||||
list(ch_core.hookenv.expected_related_units(
|
||||
self.expand_name('{endpoint_name}')))):
|
||||
expected_related_units = len(
|
||||
list(ch_core.hookenv.expected_related_units(
|
||||
self.expand_name('{endpoint_name}'))))
|
||||
# A minimum of 3 ovn-central units are required for operation, if
|
||||
# this number is 1 chances are we are consuming the realation over CMR
|
||||
# which would not provide us with an accurate number.
|
||||
if expected_related_units == 1:
|
||||
expected_related_units = 3
|
||||
if len(self.all_joined_units) >= expected_related_units:
|
||||
bound_addrs = [unit.received.get('bound-address', None) is not None
|
||||
for relation in self.relations
|
||||
for unit in relation.units]
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Lint and unit test requirements
|
||||
flake8
|
||||
os-testr>=0.4.1
|
||||
stestr
|
||||
charms.reactive
|
||||
mock>=1.2
|
||||
coverage>=3.6
|
||||
|
6
tox.ini
6
tox.ini
@ -13,17 +13,17 @@ install_command =
|
||||
[testenv:py3]
|
||||
basepython = python3
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = ostestr {posargs}
|
||||
commands = stestr run {posargs}
|
||||
|
||||
[testenv:py35]
|
||||
basepython = python3.5
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = ostestr {posargs}
|
||||
commands = stestr run {posargs}
|
||||
|
||||
[testenv:py36]
|
||||
basepython = python3.6
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = ostestr {posargs}
|
||||
commands = stestr run {posargs}
|
||||
|
||||
[testenv:pep8]
|
||||
basepython = python3
|
||||
|
@ -183,6 +183,18 @@ class TestOVSDBLib(test_utils.PatchHelper):
|
||||
unit3.received = {'bound-address': '6.7.8.9'}
|
||||
self.assertEquals(self.target.expected_units_available(), True)
|
||||
|
||||
# when related to ovn-central through CMR expected_related_units
|
||||
# will always be 1. check that this works
|
||||
self.expected_related_units.return_value = [
|
||||
'controller:user/offer.name',
|
||||
]
|
||||
self.target._all_joined_units = [
|
||||
'unit/0', 'unit/1']
|
||||
self.assertEquals(self.target.expected_units_available(), False)
|
||||
self.target._all_joined_units = [
|
||||
'unit/0', 'unit/1', 'unit/2']
|
||||
self.assertEquals(self.target.expected_units_available(), True)
|
||||
|
||||
def test_publish_cluster_local_addr(self):
|
||||
to_publish = self.patch_topublish()
|
||||
self.target.publish_cluster_local_addr()
|
||||
|
Loading…
x
Reference in New Issue
Block a user