Skip to content

Commit 785f3d7

Browse files
authored
Fix flakiness of e2e_appdb_tls_operator_upgrade_v1_32_to_mck (#100)
# Summary This fix should at least reduce the flakiness of the mentioned test. The flakiness comes from waiting for database measurements of the "admin" db. Measurements from this db are rare, especially with no operations happening. Therefore, we now wait for host measurements (cpu, memory, etc.) which are constant regardless of db operations. ## Proof of Work There are no failures due to waiting for db measurements now. https://spruce.mongodb.com/task/mongodb_kubernetes_e2e_multi_cluster_om_appdb_e2e_appdb_tls_operator_upgrade_v1_32_to_mck_patch_6a1393da1c85ce7f02cc31986bc547bfd7adf03f_682b1e248ca26800084d419a_25_05_19_12_03_57/tests?execution=4&sortBy=STATUS&sortDir=ASC ## Checklist - [ ] Have you linked a jira ticket and/or is the ticket in the title? - [ ] Have you checked whether your jira ticket required DOCSP changes? - [ ] Have you checked for release_note changes?
1 parent 0f58ef3 commit 785f3d7

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def api_read_backup_snapshot_schedule(self) -> Dict:
542542
f"/groups/{self.context.project_id}/backupConfigs/{backup_configs['clusterId']}/snapshotSchedule",
543543
).json()
544544

545-
def api_read_monitoring_measurements(
545+
def api_read_measurements(
546546
self,
547547
host_id: str,
548548
database_name: Optional[str] = None,
@@ -554,11 +554,13 @@ def api_read_monitoring_measurements(
554554
555555
https://docs.opsmanager.mongodb.com/v4.4/reference/api/measures/get-host-process-system-measurements/
556556
"""
557-
if database_name is None:
558-
database_name = "admin"
557+
database_path = ""
558+
if database_name is not None:
559+
database_path = f"/databases/{database_name}"
560+
559561
return self.om_request(
560562
"get",
561-
f"/groups/{project_id}/hosts/{host_id}/databases/{database_name}/measurements?granularity=PT30S&period={period}",
563+
f"/groups/{project_id}/hosts/{host_id}{database_path}/measurements?granularity=PT30S&period={period}",
562564
).json()["measurements"]
563565

564566
def api_read_monitoring_agents(self) -> List:

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ def no_automation_agents_have_registered() -> bool:
174174
TRACER.start_as_current_span("assert_monitoring_data_exists")
175175

176176
def assert_monitoring_data_exists(
177-
self, database_name: str = "admin", period: str = "P1DT12H", timeout: int = 120, all_hosts: bool = True
177+
self,
178+
database_name: Optional[str] = None,
179+
period: str = "P1DT12H",
180+
timeout: int = 600,
181+
all_hosts: bool = True,
178182
):
179183
"""
180184
Asserts the existence of monitoring measurements in this Ops Manager instance.
@@ -186,7 +190,7 @@ def assert_monitoring_data_exists(
186190

187191
def agent_is_showing_metrics():
188192
for host_id in host_ids:
189-
measurements = tester.api_read_monitoring_measurements(
193+
measurements = tester.api_read_measurements(
190194
host_id,
191195
database_name=database_name,
192196
project_id=project_id,

docker/mongodb-kubernetes-tests/tests/opsmanager/withMonitoredAppDB/om_ops_manager_appdb_monitoring_tls.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Optional
33

44
import pymongo
5-
from kubetester import create_or_update_secret
5+
from kubetester import create_or_update_secret, try_load
66
from kubetester.certs import create_ops_manager_tls_certs
77
from kubetester.kubetester import fixture as yaml_fixture
88
from kubetester.mongodb import Phase
@@ -36,13 +36,16 @@ def ops_manager(
3636
custom_appdb_version: str,
3737
issuer_ca_filepath: str,
3838
) -> MongoDBOpsManager:
39-
create_or_update_secret(namespace, "appdb-secret", {"password": "Hello-World!"})
40-
4139
print("Creating OM object")
4240
om = MongoDBOpsManager.from_yaml(yaml_fixture("om_ops_manager_appdb_monitoring_tls.yaml"), namespace=namespace)
4341
om.set_version(custom_version)
4442
om.set_appdb_version(custom_appdb_version)
4543

44+
if try_load(om):
45+
return om
46+
47+
create_or_update_secret(namespace, "appdb-secret", {"password": "Hello-World!"})
48+
4649
# ensure the requests library will use this CA when communicating with Ops Manager
4750
os.environ["REQUESTS_CA_BUNDLE"] = issuer_ca_filepath
4851

@@ -78,9 +81,9 @@ def test_appdb_password_can_be_changed(ops_manager: MongoDBOpsManager):
7881
)
7982

8083
# We know that Ops Manager will detect the changes and be restarted
81-
ops_manager.appdb_status().assert_reaches_phase(Phase.Pending, timeout=120)
84+
ops_manager.appdb_status().assert_reaches_phase(Phase.Pending, timeout=300)
8285
ops_manager.appdb_status().assert_reaches_phase(Phase.Running, timeout=600)
83-
ops_manager.om_status().assert_reaches_phase(Phase.Pending, timeout=120)
86+
ops_manager.om_status().assert_reaches_phase(Phase.Pending, timeout=300)
8487
ops_manager.om_status().assert_reaches_phase(Phase.Running, timeout=800)
8588

8689

0 commit comments

Comments
 (0)