Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
70381298
Unverified
Commit
70381298
authored
2 years ago
by
Sergey V
Browse files
Options
Downloads
Patches
Plain Diff
refactor: add prefixes to the instance output
parent
6f640421
No related branches found
No related tags found
No related merge requests found
Pipeline
#5396
passed
2 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/int/conftest.py
+30
-4
30 additions, 4 deletions
test/int/conftest.py
with
30 additions
and
4 deletions
test/int/conftest.py
+
30
−
4
View file @
70381298
import
io
import
os
import
re
import
sys
import
threading
import
funcy
# type: ignore
import
pytest
import
signal
...
...
@@ -20,7 +22,7 @@ from tarantool.error import ( # type: ignore
# From raft.rs:
# A constant represents invalid id of raft.
# pub const INVALID_ID: u64 = 0;
INVALID_ID
=
0
INVALID_
RAFT_
ID
=
0
RE_XDIST_WORKER_ID
=
re
.
compile
(
r
"
^gw(\d+)$
"
)
...
...
@@ -121,6 +123,9 @@ class RaftStatus:
is_ready
:
bool
OUT_LOCK
=
threading
.
Lock
()
@dataclass
class
Instance
:
binary_path
:
str
...
...
@@ -133,7 +138,7 @@ class Instance:
env
:
dict
[
str
,
str
]
=
field
(
default_factory
=
dict
)
process
:
subprocess
.
Popen
|
None
=
None
raft_id
:
int
=
INVALID_ID
raft_id
:
int
=
INVALID_
RAFT_
ID
@property
def
listen
(
self
):
...
...
@@ -214,6 +219,14 @@ class Instance:
finally
:
self
.
kill
()
def
_process_output
(
self
,
src
,
out
):
prefix
=
f
"
{
self
.
instance_id
}
|
"
for
line
in
io
.
TextIOWrapper
(
src
,
line_buffering
=
True
):
with
OUT_LOCK
:
out
.
write
(
prefix
)
out
.
write
(
line
)
out
.
flush
()
def
start
(
self
):
if
self
.
process
:
# Be idempotent
...
...
@@ -224,8 +237,22 @@ class Instance:
env
=
self
.
env
or
None
,
stdin
=
subprocess
.
DEVNULL
,
start_new_session
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
)
for
src
,
out
in
[
(
self
.
process
.
stdout
,
sys
.
stdout
),
(
self
.
process
.
stderr
,
sys
.
stderr
),
]:
threading
.
Thread
(
target
=
self
.
_process_output
,
args
=
(
src
,
out
),
daemon
=
True
,
).
start
()
eprint
(
f
"
{
self
}
started
"
)
eprint
(
f
"
{
self
}
starting...
"
)
# Assert a new process group is created
...
...
@@ -396,8 +423,7 @@ def cluster(binary_path, tmpdir, worker_id) -> Generator[Cluster, None, None]:
max_port
=
max_port
,
)
yield
cluster
cluster
.
terminate
()
cluster
.
remove_data
()
cluster
.
kill
()
@pytest.fixture
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment