Skip to content

Commit 8c79f27

Browse files
authored
check pod readiness in ingress scale test (nginx#5774)
1 parent b0a36f4 commit 8c79f27

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

tests/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
NS_COUNT,
1717
NUM_REPLICAS,
1818
)
19-
from suite.utils.resources_utils import get_first_pod_name
19+
from suite.utils.resources_utils import are_all_pods_in_ready_state, get_first_pod_name, wait_before_test
2020

2121

2222
def pytest_addoption(parser) -> None:
@@ -200,6 +200,10 @@ def pytest_runtest_makereport(item) -> None:
200200
pod_namespace = item.funcargs["ingress_controller_prerequisites"].namespace
201201
pod_name = get_first_pod_name(item.funcargs["kube_apis"].v1, pod_namespace)
202202
print("\n===================== IC Logs Start =====================")
203+
count = 0
204+
while (not are_all_pods_in_ready_state(item.funcargs["kube_apis"].v1, pod_namespace)) and count < 10:
205+
count += 1
206+
wait_before_test()
203207
print(item.funcargs["kube_apis"].v1.read_namespaced_pod_log(pod_name, pod_namespace))
204208
print("\n===================== IC Logs End =====================")
205209

tests/suite/test_rl_ingress.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from suite.fixtures.fixtures import PublicEndpoint
99
from suite.utils.custom_assertions import assert_event_count_increased
1010
from suite.utils.resources_utils import (
11+
are_all_pods_in_ready_state,
1112
create_example_app,
1213
create_items_from_yaml,
1314
delete_common_app,
@@ -129,6 +130,11 @@ def test_ingress_rate_limit_sscaled(
129130
"""
130131
ns = ingress_controller_prerequisites.namespace
131132
scale_deployment(kube_apis.v1, kube_apis.apps_v1_api, "nginx-ingress", ns, 4)
133+
count = 0
134+
while (not are_all_pods_in_ready_state(kube_apis.v1, ns)) and count < 10:
135+
count += 1
136+
wait_before_test()
137+
132138
ic_pods = get_pod_list(kube_apis.v1, ns)
133139
for i in range(len(ic_pods)):
134140
conf = get_ingress_nginx_template_conf(
@@ -140,3 +146,4 @@ def test_ingress_rate_limit_sscaled(
140146
)
141147
flag = ("rate=10r/s" in conf) or ("rate=13r/s" in conf)
142148
assert flag
149+
scale_deployment(kube_apis.v1, kube_apis.apps_v1_api, "nginx-ingress", ns, 1)

0 commit comments

Comments
 (0)