diff --git a/examples/11-filtering-handlers/test_example_11.py b/examples/11-filtering-handlers/test_example_11.py index d1b9abe4..e94fae48 100644 --- a/examples/11-filtering-handlers/test_example_11.py +++ b/examples/11-filtering-handlers/test_example_11.py @@ -13,12 +13,19 @@ @pytest.fixture(autouse=True) def crd_exists(): - subprocess.run(f"kubectl apply -f {crd_yaml}", shell=True, check=True) + subprocess.run(f"kubectl apply -f {crd_yaml}", + check=True, timeout=10, capture_output=True, shell=True) @pytest.fixture(autouse=True) def obj_absent(): - subprocess.run(f"kubectl delete -f {obj_yaml}", shell=True, check=False) + # Operator is not running in fixtures, so we need a force-delete (or this patch). + subprocess.run(['kubectl', 'patch', '-f', obj_yaml, + '-p', '{"metadata":{"finalizers":[]}}', + '--type', 'merge'], + check=False, timeout=10, capture_output=True) + subprocess.run(f"kubectl delete -f {obj_yaml}", + check=False, timeout=10, capture_output=True, shell=True) def test_handler_filtering(mocker): diff --git a/tests/e2e/test_examples.py b/tests/e2e/test_examples.py index 1df6f1cb..7baeef7a 100644 --- a/tests/e2e/test_examples.py +++ b/tests/e2e/test_examples.py @@ -41,7 +41,7 @@ def test_all_examples_are_runnable(mocker, with_crd, with_peering, exampledir): # Run an operator and simulate some activity with the operated resource. with KopfRunner(['run', '--verbose', str(example_py)]) as runner: subprocess.run("kubectl apply -f examples/obj.yaml", shell=True, check=True) - time.sleep(e2e_create_time or 1) # give it some time to react and to sleep and to retry + time.sleep(e2e_create_time or 2) # give it some time to react and to sleep and to retry subprocess.run("kubectl delete -f examples/obj.yaml", shell=True, check=True) time.sleep(e2e_delete_time or 1) # give it some time to react