mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-08 14:02:55 +00:00
- The 'pageserver' fixture now sets up the repository and starts up
the Page Server automatically. In other words, the 'pageserver'
fixture provides a Page Server that's up and running and ready to
use in tests.
- The 'pageserver' fixture now also creates a branch called 'empty',
right after initializing the repository. By convention, all the
tests start by createing a new branch off 'empty' for the test. This
allows running all the tests against the same Page Server
concurrently. (I haven't tested that though. pytest doensn't
provide an option to run tests in parallel but there are extensions
for that.)
- Remove the 'zen_simple' fixture. Now that 'pageserver' provides
server that's up and running, it's pretty simple to use the
'pageserver' and 'postgres' fixtures directly.
- Don't assume host name or ports in the tests. They now use the
fields in the fixtures for that. That allows assigning the ports
dynamically, making it possible to run multiple page servers in
parallel, or running the tests in parallel with another page
server. This commit still hard codes the Page Server's port in the
fixture, though, so more work is needed to actually make it
possible.
- I made some changes to the 'postgres' fixture in commit 532918e13d,
which broke the other tests. Fix them.
- Divide the tests into two "batches" of roughly equal runtime, which
can be run in parallel
- Merge the 'test_file' and 'test_filter' options in CircleCI config
into one 'test_selection' option, for simplicity.
53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
import pytest
|
|
import psycopg2
|
|
import getpass
|
|
import json
|
|
|
|
pytest_plugins = ("fixtures.zenith_fixtures")
|
|
|
|
def test_status(pageserver):
|
|
pg_conn = psycopg2.connect(pageserver.connstr())
|
|
pg_conn.autocommit = True
|
|
cur = pg_conn.cursor()
|
|
cur.execute('status;')
|
|
assert cur.fetchone() == ('hello world',)
|
|
pg_conn.close()
|
|
|
|
def test_pg_list(pageserver, zenith_cli):
|
|
|
|
# Create a branch for us
|
|
zenith_cli.run(["branch", "test_pg_list_main", "empty"]);
|
|
|
|
page_server_conn = psycopg2.connect(pageserver.connstr())
|
|
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])
|
|
# Filter out branches created by other tests
|
|
branches = [x for x in branches if x['name'].startswith('test_pg_list')]
|
|
|
|
assert len(branches) == 1
|
|
assert branches[0]['name'] == 'test_pg_list_main'
|
|
assert 'timeline_id' in branches[0]
|
|
assert 'latest_valid_lsn' in branches[0]
|
|
|
|
# Create another branch, and start Postgres on it
|
|
zenith_cli.run(['branch', 'test_pg_list_experimental', 'test_pg_list_main'])
|
|
zenith_cli.run(['pg', 'create', 'test_pg_list_experimental'])
|
|
|
|
page_server_cur.execute('pg_list;')
|
|
new_branches = json.loads(page_server_cur.fetchone()[0])
|
|
# Filter out branches created by other tests
|
|
new_branches = [x for x in new_branches if x['name'].startswith('test_pg_list')]
|
|
assert len(new_branches) == 2
|
|
new_branches.sort(key=lambda k: k['name'])
|
|
|
|
assert new_branches[0]['name'] == 'test_pg_list_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()
|