23 Returns a function that adjusts the static configuration file for
25 Sets the `dbconnection` to the testsuite started MongoDB credentials if
26 the `dbconnection` starts with `mongodb://`. Additionally
27 increases MongoDB connection timeouts to 30 seconds.
29 @ingroup userver_testsuite_fixtures
32 port = mongo_connection_info.port
33 host = mongo_connection_info.host
34 new_uri = f
'mongodb://{host}:{port}/'
36 def _patch_config(config_yaml, config_vars):
37 components = config_yaml[
'components_manager'][
'components']
38 for _, params
in components.items():
41 if params
and 'dbconnection#fallback' in params:
42 uri = params[
'dbconnection#fallback']
44 if params
and 'dbconnection' in params:
45 uri = params[
'dbconnection']
47 if not uri
or not uri.startswith(
'mongodb://'):
50 uri = re.sub(
'mongodb://[^:]+:\\d+/', new_uri, uri)
51 uri = re.sub(
'mongodb://[^:]+/', new_uri, uri)
53 params[
'dbconnection'] = uri
54 params[
'conn_timeout'] =
'30s'
55 params[
'so_timeout'] =
'30s'
56 params.pop(
'dbalias',
None)