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
The Tor Project
Network Health
sbws
Commits
f5e611c2
Commit
f5e611c2
authored
Mar 12, 2019
by
juga
Browse files
new: v3bwfile: Set relays exclusion KeyValues
Part of
#28565
.
parent
718a3145
Changes
2
Hide whitespace changes
Inline
Side-by-side
sbws/lib/v3bwfile.py
View file @
f5e611c2
...
...
@@ -453,6 +453,15 @@ class V3BWHeader(object):
[
setattr
(
self
,
k
,
str
(
v
))
for
k
,
v
in
kwargs
.
items
()
if
k
in
STATS_KEYVALUES
]
def
add_relays_excluded_counters
(
self
,
exclusion_dict
):
"""
Add the monitoring KeyValues to the header about the number of
relays not included because they were not ``eligible``.
"""
log
.
debug
(
"Adding relays excluded counters."
)
for
k
,
v
in
exclusion_dict
.
items
():
setattr
(
self
,
k
,
str
(
v
))
class
V3BWLine
(
object
):
"""
...
...
@@ -798,12 +807,26 @@ class V3BWFile(object):
number_consensus_relays
=
cls
.
read_number_consensus_relays
(
consensus_path
)
state
=
State
(
state_fpath
)
# Create a dictionary with the number of relays excluded by any of the
# of the filtering rules that makes relays non-`eligible`.
# NOTE: In BW_HEADER_KEYVALUES_RECENT_MEASUREMENTS_EXCLUDED it is
# explained what are the KeyValues.
# See also the comments in `from_results`.
exclusion_dict
=
dict
(
[(
k
,
0
)
for
k
in
BW_HEADER_KEYVALUES_RECENT_MEASUREMENTS_EXCLUDED
]
)
for
fp
,
values
in
results
.
items
():
# log.debug("Relay fp %s", fp)
line
,
reason
=
V3BWLine
.
from_results
(
values
,
secs_recent
,
secs_away
,
min_num
)
if
line
is
not
None
:
bw_lines_raw
.
append
(
line
)
else
:
exclusion_dict
[
reason
]
=
exclusion_dict
.
get
(
reason
,
0
)
+
1
# Add the headers with the number of excluded relays by reason
header
.
add_relays_excluded_counters
(
exclusion_dict
)
if
not
bw_lines_raw
:
log
.
info
(
"After applying restrictions to the raw results, "
"there is not any. Scaling can not be applied."
)
...
...
tests/unit/lib/test_v3bwfile.py
View file @
f5e611c2
...
...
@@ -61,9 +61,7 @@ raw_bwl_str = "bw=56 bw_mean=61423 bw_median=55656 "\
"nick=A "
\
"node_id=$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA "
\
"relay_recent_measurement_attempt_count=2 "
\
"relay_recent_measurement_exclusion_not_distanciated_count=0 "
\
"relay_recent_measurement_exclusion_not_recent_count=0 "
\
"relay_recent_measurement_exclusion_not_success_count=1 "
\
"relay_recent_measurements_excluded_error_count=1 "
\
"relay_recent_priority_list_count=3 "
\
"rtt=456 success=1 "
\
"time=2018-04-17T14:09:07
\n
"
...
...
@@ -315,7 +313,7 @@ def test_results_away_each_other(datadir):
# There is one result excluded, but the relay is not excluded
bwl
,
reason
=
V3BWLine
.
from_results
(
values
,
secs_away
=
secs_away
,
min_num
=
2
)
assert
bwl
.
relay_recent_measurement_exclu
sion
_error_count
==
1
assert
bwl
.
relay_recent_measurement
s
_exclu
ded
_error_count
==
1
assert
reason
is
None
success_results
=
[
r
for
r
in
values
if
isinstance
(
r
,
ResultSuccess
)]
...
...
@@ -330,8 +328,8 @@ def test_results_away_each_other(datadir):
# the relay is excluded
bwl
,
reason
=
V3BWLine
.
from_results
(
values
,
secs_away
=
secs_away
,
min_num
=
2
)
# TODO ticket28563: uncomment
# assert bwl.relay_recent_measurement_exclu
sion
_near_count == 2
assert
reason
==
'recent_measurement_exclu
sion
_near_count'
# assert bwl.relay_recent_measurement
s
_exclu
ded
_near_count == 2
assert
reason
==
'recent_measurement
s
_exclu
ded
_near_count'
success_results
=
[
r
for
r
in
values
if
isinstance
(
r
,
ResultSuccess
)]
assert
len
(
success_results
)
>=
min_num
...
...
@@ -349,8 +347,8 @@ def test_results_away_each_other(datadir):
# There is only 1 result, the relay is excluded
bwl
,
reason
=
V3BWLine
.
from_results
(
values
,
min_num
=
2
)
# TODO ticket28563: uncomment
# assert bwl.recent_measurement_exclu
sion
_few_count == 1
assert
reason
==
'recent_measurement_exclu
sion
_few_count'
# assert bwl.recent_measurement
s
_exclu
ded
_few_count == 1
assert
reason
==
'recent_measurement
s
_exclu
ded
_few_count'
success_results
=
[
r
for
r
in
values
if
isinstance
(
r
,
ResultSuccess
)]
assert
len
(
success_results
)
<
min_num
...
...
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