Pass wait timeout all the way through to clients
Wait timeout is the non-interactive idle timeout setting. The default of 3600 is aligned to OpenStack's idle_timeout configuration default. Proxy this value from the server to the client. Depends-On: Ie2b2ad2856cbe1d830f1b7e674a2fb867d81de12 Change-Id: I0a40a65cdf1b618ec843bf872fe0b39866496e1c Closes-Bug: #1841063
This commit is contained in:
parent
8e9aa9d827
commit
f8f5495b4b
|
@ -473,6 +473,11 @@ class MySQLRouterCharm(charms_openstack.charm.OpenStackCharm):
|
|||
|
||||
_password = json.loads(
|
||||
receiving_interface.password(prefix=prefix))
|
||||
|
||||
# Wait timeout is an optional setting
|
||||
_wait_timeout = receiving_interface.wait_timeout()
|
||||
if _wait_timeout:
|
||||
_wait_timeout = json.loads(_wait_timeout)
|
||||
if ch_core.hookenv.local_unit() in (json.loads(
|
||||
receiving_interface.allowed_units(prefix=prefix))):
|
||||
_allowed_hosts = unit.unit_name
|
||||
|
@ -485,5 +490,6 @@ class MySQLRouterCharm(charms_openstack.charm.OpenStackCharm):
|
|||
unit.relation.relation_id,
|
||||
self.shared_db_address,
|
||||
_password,
|
||||
_allowed_hosts,
|
||||
prefix=prefix)
|
||||
allowed_units=_allowed_hosts,
|
||||
prefix=prefix,
|
||||
wait_timeout=_wait_timeout)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# https://github.com/openstack-charmers/release-tools
|
||||
#
|
||||
# Lint and unit test requirements
|
||||
flake8>=2.2.4,<=2.4.1
|
||||
flake8>=2.2.4
|
||||
stestr>=2.2.0
|
||||
requests>=2.18.4
|
||||
charms.reactive
|
||||
|
|
|
@ -26,6 +26,7 @@ def _add_path(path):
|
|||
if path not in sys.path:
|
||||
sys.path.insert(1, path)
|
||||
|
||||
|
||||
_add_path(_src)
|
||||
_add_path(_lib)
|
||||
_add_path(_reactive)
|
||||
|
|
|
@ -435,6 +435,8 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
|||
_calls, any_order=True)
|
||||
|
||||
def test_proxy_db_and_user_responses_unprefixed(self):
|
||||
_wait_time = 90
|
||||
_json_wait_time = "90"
|
||||
_json_pass = '"pass"'
|
||||
_pass = json.loads(_json_pass)
|
||||
_local_unit = "kmr/5"
|
||||
|
@ -445,16 +447,18 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
|||
self.db_router.get_prefixes.return_value = [
|
||||
mrc._unprefixed, mrc.db_prefix]
|
||||
|
||||
# Allowed Units unset
|
||||
# Allowed Units unset and wait_time unset
|
||||
self.db_router.wait_timeout.return_value = None
|
||||
self.db_router.allowed_units.return_value = '""'
|
||||
|
||||
mrc.proxy_db_and_user_responses(
|
||||
self.db_router, self.keystone_shared_db)
|
||||
self.keystone_shared_db.set_db_connection_info.assert_called_once_with(
|
||||
self.keystone_shared_db.relation_id, mrc.shared_db_address,
|
||||
_pass, None, prefix=None)
|
||||
_pass, allowed_units=None, prefix=None, wait_timeout=None)
|
||||
|
||||
# Allowed Units set correctly
|
||||
# Allowed Units and wait time set correctly
|
||||
self.db_router.wait_timeout.return_value = _json_wait_time
|
||||
self.keystone_shared_db.set_db_connection_info.reset_mock()
|
||||
self.db_router.allowed_units.return_value = json.dumps(_local_unit)
|
||||
mrc.proxy_db_and_user_responses(
|
||||
|
@ -462,7 +466,8 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
|||
|
||||
self.keystone_shared_db.set_db_connection_info.assert_called_once_with(
|
||||
self.keystone_shared_db.relation_id, mrc.shared_db_address,
|
||||
_pass, self.keystone_unit_name, prefix=None)
|
||||
_pass, allowed_units=self.keystone_unit_name, prefix=None,
|
||||
wait_timeout=_wait_time)
|
||||
|
||||
# Confirm msyqlrouter credentials are not sent over the shared-db
|
||||
# relation
|
||||
|
@ -470,6 +475,8 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
|||
self.assertNotEqual(mrc.db_prefix, call.kwargs.get("prefix"))
|
||||
|
||||
def test_proxy_db_and_user_responses_prefixed(self):
|
||||
_wait_time = 90
|
||||
_json_wait_time = "90"
|
||||
_json_pass = '"pass"'
|
||||
_pass = json.loads(_json_pass)
|
||||
_local_unit = "nmr/5"
|
||||
|
@ -483,39 +490,45 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
|||
self.db_router.get_prefixes.return_value = [
|
||||
mrc.db_prefix, _nova, _novaapi, _novacell0]
|
||||
|
||||
# Allowed Units unset
|
||||
# Allowed Units and wait time unset
|
||||
self.db_router.wait_timeout.return_value = None
|
||||
self.db_router.allowed_units.return_value = '""'
|
||||
mrc.proxy_db_and_user_responses(self.db_router, self.nova_shared_db)
|
||||
_calls = [
|
||||
mock.call(
|
||||
self.nova_shared_db.relation_id, mrc.shared_db_address, _pass,
|
||||
None, prefix=_nova),
|
||||
allowed_units=None, prefix=_nova,
|
||||
wait_timeout=None),
|
||||
mock.call(
|
||||
self.nova_shared_db.relation_id, mrc.shared_db_address, _pass,
|
||||
None, prefix=_novaapi),
|
||||
allowed_units=None, prefix=_novaapi,
|
||||
wait_timeout=None),
|
||||
mock.call(
|
||||
self.nova_shared_db.relation_id, mrc.shared_db_address, _pass,
|
||||
None, prefix=_novacell0),
|
||||
allowed_units=None, prefix=_novacell0,
|
||||
wait_timeout=None),
|
||||
]
|
||||
self.nova_shared_db.set_db_connection_info.assert_has_calls(
|
||||
_calls, any_order=True)
|
||||
|
||||
# Allowed Units set correctly
|
||||
# Allowed Units and wait time set correctly
|
||||
self.db_router.wait_timeout.return_value = _json_wait_time
|
||||
self.nova_shared_db.set_db_connection_info.reset_mock()
|
||||
self.db_router.allowed_units.return_value = json.dumps(_local_unit)
|
||||
mrc.proxy_db_and_user_responses(self.db_router, self.nova_shared_db)
|
||||
_calls = [
|
||||
mock.call(
|
||||
self.nova_shared_db.relation_id, mrc.shared_db_address, _pass,
|
||||
self.nova_unit_name, prefix=_nova),
|
||||
|
||||
allowed_units=self.nova_unit_name, prefix=_nova,
|
||||
wait_timeout=_wait_time),
|
||||
mock.call(
|
||||
self.nova_shared_db.relation_id, mrc.shared_db_address, _pass,
|
||||
self.nova_unit_name, prefix=_novaapi),
|
||||
|
||||
allowed_units=self.nova_unit_name, prefix=_novaapi,
|
||||
wait_timeout=_wait_time),
|
||||
mock.call(
|
||||
self.nova_shared_db.relation_id, mrc.shared_db_address, _pass,
|
||||
self.nova_unit_name, prefix=_novacell0),
|
||||
allowed_units=self.nova_unit_name, prefix=_novacell0,
|
||||
wait_timeout=_wait_time),
|
||||
]
|
||||
self.nova_shared_db.set_db_connection_info.assert_has_calls(
|
||||
_calls, any_order=True)
|
||||
|
|
Loading…
Reference in New Issue