Skip to content

Commit

Permalink
tests: fail tests which write too much data
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsp committed Oct 28, 2024
1 parent 923974d commit 7635345
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions test_runner/fixtures/neon_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ def __init__(

self.pageserver_virtual_file_io_engine: Optional[str] = pageserver_virtual_file_io_engine

self.pageserver_default_tenant_config_compaction_algorithm: Optional[dict[str, Any]] = (
pageserver_default_tenant_config_compaction_algorithm
)
self.pageserver_default_tenant_config_compaction_algorithm: Optional[
dict[str, Any]
] = pageserver_default_tenant_config_compaction_algorithm
if self.pageserver_default_tenant_config_compaction_algorithm is not None:
log.debug(
f"Overriding pageserver default compaction algorithm to {self.pageserver_default_tenant_config_compaction_algorithm}"
Expand Down Expand Up @@ -852,7 +852,16 @@ def __exit__(
traceback: Optional[TracebackType],
):
# Stop all the nodes.
bytes_written = 0
if self.env:
log.info("Checking for lots of I/O in tests that shouldn't")
if self.env.safekeepers[0].running:
bytes_written = (
self.env.safekeepers[0]
.http_client()
.get_metric_value("safekeeper_write_wal_bytes_sum")
)

log.info("Cleaning up all storage and compute nodes")
self.env.stop(
immediate=False,
Expand Down Expand Up @@ -913,6 +922,13 @@ def __exit__(
if cleanup_error is not None:
cleanup_error = e

if os.environ.get("BUILD_TYPE") == "debug" and bytes_written and bytes_written > 128000000:
raise RuntimeError(
f"This test wrote too much data in debug mode: {bytes_written} bytes"
)
else:
log.info(f"This test wrote {bytes_written} bytes")


class NeonEnv:
"""
Expand Down Expand Up @@ -1073,9 +1089,9 @@ def __init__(self, config: NeonEnvBuilder):
ps_cfg["virtual_file_io_engine"] = self.pageserver_virtual_file_io_engine
if config.pageserver_default_tenant_config_compaction_algorithm is not None:
tenant_config = ps_cfg.setdefault("tenant_config", {})
tenant_config["compaction_algorithm"] = (
config.pageserver_default_tenant_config_compaction_algorithm
)
tenant_config[
"compaction_algorithm"
] = config.pageserver_default_tenant_config_compaction_algorithm

if self.pageserver_remote_storage is not None:
ps_cfg["remote_storage"] = remote_storage_to_toml_dict(
Expand Down Expand Up @@ -1119,9 +1135,9 @@ def __init__(self, config: NeonEnvBuilder):
if config.auth_enabled:
sk_cfg["auth_enabled"] = True
if self.safekeepers_remote_storage is not None:
sk_cfg["remote_storage"] = (
self.safekeepers_remote_storage.to_toml_inline_table().strip()
)
sk_cfg[
"remote_storage"
] = self.safekeepers_remote_storage.to_toml_inline_table().strip()
self.safekeepers.append(
Safekeeper(env=self, id=id, port=port, extra_opts=config.safekeeper_extra_opts)
)
Expand Down Expand Up @@ -1197,6 +1213,7 @@ def stop(self, immediate=False, ps_assert_metric_no_errors=False, fail_on_endpoi

for sk in self.safekeepers:
sk.stop(immediate=immediate)

for pageserver in self.pageservers:
if ps_assert_metric_no_errors:
try:
Expand Down

0 comments on commit 7635345

Please sign in to comment.