mirror of
https://github.com/neondatabase/neon.git
synced 2026-10-28 22:46:46 +00:00
Add more information to timeline-related APIs (#1673)
Resolves #1488. - implemented `GET tenant/:tenant_id/timeline/:timeline_id/wal_receiver` endpoint - returned `thread_id` in `thread_mgr::spawn` - added `latest_gc_cutoff_lsn` field to `LocalTimelineInfo` struct
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
from uuid import uuid4, UUID
|
||||
import pytest
|
||||
from fixtures.zenith_fixtures import ZenithEnv, ZenithEnvBuilder, ZenithPageserverHttpClient
|
||||
from fixtures.zenith_fixtures import (
|
||||
DEFAULT_BRANCH_NAME,
|
||||
ZenithEnv,
|
||||
ZenithEnvBuilder,
|
||||
ZenithPageserverHttpClient,
|
||||
ZenithPageserverApiException,
|
||||
)
|
||||
|
||||
|
||||
# test that we cannot override node id
|
||||
@@ -48,6 +54,39 @@ def check_client(client: ZenithPageserverHttpClient, initial_tenant: UUID):
|
||||
assert local_timeline_details['timeline_state'] == 'Loaded'
|
||||
|
||||
|
||||
def test_pageserver_http_get_wal_receiver_not_found(zenith_simple_env: ZenithEnv):
|
||||
env = zenith_simple_env
|
||||
client = env.pageserver.http_client()
|
||||
|
||||
tenant_id, timeline_id = env.zenith_cli.create_tenant()
|
||||
|
||||
# no PG compute node is running, so no WAL receiver is running
|
||||
with pytest.raises(ZenithPageserverApiException) as e:
|
||||
_ = client.wal_receiver_get(tenant_id, timeline_id)
|
||||
assert "Not Found" in str(e.value)
|
||||
|
||||
|
||||
def test_pageserver_http_get_wal_receiver_success(zenith_simple_env: ZenithEnv):
|
||||
env = zenith_simple_env
|
||||
client = env.pageserver.http_client()
|
||||
|
||||
tenant_id, timeline_id = env.zenith_cli.create_tenant()
|
||||
pg = env.postgres.create_start(DEFAULT_BRANCH_NAME, tenant_id=tenant_id)
|
||||
|
||||
res = client.wal_receiver_get(tenant_id, timeline_id)
|
||||
assert list(res.keys()) == [
|
||||
"thread_id",
|
||||
"wal_producer_connstr",
|
||||
"last_received_msg_lsn",
|
||||
"last_received_msg_ts",
|
||||
]
|
||||
|
||||
# make a DB modification then expect getting a new WAL receiver's data
|
||||
pg.safe_psql("CREATE TABLE t(key int primary key, value text)")
|
||||
res2 = client.wal_receiver_get(tenant_id, timeline_id)
|
||||
assert res2["last_received_msg_lsn"] > res["last_received_msg_lsn"]
|
||||
|
||||
|
||||
def test_pageserver_http_api_client(zenith_simple_env: ZenithEnv):
|
||||
env = zenith_simple_env
|
||||
client = env.pageserver.http_client()
|
||||
|
||||
@@ -786,6 +786,15 @@ class ZenithPageserverHttpClient(requests.Session):
|
||||
assert isinstance(res_json, dict)
|
||||
return res_json
|
||||
|
||||
def wal_receiver_get(self, tenant_id: uuid.UUID, timeline_id: uuid.UUID) -> Dict[Any, Any]:
|
||||
res = self.get(
|
||||
f"http://localhost:{self.port}/v1/tenant/{tenant_id.hex}/timeline/{timeline_id.hex}/wal_receiver"
|
||||
)
|
||||
self.verbose_error(res)
|
||||
res_json = res.json()
|
||||
assert isinstance(res_json, dict)
|
||||
return res_json
|
||||
|
||||
def get_metrics(self) -> str:
|
||||
res = self.get(f"http://localhost:{self.port}/metrics")
|
||||
self.verbose_error(res)
|
||||
|
||||
Reference in New Issue
Block a user