mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-10 15:02:56 +00:00
this patch adds support for tenants. This touches mostly pageserver. Directory layout on disk is changed to contain new layer of indirection. Now path to particular repository has the following structure: <pageserver workdir>/tenants/<tenant id>. Tenant id has the same format as timeline id. Tenant id is included in pageserver commands when needed. Also new commands are available in pageserver: tenant_list, tenant_create. This is also reflected CLI. During init default tenant is created and it's id is saved in CLI config, so following commands can use it without extra options. Tenant id is also included in compute postgres configuration, so it can be passed via ServerInfo to safekeeper and in connection string to pageserver. For more info see docs/multitenancy.md.
49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
from contextlib import closing
|
|
|
|
import pytest
|
|
|
|
from fixtures.zenith_fixtures import (
|
|
TenantFactory,
|
|
ZenithCli,
|
|
PostgresFactory,
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize('with_wal_acceptors', [False, True])
|
|
def test_tenants_normal_work(
|
|
zenith_cli: ZenithCli,
|
|
tenant_factory: TenantFactory,
|
|
postgres: PostgresFactory,
|
|
wa_factory,
|
|
with_wal_acceptors: bool,
|
|
):
|
|
"""Tests tenants with and without wal acceptors"""
|
|
tenant_1 = tenant_factory.create()
|
|
tenant_2 = tenant_factory.create()
|
|
|
|
zenith_cli.run(["branch", f"test_tenants_normal_work_with_wal_acceptors{with_wal_acceptors}", "main", f"--tenantid={tenant_1}"])
|
|
zenith_cli.run(["branch", f"test_tenants_normal_work_with_wal_acceptors{with_wal_acceptors}", "main", f"--tenantid={tenant_2}"])
|
|
if with_wal_acceptors:
|
|
wa_factory.start_n_new(3)
|
|
|
|
pg_tenant1 = postgres.create_start(
|
|
f"test_tenants_normal_work_with_wal_acceptors{with_wal_acceptors}",
|
|
tenant_1,
|
|
wal_acceptors=wa_factory.get_connstrs() if with_wal_acceptors else None,
|
|
)
|
|
pg_tenant2 = postgres.create_start(
|
|
f"test_tenants_normal_work_with_wal_acceptors{with_wal_acceptors}",
|
|
tenant_2,
|
|
wal_acceptors=wa_factory.get_connstrs() if with_wal_acceptors else None,
|
|
)
|
|
|
|
for pg in [pg_tenant1, pg_tenant2]:
|
|
with closing(pg.connect()) as conn:
|
|
with conn.cursor() as cur:
|
|
# we rely upon autocommit after each statement
|
|
# as waiting for acceptors happens there
|
|
cur.execute("CREATE TABLE t(key int primary key, value text)")
|
|
cur.execute("INSERT INTO t SELECT generate_series(1,100000), 'payload'")
|
|
cur.execute("SELECT sum(key) FROM t")
|
|
assert cur.fetchone() == (5000050000,)
|