mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-16 01:42:55 +00:00
Add psbench_bin fixture
This commit is contained in:
@@ -638,13 +638,6 @@ class ZenithEnv:
|
||||
""" Get list of safekeeper endpoints suitable for wal_acceptors GUC """
|
||||
return ','.join([f'localhost:{wa.port.pg}' for wa in self.safekeepers])
|
||||
|
||||
def run_psbench(self, timeline):
|
||||
wal_metadata_filename = os.path.join(self.repo_dir, "wal_metadata.log")
|
||||
psbench_binpath = os.path.join(str(zenith_binpath), 'psbench')
|
||||
tenant_hex = self.initial_tenant.hex
|
||||
args = [psbench_binpath, wal_metadata_filename, tenant_hex, timeline]
|
||||
return subprocess.run(args, capture_output=True).stdout.decode("UTF-8").strip()
|
||||
|
||||
@cached_property
|
||||
def auth_keys(self) -> AuthKeys:
|
||||
pub = (Path(self.repo_dir) / 'auth_public_key.pem').read_bytes()
|
||||
@@ -1296,6 +1289,23 @@ def pg_bin(test_output_dir: str) -> PgBin:
|
||||
return PgBin(test_output_dir)
|
||||
|
||||
|
||||
@dataclass
|
||||
class PsbenchBin:
|
||||
"""A helper class for running the pageserver benchmarker tool."""
|
||||
wal_metadata_path: str
|
||||
|
||||
def run(self, tenant_hex: str, timeline: str) -> str:
|
||||
psbench_binpath = os.path.join(str(zenith_binpath), 'psbench')
|
||||
args = [psbench_binpath, self.wal_metadata_path, tenant_hex, timeline]
|
||||
return subprocess.run(args, capture_output=True).stdout.decode("UTF-8").strip()
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def psbench_bin(test_output_dir):
|
||||
wal_metadata_path = os.path.join(test_output_dir, "repo", "wal_metadata.log")
|
||||
return PsbenchBin(wal_metadata_path)
|
||||
|
||||
|
||||
class VanillaPostgres(PgProtocol):
|
||||
def __init__(self, pgdatadir: str, pg_bin: PgBin, port: int):
|
||||
super().__init__(host='localhost', port=port)
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
from contextlib import closing
|
||||
from fixtures.zenith_fixtures import ZenithEnv, PgBin, ZenithEnvBuilder
|
||||
from fixtures.zenith_fixtures import ZenithEnv, PgBin, ZenithEnvBuilder, DEFAULT_BRANCH_NAME, PsbenchBin
|
||||
from fixtures.benchmark_fixture import MetricReport, ZenithBenchmarker
|
||||
|
||||
|
||||
def test_get_page(zenith_env_builder: ZenithEnvBuilder,
|
||||
zenbenchmark: ZenithBenchmarker,
|
||||
pg_bin: PgBin):
|
||||
pg_bin: PgBin,
|
||||
psbench_bin: PsbenchBin):
|
||||
zenith_env_builder.pageserver_config_override = "emit_wal_metadata=true"
|
||||
env = zenith_env_builder.init_start()
|
||||
|
||||
env.zenith_cli.create_branch("test_pageserver", "main")
|
||||
env.zenith_cli.create_branch("test_pageserver", DEFAULT_BRANCH_NAME)
|
||||
pg = env.postgres.create_start('test_pageserver')
|
||||
tenant_hex = env.initial_tenant.hex
|
||||
timeline = pg.safe_psql("SHOW zenith.zenith_timeline")[0][0]
|
||||
@@ -40,7 +41,7 @@ def test_get_page(zenith_env_builder: ZenithEnvBuilder,
|
||||
|
||||
pscur.execute(f"checkpoint {env.initial_tenant.hex} {timeline} 0")
|
||||
|
||||
output = env.run_psbench(timeline)
|
||||
output = psbench_bin.run(env.initial_tenant.hex, timeline)
|
||||
for line in output.split("\n"):
|
||||
tokens = line.split(" ")
|
||||
report = tokens[0]
|
||||
|
||||
Reference in New Issue
Block a user