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
b0d3067f
Unverified
Commit
b0d3067f
authored
2 years ago
by
Sergey V
Browse files
Options
Downloads
Patches
Plain Diff
refactor(test): make xdist_worker_number a fixture
parent
a06ff88d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/int/conftest.py
+5
-6
5 additions, 6 deletions
test/int/conftest.py
test/int/test_basics.py
+0
-18
0 additions, 18 deletions
test/int/test_basics.py
with
5 additions
and
24 deletions
test/int/conftest.py
+
5
−
6
View file @
b0d3067f
...
...
@@ -23,13 +23,13 @@ from tarantool.error import ( # type: ignore
# A constant represents invalid id of raft.
# pub const INVALID_ID: u64 = 0;
INVALID_RAFT_ID
=
0
RE_XDIST_WORKER_ID
=
re
.
compile
(
r
"
^gw(\d+)$
"
)
def
eprint
(
*
args
,
**
kwargs
):
print
(
*
args
,
file
=
sys
.
stderr
,
**
kwargs
)
@pytest.fixture
(
scope
=
"
session
"
)
def
xdist_worker_number
(
worker_id
:
str
)
->
int
:
"""
Identify xdist worker by an integer instead of a string.
...
...
@@ -40,9 +40,8 @@ def xdist_worker_number(worker_id: str) -> int:
if
worker_id
==
"
master
"
:
return
0
match
=
RE_XDIST_WORKER_ID
.
match
(
worker_id
)
if
not
match
:
raise
ValueError
(
worker_id
)
match
=
re
.
fullmatch
(
r
"
gw(\d+)
"
,
worker_id
)
assert
match
,
f
"
unexpected worker id:
{
worker_id
}
"
return
int
(
match
.
group
(
1
))
...
...
@@ -403,8 +402,8 @@ def binary_path(compile) -> str:
@pytest.fixture
def
cluster
(
binary_path
,
tmpdir
,
worker_
id
)
->
Generator
[
Cluster
,
None
,
None
]:
n
=
xdist_worker_number
(
worker_id
)
def
cluster
(
binary_path
,
tmpdir
,
xdist_
worker_
number
)
->
Generator
[
Cluster
,
None
,
None
]:
n
=
xdist_worker_number
assert
isinstance
(
n
,
int
)
assert
n
>=
0
...
...
This diff is collapsed.
Click to expand it.
test/int/test_basics.py
+
0
−
18
View file @
b0d3067f
...
...
@@ -5,7 +5,6 @@ import pytest
import
signal
from
conftest
import
(
xdist_worker_number
,
Instance
,
TarantoolError
,
ReturnError
,
...
...
@@ -13,23 +12,6 @@ from conftest import (
)
def
test_xdist_worker_number
():
assert
xdist_worker_number
(
"
master
"
)
==
0
assert
xdist_worker_number
(
"
gw0
"
)
==
0
assert
xdist_worker_number
(
"
gw1
"
)
==
1
assert
xdist_worker_number
(
"
gw007
"
)
==
7
assert
xdist_worker_number
(
"
gw1024
"
)
==
1024
with
pytest
.
raises
(
ValueError
,
match
=
r
"
gw
"
):
assert
xdist_worker_number
(
"
gw
"
)
with
pytest
.
raises
(
ValueError
,
match
=
r
"
xgw8x
"
):
assert
xdist_worker_number
(
"
xgw8x
"
)
with
pytest
.
raises
(
ValueError
,
match
=
r
"
wtf
"
):
assert
xdist_worker_number
(
"
wtf
"
)
def
test_call_normalization
(
instance
:
Instance
):
assert
instance
.
call
(
"
tostring
"
,
1
)
==
"
1
"
assert
instance
.
call
(
"
dostring
"
,
"
return
"
)
is
None
...
...
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