Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import kubernetes
import kubernetes.client
import pymongo
import pytest
from kubernetes import client
from kubetester import (
create_or_update_configmap,
Expand Down Expand Up @@ -474,17 +475,9 @@ def test_mongodb_multi_one_running_state(self, mongodb_multi_one: MongoDBMulti):

@skip_if_local
@mark.e2e_multi_cluster_backup_restore
@pytest.mark.flaky(reruns=16, reruns_delay=6)
def test_add_test_data(self, mongodb_multi_one_collection):
max_attempts = 100
while max_attempts > 0:
try:
mongodb_multi_one_collection.insert_one(TEST_DATA)
return
except Exception as e:
print(e)
max_attempts -= 1
time.sleep(6)
raise Exception("❌ Failed to insert test data after multiple attempts")
mongodb_multi_one_collection.insert_one(TEST_DATA)

@mark.e2e_multi_cluster_backup_restore
def test_mdb_backed_up(self, project_one: OMTester):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,9 @@ def test_replica_set_is_reachable(mongodb_multi: MongoDBMulti):


@pytest.mark.e2e_multi_cluster_dr
@pytest.mark.flaky(reruns=16, reruns_delay=6)
def test_add_test_data(mongodb_multi_collection):
# TODO: remove this retry mechanism, for some reason the resource exits the running state and then
# enters it later. The subsequent test fails because the resource is not actually
max_attempts = 100
while max_attempts > 0:
try:
mongodb_multi_collection.insert_one(TEST_DATA)
return
except Exception as e:
print(e)
max_attempts -= 1
time.sleep(6)
mongodb_multi_collection.insert_one(TEST_DATA)


@pytest.mark.e2e_multi_cluster_dr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import kubernetes.client
import pymongo
import pytest
from kubetester import create_or_update_configmap, try_load
from kubetester.kubetester import ensure_ent_version
from kubetester.kubetester import fixture as yaml_fixture
Expand Down Expand Up @@ -203,16 +204,9 @@ def test_mongodb_multi_one_running_state(self, mongodb_multi_one: MongoDBMulti):
# we might fail connection in the beginning since we set a custom dns in coredns
mongodb_multi_one.assert_reaches_phase(Phase.Running, ignore_errors=True, timeout=600)

@pytest.mark.flaky(reruns=16, reruns_delay=6)
def test_add_test_data(self, mongodb_multi_one_collection):
max_attempts = 100
while max_attempts > 0:
try:
mongodb_multi_one_collection.insert_one(TEST_DATA)
return
except Exception as e:
print(e)
max_attempts -= 1
time.sleep(6)
mongodb_multi_one_collection.insert_one(TEST_DATA)

def test_mdb_backed_up(self, project_one: OMTester):
project_one.wait_until_backup_snapshots_are_ready(expected_count=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,16 +557,9 @@ def test_create_mongodb_multi(server_certs: str, mongodb_multi: MongoDBMulti):

@skip_if_local
@mark.e2e_multi_cluster_om_appdb_no_mesh
@pytest.mark.flaky(reruns=16, reruns_delay=6)
def test_add_test_data(mongodb_multi_collection):
max_attempts = 100
while max_attempts > 0:
try:
mongodb_multi_collection.insert_one(TEST_DATA)
return
except Exception as e:
print(e)
max_attempts -= 1
time.sleep(6)
mongodb_multi_collection.insert_one(TEST_DATA)


@mark.e2e_multi_cluster_om_appdb_no_mesh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def test_replica_set_sts_exists(self):
sts = self.appsv1.read_namespaced_stateful_set(RESOURCE_NAME, self.namespace)
assert sts

@pytest.mark.flaky(reruns=15, reruns_delay=5)
def test_sts_creation(self):
sts = self.appsv1.read_namespaced_stateful_set(RESOURCE_NAME, self.namespace)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,17 @@ def _get_pods(podname_template: str, qty: int = 3):

@skip_if_static_containers
@pytest.mark.e2e_replica_set_liveness_probe
@pytest.mark.flaky(reruns=10, reruns_delay=30)
def test_pods_are_running(replica_set: MongoDB, namespace: str):
corev1_client = client.CoreV1Api()
running_pods: Set[str] = set()
tries = 10
# Wait for all the pods to be running
# We can't wait for the replica set to be running
# as it will never get to it (mongod is not starting)
while tries:
if len(running_pods) == 3:
break
for podname in _get_pods("my-replica-set-{}", 3):
try:
pod = corev1_client.read_namespaced_pod(podname, namespace)
if pod.status.phase == "Running":
running_pods.add(podname)
except:
# Pod not found, will retry
pass
tries -= 1
time.sleep(30)
for podname in _get_pods("my-replica-set-{}", 3):
pod = corev1_client.read_namespaced_pod(podname, namespace)
if pod.status.phase == "Running":
running_pods.add(podname)
assert len(running_pods) == 3


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def test_replica_set_sts_exists(self):
sts = self.appsv1.read_namespaced_stateful_set("rs001-pv", self.namespace)
assert sts

@pytest.mark.flaky(reruns=15, reruns_delay=5)
def test_sts_creation(self):
sts = self.appsv1.read_namespaced_stateful_set("rs001-pv", self.namespace)

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ types-python-dateutil==2.9.0.20250809
pipupgrade==1.12.0
pytest-cov==6.2.1
pytest-socket==0.7.0
pytest-rerunfailures==16.0