Pass wait timeout all the way through to clients
Pass the non-interactive wait timeout value through. Change-Id: I25c2e982ebabe09385e52fef0fb8c97cabe60756 Closes-Bug: #1841063
This commit is contained in:
parent
1099a6b3ec
commit
7c50d9e1dc
|
@ -76,13 +76,16 @@ class MySQLSharedProvides(reactive.Endpoint):
|
|||
|
||||
def set_db_connection_info(
|
||||
self, relation_id, db_host, password,
|
||||
allowed_units=None, prefix=None):
|
||||
allowed_units=None, prefix=None, wait_timeout=None):
|
||||
# Implementations of shared-db pre-date the json encoded era of
|
||||
# interface layers. In order not to have to update dozens of charms,
|
||||
# publish in raw data
|
||||
|
||||
# Everyone gets db_host
|
||||
# No prefix for db_host and wait_timeout
|
||||
self.relations[relation_id].to_publish_raw["db_host"] = db_host
|
||||
if wait_timeout:
|
||||
self.relations[relation_id].to_publish_raw["wait_timeout"] = (
|
||||
wait_timeout)
|
||||
if not prefix:
|
||||
self.relations[relation_id].to_publish_raw["password"] = password
|
||||
self.relations[relation_id].to_publish_raw[
|
||||
|
|
|
@ -11,7 +11,7 @@ class MySQLSharedRequires(RelationBase):
|
|||
# with a basic documentation string provided.
|
||||
auto_accessors = ['access-network', 'db_host',
|
||||
'ssl_ca', 'ssl_cert', 'ssl_key',
|
||||
'cluster-series-upgrading']
|
||||
'cluster-series-upgrading', 'wait_timeout']
|
||||
|
||||
@hook('{requires:mysql-shared}-relation-joined')
|
||||
def joined(self):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
charms.reactive
|
||||
flake8>=2.2.4,<=2.4.1
|
||||
flake8>=2.2.4
|
||||
mock>=1.2
|
||||
stestr>=2.2.0
|
||||
git+https://github.com/openstack/charms.openstack.git#egg=charms.openstack
|
||||
|
|
|
@ -158,3 +158,20 @@ class TestMySQLSharedProvides(test_utils.PatchHelper):
|
|||
mock.call("{}_password".format(_p), _pw),
|
||||
mock.call("{}_allowed_units".format(_p), self.fake_unit.unit_name)]
|
||||
self.fake_relation.to_publish_raw.__setitem__.assert_has_calls(_calls)
|
||||
|
||||
def test_set_db_connection_info_wait_timeout(self):
|
||||
_wto = 90
|
||||
_p = "prefix"
|
||||
_pw = "fakepassword"
|
||||
self.ep.set_db_connection_info(
|
||||
self.fake_relation_id,
|
||||
self.ep.ingress_address,
|
||||
_pw,
|
||||
allowed_units=self.fake_unit.unit_name,
|
||||
prefix=_p, wait_timeout=_wto)
|
||||
_calls = [
|
||||
mock.call("db_host", self.ep.ingress_address),
|
||||
mock.call("wait_timeout", _wto),
|
||||
mock.call("{}_password".format(_p), _pw),
|
||||
mock.call("{}_allowed_units".format(_p), self.fake_unit.unit_name)]
|
||||
self.fake_relation.to_publish_raw.__setitem__.assert_has_calls(_calls)
|
||||
|
|
|
@ -80,6 +80,7 @@ class TestMySQLSharedRequires(unittest.TestCase):
|
|||
self.patch_mysql_shared('set_state')
|
||||
self.patch_mysql_shared('remove_state')
|
||||
self.patch_mysql_shared('db_host', "10.5.0.21")
|
||||
self.patch_mysql_shared('wait_timeout', 90)
|
||||
|
||||
def tearDown(self):
|
||||
self.mysql_shared = None
|
||||
|
@ -161,6 +162,16 @@ class TestMySQLSharedRequires(unittest.TestCase):
|
|||
self.db_host.return_value = None
|
||||
assert self.mysql_shared.base_data_complete() is False
|
||||
|
||||
def test_shared_db_data_complete_wait_timeout(self):
|
||||
self._local_data = {"prefixes": ["myprefix"]}
|
||||
self._remote_data = {"myprefix_password": "1234",
|
||||
"myprefix_allowed_units": "unit/1"}
|
||||
# Wait timeout is an optional value and should not affect data complete
|
||||
self.wait_timeout.return_value = None
|
||||
assert self.mysql_shared.base_data_complete() is True
|
||||
self.wait_timeout.return_value = 90
|
||||
assert self.mysql_shared.base_data_complete() is True
|
||||
|
||||
def test_base_data_incomplete(self):
|
||||
assert self.mysql_shared.base_data_complete() is False
|
||||
|
||||
|
|
Loading…
Reference in New Issue