tests: add helpers for location_conf

This commit is contained in:
John Spray
2023-10-13 08:34:50 +01:00
parent 22c94d99f5
commit fbe1da2981
2 changed files with 18 additions and 0 deletions

View File

@@ -1773,6 +1773,16 @@ class NeonPageserver(PgProtocol):
client = self.http_client()
return client.tenant_attach(tenant_id, config, config_null, generation=generation)
def tenant_location_configure(self, tenant_id: TenantId, config: dict[str, Any]):
# This API is only for use when generations are enabled
assert self.env.attachment_service is not None
if config["mode"].startswith("Attached") and "generation" not in config:
config["generation"] = self.env.attachment_service.attach_hook(tenant_id, self.id)
client = self.http_client()
return client.tenant_location_conf(tenant_id, config)
def append_pageserver_param_overrides(
params_to_update: List[str],

View File

@@ -247,6 +247,14 @@ class PageserverHttpClient(requests.Session):
res = self.post(f"http://localhost:{self.port}/v1/tenant/{tenant_id}/detach", params=params)
self.verbose_error(res)
def tenant_location_conf(self, tenant_id: TenantId, location_conf=dict[str, Any]):
body = location_conf.copy()
body["tenant_id"] = str(tenant_id)
res = self.put(
f"http://localhost:{self.port}/v1/tenant/{tenant_id}/location_config", json=body
)
self.verbose_error(res)
def tenant_delete(self, tenant_id: TenantId):
res = self.delete(f"http://localhost:{self.port}/v1/tenant/{tenant_id}")
self.verbose_error(res)