Skip to content
Snippets Groups Projects
Verified Commit 71d5bb1f authored by Yaroslav Dynnikov's avatar Yaroslav Dynnikov
Browse files

test: arrange pytest logging

1. Print logs to the stderr so that they interleave with tarantool logs.
2. Fix `cluster.__repr__()`.
parent 1bfc5a21
No related branches found
No related tags found
1 merge request!87test: arrange pytest logging
Pipeline #4516 passed
import os import os
import re import re
import sys
import funcy # type: ignore import funcy # type: ignore
import pytest import pytest
import signal import signal
...@@ -22,6 +23,10 @@ from tarantool.error import ( # type: ignore ...@@ -22,6 +23,10 @@ from tarantool.error import ( # type: ignore
INVALID_ID = 0 INVALID_ID = 0
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
re_xdist_worker_id = re.compile(r"^gw(\d+)$") re_xdist_worker_id = re.compile(r"^gw(\d+)$")
...@@ -205,7 +210,7 @@ class Instance: ...@@ -205,7 +210,7 @@ class Instance:
os.killpg(pid, signal.SIGKILL) os.killpg(pid, signal.SIGKILL)
with suppress(ChildProcessError): with suppress(ChildProcessError):
os.waitpid(pid, 0) os.waitpid(pid, 0)
print(f"killed: {self}") eprint(f"{self} killed")
self.process = None self.process = None
def terminate(self, kill_after_seconds=10): def terminate(self, kill_after_seconds=10):
...@@ -293,7 +298,7 @@ class Cluster: ...@@ -293,7 +298,7 @@ class Cluster:
instances: list[Instance] = field(default_factory=list) instances: list[Instance] = field(default_factory=list)
def __repr__(self): def __repr__(self):
return f'Cluster("127.7.{self.subnet}.1", n={self.instances.count()})' return f'Cluster("127.7.{self.subnet}.1", n={len(self.instances)})'
def __getitem__(self, item: int) -> Instance: def __getitem__(self, item: int) -> Instance:
return self.instances[item] return self.instances[item]
...@@ -319,6 +324,7 @@ class Cluster: ...@@ -319,6 +324,7 @@ class Cluster:
for instance in self.instances: for instance in self.instances:
instance.wait_ready() instance.wait_ready()
eprint(f" {self} deployed ".center(80, "="))
return self.instances return self.instances
def kill_all(self): def kill_all(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment