benchmark-runner icon indicating copy to clipboard operation
benchmark-runner copied to clipboard

test_delete_sync_pod_timeout_error fails if delete succeeds very quickly

Open RobertKrawitz opened this issue 3 years ago • 1 comments

test_delete_sync_pod_timeout_error is consistently failing for me as follows:


============================================================================================================================= FAILURES ==============================================================================================================================
________________________________________________________________________________________________________________ test_delete_sync_pod_timeout_error _________________________________________________________________________________________________________________

    def test_delete_sync_pod_timeout_error():
        """
        This method delete pod with timeout error
        :return:
        """
        oc = OC(kubeadmin_password=test_environment_variable['kubeadmin_password'])
        oc.login()
        oc.create_pod_sync(yaml=os.path.join(f'{templates_path}', 'stressng_pod.yaml'), pod_name='stressng-pod-workload')
        with pytest.raises(PodTerminateTimeout) as err:
>           oc.delete_pod_sync(yaml=os.path.join(f'{templates_path}', 'stressng_pod.yaml'), pod_name='stressng-pod-workload', timeout=0)
E           Failed: DID NOT RAISE <class 'benchmark_runner.common.oc.oc_exceptions.PodTerminateTimeout'>

tests/integration/benchmark_runner/common/oc/test_oc.py:190: Failed

The problem is that the pod delete is completing very quickly, so doesn't actually fail. This change in wait_for_pod_terminate allows it to pass:

index eab9aed..54cf895 100644
@@ -205,7 +206,7 @@ class OC(SSH):
         :return: True if pod name terminated or raise
         """
         current_wait_time = 0
-        while current_wait_time <= timeout:
+        while current_wait_time < timeout:
             if not self._is_pod_exist(pod_name=pod_name, namespace=namespace):
                 return True
             # sleep for x seconds

The test should not assume that the deletion will take non-zero time.

RobertKrawitz avatar Aug 30 '21 19:08 RobertKrawitz

Actually, a better fix would be to change the timeout to be -1.

RobertKrawitz avatar Aug 30 '21 19:08 RobertKrawitz