mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-14 17:02:56 +00:00
Add test restarting compute node to investigate flukyness of test_subscriber_restart
This commit is contained in:
41
test_runner/regress/test_compute_restart.py
Normal file
41
test_runner/regress/test_compute_restart.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import threading
|
||||
import time
|
||||
|
||||
from fixtures.neon_fixtures import NeonEnv
|
||||
from fixtures.utils import wait_until
|
||||
|
||||
|
||||
def test_compute_restart(neon_simple_env: NeonEnv):
|
||||
env = neon_simple_env
|
||||
env.neon_cli.create_branch("publisher")
|
||||
pub = env.endpoints.create("publisher")
|
||||
pub.start()
|
||||
|
||||
sub_timeline_id = env.neon_cli.create_branch("subscriber")
|
||||
sub = env.endpoints.create("subscriber")
|
||||
sub.start()
|
||||
|
||||
n_records = 100000
|
||||
n_restarts = 200
|
||||
|
||||
def insert_data(pub):
|
||||
with pub.cursor() as pcur:
|
||||
for i in range(0, n_records):
|
||||
pcur.execute("INSERT into t values (%s,random()*100000)", (i,))
|
||||
|
||||
with pub.cursor() as pcur:
|
||||
with sub.cursor() as scur:
|
||||
pcur.execute("CREATE TABLE t (pk integer primary key, sk integer)")
|
||||
scur.execute("CREATE TABLE t (pk integer primary key, sk integer)")
|
||||
|
||||
thread = threading.Thread(target=insert_data, args=(pub,), daemon=True)
|
||||
thread.start()
|
||||
|
||||
for _ in range(n_restarts):
|
||||
# restart subscriber
|
||||
# time.sleep(2)
|
||||
sub.stop("immediate", sks_wait_walreceiver_gone=(env.safekeepers, sub_timeline_id))
|
||||
sub.start()
|
||||
|
||||
thread.join()
|
||||
|
||||
Reference in New Issue
Block a user