Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions tests/e2e_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import signal
import subprocess
import time
import threading

import pytest
from substrateinterface import SubstrateInterface
Expand Down Expand Up @@ -37,7 +38,11 @@ def local_chain(request):

# Start new node process
process = subprocess.Popen(
cmds, stdout=subprocess.PIPE, text=True, preexec_fn=os.setsid
cmds,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
preexec_fn=os.setsid,
)

# Pattern match indicates node is compiled and ready
Expand All @@ -52,16 +57,31 @@ def local_chain(request):
timestamp = int(time.time())

def wait_for_node_start(process, pattern):
for line in process.stdout:
while True:
line = process.stdout.readline()
if not line:
break

print(line.strip())
# 10 min as timeout
if int(time.time()) - timestamp > 10 * 60:
print("Subtensor not started in time")
break
return
if pattern.search(line):
print("Node started!")
break

# Start a background reader after pattern is found
# To prevent the buffer filling up
def read_output():
while True:
line = process.stdout.readline()
if not line:
break

reader_thread = threading.Thread(target=read_output, daemon=True)
reader_thread.start()

wait_for_node_start(process, pattern)

# Run the test, passing in substrate interface
Expand Down