Make test_gc_cutoff test more robust.

Previously, if the failpoint was not reached for some reason, the test
would only fail because it would reach the 5 minute timeout we have on
all python tests. That's very subtle. Make it fail explicitly, if the
failpoint is not hit on each iteration of the loop.

Extracted from a larger PR, see
https://github.com/neondatabase/neon/pull/2785/files#r1022765794
This commit is contained in:
Heikki Linnakangas
2022-11-15 18:41:45 +02:00
committed by Heikki Linnakangas
parent 3f93c6c6f0
commit d013a2b227

View File

@@ -1,3 +1,4 @@
import pytest
from fixtures.neon_fixtures import NeonEnvBuilder, PgBin
@@ -35,10 +36,9 @@ def test_gc_cutoff(neon_env_builder: NeonEnvBuilder, pg_bin: PgBin):
pageserver_http.configure_failpoints(("after-timeline-gc-removed-layers", "exit"))
for i in range(5):
try:
for _ in range(5):
with pytest.raises(Exception):
pg_bin.run_capture(["pgbench", "-N", "-c5", "-T100", "-Mprepared", connstr])
except Exception:
env.pageserver.stop()
env.pageserver.start()
pageserver_http.configure_failpoints(("after-timeline-gc-removed-layers", "exit"))
env.pageserver.stop()
env.pageserver.start()
pageserver_http.configure_failpoints(("after-timeline-gc-removed-layers", "exit"))