mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-29 19:10:38 +00:00
Write proposer binary
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
from contextlib import closing
|
||||
|
||||
import pytest
|
||||
|
||||
from fixtures.zenith_fixtures import ZenithEnv, PgBin, ZenithEnvBuilder, DEFAULT_BRANCH_NAME, AdversarialProposerBin
|
||||
from fixtures.benchmark_fixture import MetricReport, ZenithBenchmarker
|
||||
|
||||
|
||||
|
||||
|
||||
# TODO PR execution plan:
|
||||
# 1. Write an adversarial proposer that successfully sends greeting
|
||||
# 1. Make pg connection
|
||||
@@ -6,12 +16,17 @@
|
||||
# 3. Add TODOs, merge the harness into main, improve later
|
||||
|
||||
|
||||
def test_fuzz_safekeeper(zenith_env_builder: ZenithEnvBuilder):
|
||||
def test_fuzz_safekeeper(zenith_env_builder: ZenithEnvBuilder,
|
||||
adversarial_proposer_bin: AdversarialProposerBin):
|
||||
zenith_env_builder.num_safekeepers = 3
|
||||
env = zenith_env_builder.init_start()
|
||||
|
||||
env.zenith_cli.create_branch('test_fuzz_safekeeper')
|
||||
pg = env.postgres.create_start('test_fuzz_safekeeper')
|
||||
timeline = pg.safe_psql("SHOW zenith.zenith_timeline")[0][0]
|
||||
|
||||
output = adversarial_proposer_bin.say_hi(env.initial_tenant.hex, timeline)
|
||||
print(output)
|
||||
|
||||
# TODO:
|
||||
# 1. Start an adversarial proposer (new rust binary) that tries to take over
|
||||
|
||||
@@ -1259,6 +1259,25 @@ def pg_bin(test_output_dir: str) -> PgBin:
|
||||
return PgBin(test_output_dir)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AdversarialProposerBin:
|
||||
def say_hi(self, tenant_hex: str, timeline: str) -> str:
|
||||
binpath = os.path.join(str(zenith_binpath), 'adversarial_proposer')
|
||||
args = [
|
||||
binpath,
|
||||
tenant_hex,
|
||||
timeline,
|
||||
"just-say-hi",
|
||||
]
|
||||
return subprocess.run(args)
|
||||
# return subprocess.run(args, capture_output=True).stdout.decode("UTF-8").strip()
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def adversarial_proposer_bin(test_output_dir):
|
||||
return AdversarialProposerBin()
|
||||
|
||||
|
||||
class VanillaPostgres(PgProtocol):
|
||||
def __init__(self, pgdatadir: str, pg_bin: PgBin, port: int):
|
||||
super().__init__(host='localhost', port=port, dbname='postgres')
|
||||
|
||||
Reference in New Issue
Block a user