3131# MongoDBSearch TLS configuration
3232MDBS_TLS_SECRET_NAME = "mdbs-tls-secret"
3333
34- MDB_VERSION_WITHOUT_BUILT_IN_ROLE = "8.0.10-ent"
35- MDB_VERSION_WITH_BUILT_IN_ROLE = "8.2.0-ent"
36- MDB_SEARCH_FORCE_WIREPROTO_ANNOTATION = "mongodb.com/v1.force-wireproto-transport"
37-
3834
3935@fixture (scope = "function" )
4036def mdb (namespace : str , issuer_ca_configmap : str ) -> MongoDB :
@@ -43,12 +39,11 @@ def mdb(namespace: str, issuer_ca_configmap: str) -> MongoDB:
4339 name = MDB_RESOURCE_NAME ,
4440 namespace = namespace ,
4541 )
46- resource .configure (om = get_ops_manager (namespace ), project_name = MDB_RESOURCE_NAME )
47- resource .set_version (MDB_VERSION_WITHOUT_BUILT_IN_ROLE )
4842
4943 if try_load (resource ):
5044 return resource
5145
46+ resource .configure (om = get_ops_manager (namespace ), project_name = MDB_RESOURCE_NAME )
5247 resource .configure_custom_tls (issuer_ca_configmap , "certs" )
5348
5449 return resource
@@ -61,9 +56,6 @@ def mdbs(namespace: str) -> MongoDBSearch:
6156 if try_load (resource ):
6257 return resource
6358
64- # force the wireproto transport initially because we're starting out with mongod 8.0.10
65- resource ["metadata" ]["annotations" ] = {MDB_SEARCH_FORCE_WIREPROTO_ANNOTATION : "true" }
66-
6759 # Add TLS configuration to MongoDBSearch
6860 if "spec" not in resource :
6961 resource ["spec" ] = {}
@@ -166,21 +158,19 @@ def test_create_users(
166158 namespace , name = admin_user ["spec" ]["passwordSecretKeyRef" ]["name" ], data = {"password" : ADMIN_USER_PASSWORD }
167159 )
168160 admin_user .update ()
161+ admin_user .assert_reaches_phase (Phase .Updated , timeout = 300 )
169162
170163 create_or_update_secret (
171164 namespace , name = user ["spec" ]["passwordSecretKeyRef" ]["name" ], data = {"password" : USER_PASSWORD }
172165 )
173166 user .update ()
174-
175- admin_user .assert_reaches_phase (Phase .Updated , timeout = 300 )
176167 user .assert_reaches_phase (Phase .Updated , timeout = 300 )
177168
178169 create_or_update_secret (
179170 namespace , name = mongot_user ["spec" ]["passwordSecretKeyRef" ]["name" ], data = {"password" : MONGOT_USER_PASSWORD }
180171 )
181172 mongot_user .update ()
182- # we deliberately don't wait for this user to be ready, because to be reconciled successfully it needs the searchCoordinator role
183- # which the ReplicaSet reconciler will only define in the automation config after the MongoDBSearch resource is created.
173+ mongot_user .assert_reaches_phase (Phase .Updated , timeout = 300 )
184174
185175
186176@mark .e2e_search_enterprise_tls
@@ -201,8 +191,7 @@ def test_wait_for_agents_ready(mdb: MongoDB):
201191@mark .e2e_search_enterprise_tls
202192def test_wait_for_mongod_parameters (mdb : MongoDB ):
203193 # After search CR is deployed, MongoDB controller will pick it up
204- # and start adding searchCoordinator role and search-related
205- # parameters to the automation config.
194+ # and start adding search-related parameters to the automation config.
206195 def check_mongod_parameters ():
207196 parameters_are_set = True
208197 pod_parameters = []
@@ -238,52 +227,6 @@ def test_search_assert_search_query(mdb: MongoDB):
238227 get_user_sample_movies_helper (mdb ).assert_search_query (retry_timeout = 60 )
239228
240229
241- @mark .e2e_search_enterprise_tls
242- # This test class verifies if mongodb <8.2 can be upgraded to mongodb >=8.2
243- # For mongod <8.2 the operator is automatically creating searchCoordinator customRole.
244- # We test here that the role exists before upgrade, because
245- # after mongodb is upgraded, the role should be removed from AC
246- # From 8.2 searchCoordinator role is a built-in role.
247- class TestUpgradeMongod :
248- def test_mongod_version (self , mdb : MongoDB ):
249- # This test is redundant when looking at the context of the full test file,
250- # as we deploy MDB_VERSION_WITHOUT_BUILT_IN_ROLE initially
251- # But it makes sense if we take into consideration TestUpgradeMongod test class alone.
252- # This checks the most important prerequisite for this test class to work.
253- # We check the version in case the test class is reused in another place
254- # or executed again when running locally.
255- mdb .tester (ca_path = get_issuer_ca_filepath (), use_ssl = True ).assert_version (MDB_VERSION_WITHOUT_BUILT_IN_ROLE )
256-
257- def test_check_polyfilled_role_in_ac (self , mdb : MongoDB ):
258- custom_roles = mdb .get_automation_config_tester ().automation_config .get ("roles" , [])
259- assert len (custom_roles ) > 0
260- assert "searchCoordinator" in [role ["role" ] for role in custom_roles ]
261-
262- def test_upgrade_to_mongo_8_2 (self , mdb : MongoDB , mdbs : MongoDBSearch ):
263- mdb .set_version (MDB_VERSION_WITH_BUILT_IN_ROLE )
264- mdb .update ()
265- mdb .assert_reaches_phase (Phase .Running , timeout = 600 )
266-
267- del mdbs ["metadata" ]["annotations" ][MDB_SEARCH_FORCE_WIREPROTO_ANNOTATION ]
268- mdbs .update ()
269- mdbs .assert_reaches_phase (Phase .Running , timeout = 300 )
270-
271- def test_check_polyfilled_role_not_in_ac (self , mdb : MongoDB ):
272- custom_roles = mdb .get_automation_config_tester ().automation_config .get ("roles" , [])
273- assert len (custom_roles ) >= 0
274- assert "searchCoordinator" not in [role ["role" ] for role in custom_roles ]
275-
276- def test_mongod_version_after_upgrade (self , mdb : MongoDB ):
277- mdb_tester = mdb .tester (ca_path = get_issuer_ca_filepath (), use_ssl = True )
278- mdb_tester .assert_scram_sha_authentication (
279- ADMIN_USER_NAME , ADMIN_USER_PASSWORD , "SCRAM-SHA-256" , 1 , ssl = True , tlsCAFile = get_issuer_ca_filepath ()
280- )
281- mdb_tester .assert_version (MDB_VERSION_WITH_BUILT_IN_ROLE )
282-
283- def test_search_assert_search_query_after_upgrade (self , mdb : MongoDB ):
284- get_user_sample_movies_helper (mdb ).assert_search_query (retry_timeout = 60 )
285-
286-
287230def get_connection_string (mdb : MongoDB , user_name : str , user_password : str ) -> str :
288231 return f"mongodb://{ user_name } :{ user_password } @{ mdb .name } -0.{ mdb .name } -svc.{ mdb .namespace } .svc.cluster.local:27017/?replicaSet={ mdb .name } "
289232
0 commit comments