tests: stabilize test_timelines_parallel_endpoints (#9413)

## Problem

This test would get failures like `command failed: Found no timeline id
for branch name 'branch_8'`

It's because neon_local is being invoked concurrently for branch
creation, which is unsafe (they'll step on each others' JSON writes)

Example failure:
https://neon-github-public-dev.s3.amazonaws.com/reports/pr-9410/11363051979/index.html#testresult/5ddc56c640f5422b/retries

## Summary of changes

- Don't do branch creation concurrently with endpoint creation via neon_local
This commit is contained in:
John Spray
2024-10-16 15:27:46 +01:00
committed by GitHub
parent d490ad23e0
commit d6281cbe65

View File

@@ -19,6 +19,7 @@ from fixtures.metrics import (
parse_metrics,
)
from fixtures.neon_fixtures import (
Endpoint,
NeonEnv,
NeonEnvBuilder,
wait_for_last_flush_lsn,
@@ -490,8 +491,8 @@ def test_timelines_parallel_endpoints(neon_simple_env: NeonEnv):
n_threads = 16
barrier = threading.Barrier(n_threads)
def test_timeline(branch_name: str, timeline_id: TimelineId):
endpoint = env.endpoints.create_start(branch_name)
def test_timeline(branch_name: str, timeline_id: TimelineId, endpoint: Endpoint):
endpoint.start()
endpoint.stop()
# Use a barrier to make sure we restart endpoints at the same time
barrier.wait()
@@ -502,8 +503,12 @@ def test_timelines_parallel_endpoints(neon_simple_env: NeonEnv):
for i in range(0, n_threads):
branch_name = f"branch_{i}"
timeline_id = env.create_branch(branch_name)
w = threading.Thread(target=test_timeline, args=[branch_name, timeline_id])
endpoint = env.endpoints.create(branch_name)
w = threading.Thread(target=test_timeline, args=[branch_name, timeline_id, endpoint])
workers.append(w)
# Only start the restarts once we're done creating all timelines & endpoints
for w in workers:
w.start()
for w in workers: