mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-16 01:42:55 +00:00
Implement LogUtils in the Endpoint fixture class, so that the "log_contains" function can be used on compute logs too. Per discussion at: https://github.com/neondatabase/neon/pull/7288#discussion_r1623633803
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import time
|
|
|
|
from fixtures.neon_fixtures import NeonEnv
|
|
|
|
|
|
def test_migrations(neon_simple_env: NeonEnv):
|
|
env = neon_simple_env
|
|
env.neon_cli.create_branch("test_migrations", "empty")
|
|
|
|
endpoint = env.endpoints.create("test_migrations")
|
|
endpoint.respec(skip_pg_catalog_updates=False)
|
|
endpoint.start()
|
|
|
|
endpoint.wait_for_migrations()
|
|
|
|
num_migrations = 9
|
|
|
|
with endpoint.cursor() as cur:
|
|
cur.execute("SELECT id FROM neon_migration.migration_id")
|
|
migration_id = cur.fetchall()
|
|
assert migration_id[0][0] == num_migrations
|
|
|
|
endpoint.assert_log_contains(f"INFO handle_migrations: Ran {num_migrations} migrations")
|
|
|
|
endpoint.stop()
|
|
endpoint.start()
|
|
# We don't have a good way of knowing that the migrations code path finished executing
|
|
# in compute_ctl in the case that no migrations are being run
|
|
time.sleep(1)
|
|
with endpoint.cursor() as cur:
|
|
cur.execute("SELECT id FROM neon_migration.migration_id")
|
|
migration_id = cur.fetchall()
|
|
assert migration_id[0][0] == num_migrations
|
|
|
|
endpoint.assert_log_contains("INFO handle_migrations: Ran 0 migrations")
|