Skip to content

Commit

Permalink
Improve flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tellet committed Nov 20, 2019
1 parent 3cbee97 commit efdd31f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
16 changes: 10 additions & 6 deletions tests/suite/resources_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from kubernetes.client.rest import ApiException
from kubernetes.stream import stream
from kubernetes import client
from more_itertools import first

from settings import TEST_DATA, RECONFIGURATION_DELAY, DEPLOYMENTS


Expand Down Expand Up @@ -297,14 +299,16 @@ def wait_for_public_ip(v1: CoreV1Api, namespace: str) -> str:
"""
resp = v1.list_namespaced_service(namespace)
counter = 0
while str(resp.items[0].status.load_balancer.ingress) == "None" and counter < 20:
svc_item = first(x for x in resp.items if x.metadata.name == "nginx-ingress")
while str(svc_item.status.load_balancer.ingress) == "None" and counter < 20:
time.sleep(5)
resp = v1.list_namespaced_service(namespace)
svc_item = first(x for x in resp.items if x.metadata.name == "nginx-ingress")
counter = counter + 1
if counter == 20:
pytest.fail("After 100 seconds the LB still doesn't have a Public IP. Exiting...")
print(f"Public IP ='{resp.items[0].status.load_balancer.ingress[0].ip}'")
return str(resp.items[0].status.load_balancer.ingress[0].ip)
print(f"Public IP ='{svc_item.status.load_balancer.ingress[0].ip}'")
return str(svc_item.status.load_balancer.ingress[0].ip)


def create_secret_from_yaml(v1: CoreV1Api, namespace, yaml_manifest) -> str:
Expand Down Expand Up @@ -983,8 +987,8 @@ def ensure_response_from_backend(req_url, host) -> None:
"""
for _ in range(30):
resp = requests.get(req_url, headers={"host": host}, verify=False)
if resp.status_code != 502:
print(f"At last after {_ * 2} seconds got 200. Continue...")
if resp.status_code != 502 and resp.status_code != 504:
print(f"After {_ * 2} seconds got non 502|504 response. Continue with tests...")
return
time.sleep(2)
pytest.fail(f"Keep getting 502 from {req_url} after 60 seconds. Exiting...")
pytest.fail(f"Keep getting 502|504 from {req_url} after 60 seconds. Exiting...")
1 change: 1 addition & 0 deletions tests/suite/test_v_s_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def assert_locations_not_in_config(config, paths):


@pytest.mark.smoke
@pytest.mark.vsr
@pytest.mark.parametrize('crd_ingress_controller, v_s_route_setup',
[({"type": "complete", "extra_args": [f"-enable-custom-resources"]},
{"example": "virtual-server-route"})],
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/test_v_s_route_upstream_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def test_v_s_r_overrides_config_map(self, kube_apis,
replace_configmap_from_yaml(kube_apis.v1, config_map_name,
ingress_controller_prerequisites.namespace,
f"{TEST_DATA}/virtual-server-route-upstream-options/configmap-with-keys.yaml")
wait_before_test(1)
wait_before_test(2)
ic_pod_name = get_first_pod_name(kube_apis.v1, ingress_controller_prerequisites.namespace)
config = get_vs_nginx_template_conf(kube_apis.v1,
v_s_route_setup.namespace,
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/test_v_s_route_upstream_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def fin():
[({"type": "complete", "extra_args": [f"-enable-custom-resources"]},
{"example": "virtual-server-route-upstream-tls"})],
indirect=True)
class TestVSRouteUpstreamOptions:
class TestVSRouteUpstreamTls:
def test_responses_and_config_after_setup(self, kube_apis, ingress_controller_prerequisites,
crd_ingress_controller, v_s_route_setup, v_s_route_secure_app_setup):
ic_pod_name = get_first_pod_name(kube_apis.v1, ingress_controller_prerequisites.namespace)
Expand Down

0 comments on commit efdd31f

Please sign in to comment.