Skip to content

Commit a4c03ba

Browse files
committed
add user wait and ac uplload
1 parent 3074a8b commit a4c03ba

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

docker/mongodb-kubernetes-tests/kubetester/mongotester.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@
99
from typing import Callable, Dict, List, Optional
1010

1111
import pymongo
12+
from kubetester import kubetester
13+
from kubetester.kubetester import KubernetesTester
14+
from kubetester.mongodb_user import MongoDBUser
15+
from kubetester.phase import Phase
1216
from opentelemetry import trace
1317
from pycognito import Cognito
1418
from pymongo.auth_oidc import OIDCCallback, OIDCCallbackContext, OIDCCallbackResult
1519
from pymongo.errors import OperationFailure, PyMongoError, ServerSelectionTimeoutError
1620
from pytest import fail
1721

18-
from kubetester import kubetester
19-
from kubetester.kubetester import KubernetesTester
20-
from kubetester.mongodb_user import MongoDBUser
21-
from kubetester.phase import Phase
22-
2322
TEST_DB = "test-db"
2423
TEST_COLLECTION = "test-collection"
2524

@@ -88,18 +87,15 @@ def _wait_for_mongodbuser_reconciliation() -> None:
8887
"""
8988
try:
9089
# Import inside function to avoid circular imports
91-
from tests.conftest import get_central_cluster_client
9290
import kubernetes.client as client
93-
91+
from tests.conftest import get_central_cluster_client
92+
9493
namespace = KubernetesTester.get_namespace()
9594
api_client = client.CustomObjectsApi(api_client=get_central_cluster_client())
9695

9796
try:
9897
mongodb_users = api_client.list_namespaced_custom_object(
99-
group="mongodb.com",
100-
version="v1",
101-
namespace=namespace,
102-
plural="mongodbusers"
98+
group="mongodb.com", version="v1", namespace=namespace, plural="mongodbusers"
10399
)
104100

105101
all_users = []
@@ -112,11 +108,15 @@ def _wait_for_mongodbuser_reconciliation() -> None:
112108
if not all_users:
113109
return
114110

115-
logging.info(f"Found {len(all_users)} MongoDBUser resource(s) in namespace '{namespace}', waiting for all to reach Updated phase...")
111+
logging.info(
112+
f"Found {len(all_users)} MongoDBUser resource(s) in namespace '{namespace}', waiting for all to reach Updated phase..."
113+
)
116114

117115
for user_name, username in all_users:
118116
try:
119-
logging.info(f"Waiting for MongoDBUser '{user_name}' (username: {username}) to reach Updated phase...")
117+
logging.info(
118+
f"Waiting for MongoDBUser '{user_name}' (username: {username}) to reach Updated phase..."
119+
)
120120

121121
user = MongoDBUser(name=user_name, namespace=namespace)
122122
user.assert_reaches_phase(Phase.Updated, timeout=300)
@@ -263,7 +263,7 @@ def assert_scram_sha_authentication(
263263
if remaining_attempts >= attempts * 0.7: # First ~30% of attempts
264264
delay = 10 # Longer delay for initial propagation
265265
else:
266-
delay = 5 # Standard delay for normal retries
266+
delay = 5 # Standard delay for normal retries
267267

268268
time.sleep(delay)
269269

docker/mongodb-kubernetes-tests/tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,9 @@ def pytest_sessionfinish(session, exitstatus):
16921692
if not automation_config:
16931693
continue
16941694

1695-
with open(f"/tmp/diagnostics/{project_id}-automation-config.json", "w", encoding="utf-8") as f:
1695+
with open(
1696+
f"/tmp/diagnostics/{project_id}-automation-config.json", "w", encoding="utf-8"
1697+
) as f:
16961698
json.dump(automation_config, f, ensure_ascii=False, indent=4)
16971699

16981700
logging.info(f"Saved automation config for project {project_id}")

0 commit comments

Comments
 (0)