mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-18 05:30:37 +00:00
Add set_mergeable
This commit is contained in:
@@ -1174,6 +1174,22 @@ class NeonCli(AbstractNeonCli):
|
||||
res = self.raw_cli(args)
|
||||
res.check_returncode()
|
||||
|
||||
def set_mergeable(
|
||||
self,
|
||||
endpoint: Endpoint):
|
||||
"""
|
||||
Merge two branches
|
||||
"""
|
||||
|
||||
args = [
|
||||
"timeline",
|
||||
"set_mergeable",
|
||||
"--endpoint",
|
||||
str(endpoint.endpoint_id),
|
||||
]
|
||||
res = self.raw_cli(args)
|
||||
res.check_returncode()
|
||||
|
||||
def create_tenant(
|
||||
self,
|
||||
tenant_id: Optional[TenantId] = None,
|
||||
|
||||
@@ -17,6 +17,7 @@ def test_merge(neon_env_builder: NeonEnvBuilder):
|
||||
main_branch = env.endpoints.create_start("main", tenant_id=tenant)
|
||||
main_cur = main_branch.connect().cursor()
|
||||
|
||||
# Create table and insert some data
|
||||
main_cur.execute("CREATE TABLE t(x bigint primary key)")
|
||||
main_cur.execute("INSERT INTO t values(generate_series(1, 10000))");
|
||||
|
||||
@@ -25,13 +26,18 @@ def test_merge(neon_env_builder: NeonEnvBuilder):
|
||||
ws_branch = env.endpoints.create_start("ws", tenant_id=tenant)
|
||||
log.info("postgres is running on 'ws' branch")
|
||||
|
||||
# Merge brnach ws as mergeable:it create logical replication slots and pins WAL
|
||||
env.neon_cli.set_mergeable(ws_branch)
|
||||
|
||||
# Insert more data in the branch
|
||||
ws_cur = ws_branch.connect().cursor()
|
||||
ws_cur.execute("select pg_create_logical_replication_slot('merge_slot_postgres', 'pgoutput')")
|
||||
ws_cur.execute("INSERT INTO t values(generate_series(10001, 20000))")
|
||||
|
||||
# Merge ws brnach intp main
|
||||
env.neon_cli.merge(ws_branch, main_branch)
|
||||
|
||||
# sleep for some time until changes are applied
|
||||
time.sleep(2)
|
||||
|
||||
# Check that changes are merged
|
||||
assert query_scalar(main_cur, "SELECT count(*) from t") == 20000
|
||||
|
||||
Reference in New Issue
Block a user