Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csppfetch
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cspp_geo
csppfetch
Commits
ed93ff02
Commit
ed93ff02
authored
Jul 26, 2021
by
Alan De Smet
Browse files
Options
Downloads
Patches
Plain Diff
ParallelTestProcess now self-terminates on delete
This slightly simplifies usage
parent
faf9710f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test-csppfetch.py
+57
-47
57 additions, 47 deletions
test-csppfetch.py
with
57 additions
and
47 deletions
test-csppfetch.py
+
57
−
47
View file @
ed93ff02
...
...
@@ -106,11 +106,18 @@ class ParallelTestProcess:
self
.
process
.
start
()
self
.
running
=
True
def
join
(
self
,
timeout
=
None
):
self
.
process
.
join
(
timeout
)
self
.
running
=
False
def
terminate
(
self
):
if
self
.
running
:
self
.
process
.
terminate
()
self
.
running
=
False
def
is_alive
(
self
):
return
self
.
process
.
is_alive
()
def
get
(
self
):
return
self
.
qresults
.
get
()
...
...
@@ -120,6 +127,9 @@ class ParallelTestProcess:
def
is_quiet
(
self
):
return
self
.
qresults
.
empty
()
def
__del__
(
self
):
self
.
terminate
()
class
ExclusiveLockFileTests
(
DTestCase
):
def
test_exclusivelockfile
(
self
):
...
...
@@ -129,7 +139,7 @@ class ExclusiveLockFileTests(DTestCase):
p
=
[]
lockfile
=
dir
+
"
/lock
"
open
(
lockfile
,
"
x
"
).
close
()
try
:
lockfile
=
dir
+
"
/lock
"
p
=
[
ParallelTestProcess
(
f
"
p
{
i
}
"
,
ELFT_lock_proc
,
lockfile
)
for
i
in
range
(
3
)]
...
...
@@ -157,6 +167,8 @@ class ExclusiveLockFileTests(DTestCase):
self
.
assertEqual
(
p
[
1
].
get
(),
f
"
p1
{
ELFT_MSG_DONE
}
"
)
self
.
assertTrue
(
p
[
1
].
is_quiet
())
# The other locks are gone, this should be trivial
p
[
2
].
start
()
self
.
assertEqual
(
p
[
2
].
get
(),
f
"
p2
{
ELFT_MSG_WAITING
}
"
)
...
...
@@ -169,13 +181,11 @@ class ExclusiveLockFileTests(DTestCase):
self
.
assertEqual
(
p
[
2
].
get
(),
f
"
p2
{
ELFT_MSG_DONE
}
"
)
self
.
assertTrue
(
p
[
2
].
is_quiet
())
self
.
assertTrue
(
p
[
0
].
is_quiet
())
self
.
assertTrue
(
p
[
1
].
is_quiet
())
self
.
assertTrue
(
p
[
2
].
is_quiet
())
for
i
in
range
(
3
):
MAXIMUM_TIME_TO_EXIT
=
2
# seconds
p
[
i
].
join
(
MAXIMUM_TIME_TO_EXIT
)
self
.
assertFalse
(
p
[
i
].
is_alive
())
finally
:
for
i
in
p
:
i
.
terminate
()
class
AtomicCreateIfMissingTests
(
DTestCase
):
...
...
...
...
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
sign in
to comment