From d51918ee5ad750a465c01518cf74a6ac722b245e Mon Sep 17 00:00:00 2001 From: Tullio Sebastiani Date: Mon, 15 Jul 2024 19:06:13 +0200 Subject: [PATCH] test fix Signed-off-by: Tullio Sebastiani lint Signed-off-by: Tullio Sebastiani --- src/krkn_lib/k8s/krkn_kubernetes.py | 20 +++++++++++--------- src/krkn_lib/tests/test_krkn_kubernetes.py | 6 ++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/krkn_lib/k8s/krkn_kubernetes.py b/src/krkn_lib/k8s/krkn_kubernetes.py index ae3bc1c4..6fa93d38 100644 --- a/src/krkn_lib/k8s/krkn_kubernetes.py +++ b/src/krkn_lib/k8s/krkn_kubernetes.py @@ -1935,10 +1935,10 @@ def get_kubernetes_core_objects_count( query_params: List[str] = [] header_params: Dict[str, str] = {} auth_settings = ["BearerToken"] - header_params[ - "Accept" - ] = api_client.select_header_accept( - ["application/json"] + header_params["Accept"] = ( + api_client.select_header_accept( + ["application/json"] + ) ) path = f"/api/{api_version}/{resource.name}" @@ -2962,7 +2962,9 @@ def __monitor_pods_worker( # sum the time elapsed waiting before the pod # has been rescheduled (rescheduling time) # to the effective recovery time of the pod - result.pod_rescheduling_time = time.time() - start_time - result.pod_readiness_time + result.pod_rescheduling_time = ( + time.time() - start_time - result.pod_readiness_time + ) result.total_recovery_time = ( result.pod_readiness_time + result.pod_rescheduling_time @@ -3054,10 +3056,10 @@ def replace_service_selector( header_params["Accept"] = self.api_client.select_header_accept( ["application/json"] ) - header_params[ - "Content-Type" - ] = self.api_client.select_header_accept( - ["application/json-patch+json"] + header_params["Content-Type"] = ( + self.api_client.select_header_accept( + ["application/json-patch+json"] + ) ) path = ( diff --git a/src/krkn_lib/tests/test_krkn_kubernetes.py b/src/krkn_lib/tests/test_krkn_kubernetes.py index 855a7a2d..b018ec0d 100644 --- a/src/krkn_lib/tests/test_krkn_kubernetes.py +++ b/src/krkn_lib/tests/test_krkn_kubernetes.py @@ -894,6 +894,12 @@ def test_monitor_pods_by_label_no_pods_affected(self): self.deploy_delayed_readiness_pod(delayed_1, namespace, 0, label) self.deploy_delayed_readiness_pod(delayed_2, namespace, 0, label) + while not self.lib_k8s.is_pod_running(delayed_1, namespace) or ( + not self.lib_k8s.is_pod_running(delayed_2, namespace) + ): + time.sleep(1) + continue + monitor_timeout = 2 pods_and_namespaces = self.lib_k8s.select_pods_by_label( f"test={label}"