Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
i4refit
framework
Commits
33822835
Commit
33822835
authored
3 years ago
by
Michael Eischer
Browse files
Options
Downloads
Patches
Plain Diff
Parallelize ping measurements
parent
6ccb1fdd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/test/measure_server_pings.py
+32
-14
32 additions, 14 deletions
scripts/test/measure_server_pings.py
with
32 additions
and
14 deletions
scripts/test/measure_server_pings.py
+
32
−
14
View file @
33822835
#!/usr/bin/env python3
import
argparse
import
subprocess
from
typing
import
Sequence
from
concurrent.futures.thread
import
ThreadPoolExecutor
from
typing
import
Sequence
,
Tuple
from
benchmark
import
GenericTestRun
,
main
...
...
@@ -17,24 +18,41 @@ class MeasureServerPings(GenericTestRun):
def
setup_args
(
cls
,
parser
:
argparse
.
ArgumentParser
)
->
None
:
parser
.
add_argument
(
"
duration
"
,
help
=
"
Duration of the test run
"
,
type
=
int
)
def
stage_build
(
self
)
->
bool
:
# Nothing to do for this test
return
True
def
_ping
(
self
,
src
,
dst
)
->
Tuple
[
str
,
int
]:
ssh
=
self
.
start_ssh
(
self
.
config
[
"
remote.user
"
],
src
,
"
ping
"
,
"
-c
"
,
str
(
self
.
duration
),
dst
,
stdout
=
subprocess
.
PIPE
)
(
output
,
_
)
=
ssh
.
communicate
()
log
=
"
=== Ping from {} to {} ===
"
.
format
(
src
,
dst
)
if
ssh
.
returncode
!=
0
:
log
+=
"
\n
Measurement error {}
"
.
format
(
ssh
.
returncode
)
return
log
,
ssh
.
returncode
for
line
in
output
.
decode
(
"
utf-8
"
).
splitlines
():
if
"
rtt min/avg/max/mdev
"
in
line
:
log
+=
"
\n
"
+
line
return
log
,
0
def
stage_bench
(
self
)
->
bool
:
servers
=
self
.
get_servers
((
"
client.network.addresses
"
,
"
replica.network.addresses
"
))
for
(
i
,
dst
)
in
enumerate
(
servers
):
for
j
in
range
(
i
+
1
,
len
(
servers
)):
src
=
servers
[
j
]
self
.
log
(
"
=== Ping from {} to {} ===
"
.
format
(
src
,
dst
))
ssh
=
self
.
start_ssh
(
self
.
config
[
"
remote.user
"
],
src
,
"
ping
"
,
"
-c
"
,
str
(
self
.
duration
),
dst
,
stdout
=
subprocess
.
PIPE
)
(
output
,
_
)
=
ssh
.
communicate
()
if
ssh
.
returncode
!=
0
:
self
.
log
(
"
Measurement error {}
"
.
format
(
ssh
.
returncode
))
with
ThreadPoolExecutor
(
max_workers
=
30
)
as
executor
:
results
=
[]
for
(
i
,
dst
)
in
enumerate
(
servers
):
for
j
in
range
(
i
+
1
,
len
(
servers
)):
src
=
servers
[
j
]
res
=
executor
.
submit
(
self
.
_ping
,
src
,
dst
)
results
.
append
(
res
)
for
res
in
results
:
r
=
res
.
result
()
self
.
log
(
r
[
0
])
if
r
[
1
]
!=
0
:
return
False
for
line
in
output
.
decode
(
"
utf-8
"
).
splitlines
():
if
"
rtt min/avg/max/mdev
"
in
line
:
self
.
log
(
line
)
return
True
...
...
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