mirror of
https://github.com/neondatabase/neon.git
synced 2026-10-28 14:36:51 +00:00
use pageserver for pg list command
This commit is contained in:
committed by
Stas Kelvich
parent
2f2dff4c8d
commit
99d80aba52
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
import psycopg2
|
||||
import getpass
|
||||
import json
|
||||
|
||||
pytest_plugins = ("fixtures.zenith_fixtures")
|
||||
|
||||
@@ -17,3 +18,34 @@ def test_status(zen_simple):
|
||||
cur.execute('status;')
|
||||
assert cur.fetchone() == ('hello world',)
|
||||
pg_conn.close()
|
||||
|
||||
def test_pg_list(zen_simple):
|
||||
username = getpass.getuser()
|
||||
page_server_conn_str = 'host={} port={} dbname=postgres user={}'.format(
|
||||
HOST, PAGESERVER_PORT, username)
|
||||
page_server_conn = psycopg2.connect(page_server_conn_str)
|
||||
page_server_conn.autocommit = True
|
||||
page_server_cur = page_server_conn.cursor()
|
||||
|
||||
page_server_cur.execute('pg_list;')
|
||||
branches = json.loads(page_server_cur.fetchone()[0])
|
||||
assert len(branches) == 1
|
||||
assert branches[0]['name'] == 'main'
|
||||
assert 'timeline_id' in branches[0]
|
||||
assert 'latest_valid_lsn' in branches[0]
|
||||
|
||||
zen_simple.zenith_cli.run(['branch', 'experimental', 'main'])
|
||||
zen_simple.zenith_cli.run(['pg', 'create', 'experimental'])
|
||||
|
||||
page_server_cur.execute('pg_list;')
|
||||
new_branches = json.loads(page_server_cur.fetchone()[0])
|
||||
assert len(new_branches) == 2
|
||||
new_branches.sort(key=lambda k: k['name'])
|
||||
|
||||
assert new_branches[0]['name'] == 'experimental'
|
||||
assert new_branches[0]['timeline_id'] != branches[0]['timeline_id']
|
||||
|
||||
# TODO: do the LSNs have to match here?
|
||||
assert new_branches[1] == branches[0]
|
||||
|
||||
page_server_conn.close()
|
||||
|
||||
Reference in New Issue
Block a user