2525)
2626from pydantic import ByteSize , TypeAdapter
2727from pytest_simcore .helpers .monkeypatch_envs import EnvVarsDict , setenvs_from_dict
28+ from settings_library .rabbit import RabbitSettings
2829from simcore_service_clusters_keeper .core .settings import ApplicationSettings
2930from simcore_service_clusters_keeper .utils .clusters import (
3031 _prepare_environment_variables ,
3435)
3536from types_aiobotocore_ec2 .literals import InstanceStateNameType
3637
38+ pytest_simcore_core_services_selection = [
39+ "rabbit" ,
40+ ]
41+
42+ pytest_simcore_ops_services_selection = []
43+
3744
3845@pytest .fixture
3946def cluster_machines_name_prefix (faker : Faker ) -> str :
@@ -69,9 +76,9 @@ def app_environment(
6976 monkeypatch ,
7077 {
7178 "CLUSTERS_KEEPER_COMPUTATIONAL_BACKEND_DEFAULT_CLUSTER_AUTH" : json_dumps (
72- TLSAuthentication .model_config [ "json_schema_extra" ] ["examples" ][0 ]
79+ TLSAuthentication .model_json_schema () ["examples" ][0 ]
7380 if isinstance (backend_cluster_auth , TLSAuthentication )
74- else NoAuthentication .model_config [ "json_schema_extra" ] ["examples" ][0 ]
81+ else NoAuthentication .model_json_schema () ["examples" ][0 ]
7582 )
7683 },
7784 )
@@ -105,7 +112,9 @@ def test_create_deploy_cluster_stack_script(
105112 clusters_keeper_docker_compose : dict [str , Any ],
106113):
107114 additional_custom_tags = {
108- AWSTagKey ("pytest-tag-key" ): AWSTagValue ("pytest-tag-value" )
115+ TypeAdapter (AWSTagKey )
116+ .validate_python ("pytest-tag-key" ): TypeAdapter (AWSTagValue )
117+ .validate_python ("pytest-tag-value" )
109118 }
110119 deploy_script = create_deploy_cluster_stack_script (
111120 app_settings ,
@@ -175,13 +184,52 @@ def test_create_deploy_cluster_stack_script(
175184 for i in dict_settings
176185 )
177186
187+ # check that the RabbitMQ settings are null since rabbit is disabled
188+ assert re .search (r"AUTOSCALING_RABBITMQ=null" , deploy_script )
189+
178190 # check the additional tags are in
179191 assert all (
180192 f'"{ key } ": "{ value } "' in deploy_script
181193 for key , value in additional_custom_tags .items ()
182194 )
183195
184196
197+ def test_rabbitmq_settings_are_passed_with_pasword_clear (
198+ docker_swarm : None ,
199+ enabled_rabbitmq : None ,
200+ mocked_ec2_server_envs : EnvVarsDict ,
201+ mocked_ssm_server_envs : EnvVarsDict ,
202+ mocked_redis_server : None ,
203+ app_settings : ApplicationSettings ,
204+ cluster_machines_name_prefix : str ,
205+ clusters_keeper_docker_compose : dict [str , Any ],
206+ ):
207+ assert app_settings .CLUSTERS_KEEPER_RABBITMQ
208+ assert app_settings .CLUSTERS_KEEPER_RABBITMQ .RABBIT_HOST
209+ assert app_settings .CLUSTERS_KEEPER_RABBITMQ .RABBIT_PORT
210+ assert app_settings .CLUSTERS_KEEPER_RABBITMQ .RABBIT_SECURE is False
211+ assert app_settings .CLUSTERS_KEEPER_RABBITMQ .RABBIT_USER
212+ assert app_settings .CLUSTERS_KEEPER_RABBITMQ .RABBIT_PASSWORD .get_secret_value ()
213+
214+ additional_custom_tags = {
215+ TypeAdapter (AWSTagKey )
216+ .validate_python ("pytest-tag-key" ): TypeAdapter (AWSTagValue )
217+ .validate_python ("pytest-tag-value" )
218+ }
219+ deploy_script = create_deploy_cluster_stack_script (
220+ app_settings ,
221+ cluster_machines_name_prefix = cluster_machines_name_prefix ,
222+ additional_custom_tags = additional_custom_tags ,
223+ )
224+ assert isinstance (deploy_script , str )
225+
226+ match = re .search (r"AUTOSCALING_RABBITMQ=({.*?})" , deploy_script )
227+ assert match , "AUTOSCALING_RABBITMQ is not present in the deploy script!"
228+ autoscaling_rabbitmq = match .group (1 )
229+ passed_settings = RabbitSettings .model_validate_json (autoscaling_rabbitmq )
230+ assert passed_settings == app_settings .CLUSTERS_KEEPER_RABBITMQ
231+
232+
185233def test_create_deploy_cluster_stack_script_below_64kb (
186234 disabled_rabbitmq : None ,
187235 mocked_ec2_server_envs : EnvVarsDict ,
@@ -192,7 +240,9 @@ def test_create_deploy_cluster_stack_script_below_64kb(
192240 clusters_keeper_docker_compose : dict [str , Any ],
193241):
194242 additional_custom_tags = {
195- AWSTagKey ("pytest-tag-key" ): AWSTagValue ("pytest-tag-value" )
243+ TypeAdapter (AWSTagKey )
244+ .validate_python ("pytest-tag-key" ): TypeAdapter (AWSTagValue )
245+ .validate_python ("pytest-tag-value" )
196246 }
197247 deploy_script = create_deploy_cluster_stack_script (
198248 app_settings ,
@@ -239,7 +289,9 @@ def test__prepare_environment_variables_defines_all_envs_for_docker_compose(
239289 clusters_keeper_docker_compose_file : Path ,
240290):
241291 additional_custom_tags = {
242- AWSTagKey ("pytest-tag-key" ): AWSTagValue ("pytest-tag-value" )
292+ TypeAdapter (AWSTagKey )
293+ .validate_python ("pytest-tag-key" ): TypeAdapter (AWSTagValue )
294+ .validate_python ("pytest-tag-value" )
243295 }
244296 environment_variables = _prepare_environment_variables (
245297 app_settings ,
@@ -285,9 +337,7 @@ def test__prepare_environment_variables_defines_all_envs_for_docker_compose(
285337 "authentication" ,
286338 [
287339 NoAuthentication (),
288- TLSAuthentication (
289- ** TLSAuthentication .model_config ["json_schema_extra" ]["examples" ][0 ]
290- ),
340+ TLSAuthentication (** TLSAuthentication .model_json_schema ()["examples" ][0 ]),
291341 ],
292342)
293343def test_create_cluster_from_ec2_instance (
0 commit comments