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