Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
juga
sbws
Commits
887d71d9
Commit
887d71d9
authored
Dec 15, 2021
by
Georg Koppen
Browse files
Merge remote-tracking branch 'gitlab/merge-requests/106' into m13
parents
b6fe7989
46f2a6dd
Changes
5
Hide whitespace changes
Inline
Side-by-side
sbws/core/scanner.py
View file @
887d71d9
...
...
@@ -731,7 +731,7 @@ def main_loop(
# At this point, we know the relays that were queued to be
# measured.
log
.
debug
(
"Attempted to measure %s relays in %
s
minutes"
,
"Attempted to measure %s relays in %
i
minutes
.
"
,
num_relays
,
loop_tdelta
,
)
...
...
sbws/lib/heartbeat.py
View file @
887d71d9
...
...
@@ -56,16 +56,23 @@ class Heartbeat(object):
log
.
info
(
"Run %s main loops."
,
loops_count
)
log
.
info
(
"Measured in total %s (%s%%) unique relays in %s minutes"
,
"Measured in total %s (%s%% of the last consensus) unique relays"
" in %i minutes"
,
len
(
self
.
measured_fp_set
),
new_measured_percent
,
main_loop_tdelta
,
)
log
.
info
(
"%s relays still not measured."
,
len
(
not_measured_fp_set
))
log
.
info
(
"%s relays from the last consensus are not measured yet."
,
len
(
not_measured_fp_set
),
)
# The case when it is equal will only happen when all the relays
# have been measured.
if
new_measured_percent
<=
self
.
previous_measurement_percent
:
log
.
warning
(
"There is no progress measuring new unique relays."
)
log
.
warning
(
"There is no progress measuring new unique relays with respect"
" to the previous loop."
)
self
.
previous_measurement_percent
=
new_measured_percent
sbws/lib/v3bwfile.py
View file @
887d71d9
...
...
@@ -648,7 +648,8 @@ class V3BWHeader(object):
elapsed_time
*
consensus_relays
/
eligible_relays
)
log
.
info
(
"Estimated time to measure the network: %s hours."
,
"Estimated time to successfully report about all the relays in the"
" last consensus: %s hours."
,
round
(
estimated_time
/
60
/
60
),
)
...
...
@@ -1320,14 +1321,15 @@ class V3BWFile(object):
/
(
max
(
1
,
(
sum_consensus_bw
+
sum_bw
))
/
2
)
)
*
100
log
.
info
(
"The difference between the total consensus bandwidth (%s)"
"and the total measured bandwidth (%s) is %s%%."
,
"The difference between the sum of the last consensus weight (%s "
"KB) and the sum of the reported weight in this Bandwidth File "
"(%s KB) is %s%%."
,
sum_consensus_bw
,
sum_bw
,
round
(
diff_perc
),
)
if
diff_perc
>
MAX_BW_DIFF_PERC
:
log
.
warning
(
"It is more than %s%%"
,
max_bw_diff_perc
)
log
.
warning
(
"It is more than %s%%
.
"
,
max_bw_diff_perc
)
return
True
return
False
...
...
@@ -1352,8 +1354,8 @@ class V3BWFile(object):
mu
=
mean
([
l
.
bw_mean
for
l
in
bw_lines
])
# filtered mean (Torflow's filt_avg)
muf
=
mean
([
l
.
bw_filt
for
l
in
bw_lines
])
log
.
debug
(
"mu %
s
"
,
mu
)
log
.
debug
(
"muf %
s
"
,
muf
)
log
.
debug
(
"mu %
i bytes.
"
,
mu
)
log
.
debug
(
"muf %
i bytes.
"
,
muf
)
# Torflow's ``tot_net_bw``, sum of the scaled bandwidth for the relays
# that are in the last consensus
...
...
@@ -1421,7 +1423,12 @@ class V3BWFile(object):
# Cap maximum bw, only possible when the ``sum_bw`` is calculated.
# Torflow's clipping
hlimit
=
sum_bw
*
cap
log
.
debug
(
"sum_bw: %s, hlimit: %s"
,
sum_bw
,
hlimit
)
log
.
debug
(
"Sum of all the reported relays' scaled bandwidth: %i bytes, "
"the limit for any relay is: %i bytes"
,
sum_bw
,
hlimit
,
)
for
l
in
bw_lines_tf
:
bw_scaled
=
min
(
hlimit
,
l
.
bw
)
# round and convert to KB
...
...
@@ -1454,7 +1461,7 @@ class V3BWFile(object):
)
except
(
FileNotFoundError
,
AttributeError
):
log
.
warning
(
"It is not possible to obtain the last consensus"
"It is not possible to obtain the last consensus
"
"cached file %s."
,
consensus_path
,
)
...
...
@@ -1550,17 +1557,16 @@ class V3BWFile(object):
def
info_stats
(
self
):
if
not
self
.
bw_lines
:
return
[
log
.
info
(
": "
.
join
([
attr
,
str
(
getattr
(
self
,
attr
))]))
for
attr
in
[
"sum_bw"
,
"mean_bw"
,
"median_bw"
,
"num"
,
"max_bw"
,
"min_bw"
,
]
]
log
.
info
(
"Bandwidth File with:"
)
for
attr
in
[
"sum_bw"
,
"mean_bw"
,
"median_bw"
,
"max_bw"
,
"min_bw"
,
]:
log
.
info
(
"%s: %s KB."
,
attr
,
str
(
getattr
(
self
,
attr
)))
log
.
info
(
"%s Bandwidth Lines"
,
str
(
getattr
(
self
,
"num"
)))
def
update_progress
(
self
,
num_bw_lines
,
header
,
number_consensus_relays
,
state
...
...
tests/unit/lib/test_heartbeat.py
View file @
887d71d9
...
...
@@ -46,8 +46,8 @@ def test_print_heartbeat_message(conf, caplog):
assert
hbeat
.
previous_measurement_percent
==
33
assert
"Run None main loops."
in
caplog
.
records
[
0
].
getMessage
()
assert
"Measured in total 1 (33%
)
"
in
caplog
.
records
[
1
].
getMessage
()
log_relay_not_measured
=
"3 relays
still not measured
"
assert
"Measured in total 1 (33%"
in
caplog
.
records
[
1
].
getMessage
()
log_relay_not_measured
=
"3 relays
from the last consensus are not
"
assert
log_relay_not_measured
in
caplog
.
records
[
2
].
getMessage
()
caplog
.
clear
()
...
...
@@ -58,5 +58,5 @@ def test_print_heartbeat_message(conf, caplog):
caplog
.
set_level
(
logging
.
WARNING
)
hbeat
.
print_heartbeat_message
()
log_no_progress
=
"There is no progress measuring new unique relays
.
"
log_no_progress
=
"There is no progress measuring new unique relays"
assert
log_no_progress
in
caplog
.
records
[
0
].
getMessage
()
tests/unit/lib/test_v3bwfile.py
View file @
887d71d9
...
...
@@ -597,7 +597,10 @@ def test_time_measure_half_network(caplog):
caplog
.
set_level
(
logging
.
INFO
)
header
.
add_time_report_half_network
()
assert
header
.
time_to_report_half_network
==
"70200"
# 19.5h
expected_log
=
"Estimated time to measure the network: 39 hours."
# 19.5*2
expected_log
=
(
"Estimated time to successfully report about all the "
"relays in the last consensus: 39 hours."
)
# 19.5*2
assert
caplog
.
records
[
-
1
].
getMessage
()
==
expected_log
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment