1
1
import pymongo
2
2
import yaml
3
- from kubetester import create_or_update_secret , run_periodically , try_load
3
+ from kubernetes import client
4
+ from kubetester import create_or_update_secret , run_periodically , try_load , wait_until
4
5
from kubetester .certs import create_mongodb_tls_certs , create_tls_certs
5
6
from kubetester .kubetester import KubernetesTester
6
7
from kubetester .kubetester import fixture as yaml_fixture
@@ -163,12 +164,13 @@ def test_create_users(
163
164
namespace , name = admin_user ["spec" ]["passwordSecretKeyRef" ]["name" ], data = {"password" : ADMIN_USER_PASSWORD }
164
165
)
165
166
admin_user .update ()
166
- admin_user .assert_reaches_phase (Phase .Updated , timeout = 300 )
167
167
168
168
create_or_update_secret (
169
169
namespace , name = user ["spec" ]["passwordSecretKeyRef" ]["name" ], data = {"password" : USER_PASSWORD }
170
170
)
171
171
user .update ()
172
+
173
+ admin_user .assert_reaches_phase (Phase .Updated , timeout = 300 )
172
174
user .assert_reaches_phase (Phase .Updated , timeout = 300 )
173
175
174
176
create_or_update_secret (
@@ -209,7 +211,7 @@ def check_mongod_parameters():
209
211
210
212
return parameters_are_set , f'Not all pods have mongot parameters set:\n { "\n " .join (pod_parameters )} '
211
213
212
- run_periodically (lambda : check_mongod_parameters () , timeout = 200 )
214
+ run_periodically (check_mongod_parameters , timeout = 200 )
213
215
214
216
215
217
@mark .e2e_search_enterprise_tls
@@ -233,13 +235,24 @@ def test_search_assert_search_query(mdb: MongoDB):
233
235
234
236
235
237
@mark .e2e_search_enterprise_tls
238
+ # This test class verifies if mongodb <8.2 can be upgraded to mongodb >=8.2
239
+ # For mongod <8.2 the operator is automatically creating searchCoordinator customRole.
240
+ # We test here that the role exists before upgrade, because
241
+ # after mongodb is upgraded, the role should be removed from AC
242
+ # From 8.2 searchCoordinator role is a built-in role.
236
243
class TestUpgradeMongod :
237
244
def test_check_polyfilled_role_in_ac (self , mdb : MongoDB ):
238
245
custom_roles = mdb .get_automation_config_tester ().automation_config .get ("roles" , [])
239
246
assert len (custom_roles ) > 0
240
247
assert "searchCoordinator" in [role ["role" ] for role in custom_roles ]
241
248
242
249
def test_mongod_version (self , mdb : MongoDB ):
250
+ # This test is redundant when looking at the context of the full test file,
251
+ # as we deploy MDB_VERSION_WITHOUT_BUILT_IN_ROLE initially
252
+ # But it makes sense if we take into consideration TestUpgradeMongod test class alone.
253
+ # This checks the most important prerequisite for this test class to work.
254
+ # We check the version in case the test class is reused in another place
255
+ # or executed again when running locally.
243
256
mdb .tester (ca_path = get_issuer_ca_filepath (), use_ssl = True ).assert_version (MDB_VERSION_WITHOUT_BUILT_IN_ROLE )
244
257
245
258
def test_upgrade_to_mongo_8_2 (self , mdb : MongoDB ):
@@ -257,13 +270,10 @@ def test_mongod_version_after_upgrade(self, mdb: MongoDB):
257
270
mdb_tester .assert_scram_sha_authentication (
258
271
ADMIN_USER_NAME , ADMIN_USER_PASSWORD , "SCRAM-SHA-256" , 1 , ssl = True , tlsCAFile = get_issuer_ca_filepath ()
259
272
)
260
- # TODO check why assert version works without auth for 8.0 and not for 8.2
261
273
mdb_tester .assert_version (MDB_VERSION_WITH_BUILT_IN_ROLE )
262
274
263
-
264
- @mark .e2e_search_enterprise_tlssh
265
- def test_search_assert_search_query_2 (mdb : MongoDB ):
266
- get_user_sample_movies_helper (mdb ).assert_search_query (retry_timeout = 60 )
275
+ def test_search_assert_search_query_after_upgrade (self , mdb : MongoDB ):
276
+ get_user_sample_movies_helper (mdb ).assert_search_query (retry_timeout = 60 )
267
277
268
278
269
279
def get_connection_string (mdb : MongoDB , user_name : str , user_password : str ) -> str :
0 commit comments