mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-13 19:20:36 +00:00
wire up the statvfs ldpreload thing in an example test
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import json
|
||||
import time
|
||||
import uuid
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Dict, Iterator, Tuple
|
||||
@@ -14,6 +16,7 @@ from fixtures.neon_fixtures import (
|
||||
RemoteStorageKind,
|
||||
wait_for_last_flush_lsn,
|
||||
wait_for_upload_queue_empty,
|
||||
wait_until,
|
||||
)
|
||||
from fixtures.types import Lsn, TenantId, TimelineId
|
||||
|
||||
@@ -365,3 +368,40 @@ def poor_mans_du(
|
||||
|
||||
assert smallest_layer is not None or total_on_disk == 0 and largest_layer == 0
|
||||
return (total_on_disk, largest_layer, smallest_layer or 0)
|
||||
|
||||
|
||||
def test_disk_usage_eviction_loop_statvfs(eviction_env: EvictionEnv):
|
||||
env = eviction_env
|
||||
|
||||
env.neon_env.pageserver.stop()
|
||||
|
||||
magic = str(uuid.uuid4())
|
||||
|
||||
preload_lib_path: Path = env.neon_env.neon_binpath / "libstatvfs_ldpreload.so"
|
||||
assert preload_lib_path.is_file(), "libstatvfs_ldpreload.so must be built"
|
||||
|
||||
env.neon_env.pageserver.start(
|
||||
overrides=(
|
||||
'--pageserver-config-override=disk_usage_based_eviction={ period = "1s", max_usage_pct = 90, min_avail_bytes = 0 }',
|
||||
),
|
||||
extra_env_vars={
|
||||
"LD_PRELOAD": str(preload_lib_path.absolute()),
|
||||
"NEON_STATVFS_LDPRELOAD_CONFIG": json.dumps(
|
||||
{
|
||||
"magic": magic,
|
||||
"mock": {
|
||||
"type": "Failure",
|
||||
"mocked_error": "EIO",
|
||||
},
|
||||
}
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
def statvfs_called():
|
||||
assert env.neon_env.pageserver.log_contains(".*statvfs_ldpreload status:.*" + magic)
|
||||
|
||||
wait_until(10, 1, statvfs_called)
|
||||
|
||||
assert env.neon_env.pageserver.log_contains(".*statvfs failed.*EIO")
|
||||
env.neon_env.pageserver.allowed_errors.append(".*statvfs failed.*EIO")
|
||||
|
||||
Reference in New Issue
Block a user