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
ddc0ef5b
Commit
ddc0ef5b
authored
2 years ago
by
Georgy Moshkin
Committed by
Georgy Moshkin
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
test: add test for graceful shutdown
parent
04e17d60
No related branches found
No related tags found
1 merge request
!219
Resolve "Graceful shutdown times out quite often"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/conftest.py
+6
-0
6 additions, 0 deletions
test/conftest.py
test/int/test_couple.py
+27
-0
27 additions, 0 deletions
test/int/test_couple.py
with
33 additions
and
0 deletions
test/conftest.py
+
6
−
0
View file @
ddc0ef5b
...
...
@@ -194,6 +194,7 @@ class Instance:
env
:
dict
[
str
,
str
]
=
field
(
default_factory
=
dict
)
process
:
subprocess
.
Popen
|
None
=
None
raft_id
:
int
=
INVALID_RAFT_ID
_on_output_callbacks
:
list
[
Callable
[[
str
],
None
]]
=
field
(
default_factory
=
list
)
@property
def
listen
(
self
):
...
...
@@ -290,6 +291,11 @@ class Instance:
out
.
write
(
prefix
)
out
.
write
(
line
)
out
.
flush
()
for
cb
in
self
.
_on_output_callbacks
:
cb
(
line
)
def
on_output_line
(
self
,
cb
:
Callable
[[
str
],
None
]):
self
.
_on_output_callbacks
.
append
(
cb
)
def
start
(
self
,
peers
=
[]):
if
self
.
process
:
...
...
This diff is collapsed.
Click to expand it.
test/int/test_couple.py
+
27
−
0
View file @
ddc0ef5b
...
...
@@ -197,3 +197,30 @@ def test_gl119_panic_in_on_shutdown(cluster2: Cluster):
# wait for the follower to start acquiring the read barrier
sleep
(
1
)
assert
i2
.
terminate
()
==
0
# it's 2022 and i have to work around a mypy bug reported in 2018
on_shutdown_timed_out
:
bool
def
test_gl127_graceul_shutdown
(
cluster2
:
Cluster
):
i1
,
i2
=
cluster2
.
instances
# make sure i1 is leader
i1
.
promote_or_fail
()
i2
.
wait_ready
()
global
on_shutdown_timed_out
on_shutdown_timed_out
=
False
def
check_log_line
(
log
):
if
"
on_shutdown triggers are timed out
"
in
log
:
global
on_shutdown_timed_out
on_shutdown_timed_out
=
True
i1
.
on_output_line
(
check_log_line
)
# on_shutdown triggers will timeout after 3sec
# so we must wait longer than # that
i1
.
terminate
(
kill_after_seconds
=
10
)
assert
not
on_shutdown_timed_out
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