Skip to content

Commit d8329a6

Browse files
committed
Review fixes
1 parent 48c5aaa commit d8329a6

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

docker/mongodb-kubernetes-tests/tests/search/search_enterprise_tls.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pymongo
22
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
45
from kubetester.certs import create_mongodb_tls_certs, create_tls_certs
56
from kubetester.kubetester import KubernetesTester
67
from kubetester.kubetester import fixture as yaml_fixture
@@ -163,12 +164,13 @@ def test_create_users(
163164
namespace, name=admin_user["spec"]["passwordSecretKeyRef"]["name"], data={"password": ADMIN_USER_PASSWORD}
164165
)
165166
admin_user.update()
166-
admin_user.assert_reaches_phase(Phase.Updated, timeout=300)
167167

168168
create_or_update_secret(
169169
namespace, name=user["spec"]["passwordSecretKeyRef"]["name"], data={"password": USER_PASSWORD}
170170
)
171171
user.update()
172+
173+
admin_user.assert_reaches_phase(Phase.Updated, timeout=300)
172174
user.assert_reaches_phase(Phase.Updated, timeout=300)
173175

174176
create_or_update_secret(
@@ -209,7 +211,7 @@ def check_mongod_parameters():
209211

210212
return parameters_are_set, f'Not all pods have mongot parameters set:\n{"\n".join(pod_parameters)}'
211213

212-
run_periodically(lambda: check_mongod_parameters(), timeout=200)
214+
run_periodically(check_mongod_parameters, timeout=200)
213215

214216

215217
@mark.e2e_search_enterprise_tls
@@ -233,13 +235,24 @@ def test_search_assert_search_query(mdb: MongoDB):
233235

234236

235237
@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.
236243
class TestUpgradeMongod:
237244
def test_check_polyfilled_role_in_ac(self, mdb: MongoDB):
238245
custom_roles = mdb.get_automation_config_tester().automation_config.get("roles", [])
239246
assert len(custom_roles) > 0
240247
assert "searchCoordinator" in [role["role"] for role in custom_roles]
241248

242249
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.
243256
mdb.tester(ca_path=get_issuer_ca_filepath(), use_ssl=True).assert_version(MDB_VERSION_WITHOUT_BUILT_IN_ROLE)
244257

245258
def test_upgrade_to_mongo_8_2(self, mdb: MongoDB):
@@ -257,13 +270,10 @@ def test_mongod_version_after_upgrade(self, mdb: MongoDB):
257270
mdb_tester.assert_scram_sha_authentication(
258271
ADMIN_USER_NAME, ADMIN_USER_PASSWORD, "SCRAM-SHA-256", 1, ssl=True, tlsCAFile=get_issuer_ca_filepath()
259272
)
260-
# TODO check why assert version works without auth for 8.0 and not for 8.2
261273
mdb_tester.assert_version(MDB_VERSION_WITH_BUILT_IN_ROLE)
262274

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)
267277

268278

269279
def get_connection_string(mdb: MongoDB, user_name: str, user_password: str) -> str:

0 commit comments

Comments
 (0)