GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit c02d9b1e authored by juga  's avatar juga 💬

chg: v3bwfile: Count recent relay's monitoring numbers

using timestamps class.
Also add one more result to the tests data and change the
test accordingly.
parent 035d325c
......@@ -656,26 +656,29 @@ class V3BWLine(object):
kwargs['master_key_ed25519'] = results[0].master_key_ed25519
kwargs['time'] = cls.last_time_from_results(results)
kwargs.update(cls.result_types_from_results(results))
consensuses_count = \
[r.relay_in_recent_consensus_count for r in results
if getattr(r, 'relay_in_recent_consensus_count', None)]
if consensuses_count:
consensus_count = max(consensuses_count)
kwargs['relay_in_recent_consensus_count'] = str(consensus_count)
measurements_attempts = \
[r.relay_recent_measurement_attempt_count for r in results
if getattr(r, 'relay_recent_measurement_attempt_count', None)]
if measurements_attempts:
kwargs['relay_recent_measurement_attempt_count'] = \
str(max(measurements_attempts))
relay_recent_priority_list_counts = \
[r.relay_recent_priority_list_count for r in results
if getattr(r, 'relay_recent_priority_list_count', None)]
if relay_recent_priority_list_counts:
kwargs['relay_recent_priority_list_count'] = \
str(max(relay_recent_priority_list_counts))
# If it has not the attribute, return list to be able to call len
# If it has the attribute, but it is None, return also list
kwargs['relay_in_recent_consensus_count'] = str(
max([
len(getattr(r, 'relay_in_recent_consensus', []) or [])
for r in results
])
)
kwargs['relay_recent_priority_list_count'] = str(
max([
len(getattr(r, 'relay_recent_priority_list', []) or [])
for r in results
])
)
kwargs['relay_recent_measurement_attempt_count'] = str(
max([
len(getattr(r, 'relay_recent_measurement_attempt', []) or [])
for r in results
])
)
success_results = [r for r in results if isinstance(r, ResultSuccess)]
......
{"version": 4, "time": 1523887747, "circ": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"], "type": "success", "rtts": [0.4596822261810303, 0.44872617721557617, 0.4563450813293457, 0.44872212409973145, 0.4561030864715576, 0.4765200614929199, 0.4495084285736084, 0.45711588859558105, 0.45520496368408203, 0.4635589122772217], "fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "scanner": "IDidntEditTheSBWSConfig", "downloads": [{"amount": 590009, "duration": 6.1014368534088135}, {"amount": 590009, "duration": 8.391342878341675}, {"amount": 321663, "duration": 7.064587831497192}, {"amount": 321663, "duration": 8.266003131866455}, {"amount": 321663, "duration": 5.779450178146362}], "dest_url": "http://y.z", "nickname": "A", "address": "111.111.111.111", "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s", "relay_average_bandwidth": 1000000000, "relay_burst_bandwidth": 123456, "relay_observed_bandwidth": 524288, "consensus_bandwidth": 600000, "consensus_bandwidth_is_unmeasured": false, "relay_recent_measurement_attempt_count": 1, "relay_recent_priority_list_count": 3}
{"version": 4, "time": 1523974147, "circ": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"], "type": "error-stream", "msg": "Something bad happened while measuring bandwidth", "fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "scanner": "IDidntEditTheSBWSConfig", "dest_url": "http://y.z", "nickname": "A", "address": "111.111.111.111", "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s", "relay_recent_measurement_attempt_count": 2, "relay_recent_priority_list_count": 3}
{"version": 4, "time": 1523974147, "circ": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"], "type": "error-stream", "msg": "Something bad happened while measuring bandwidth", "fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "scanner": "IDidntEditTheSBWSConfig", "dest_url": "http://y.z", "nickname": "A", "address": "111.111.111.111", "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s"}
{"version": 4, "time": 1523887747, "circ": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"], "type": "success", "rtts": [0.4596822261810303, 0.44872617721557617, 0.4563450813293457, 0.44872212409973145, 0.4561030864715576, 0.4765200614929199, 0.4495084285736084, 0.45711588859558105, 0.45520496368408203, 0.4635589122772217], "fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "scanner": "IDidntEditTheSBWSConfig", "downloads": [{"amount": 590009, "duration": 6.1014368534088135}, {"amount": 590009, "duration": 8.391342878341675}, {"amount": 321663, "duration": 7.064587831497192}, {"amount": 321663, "duration": 8.266003131866455}, {"amount": 321663, "duration": 5.779450178146362}], "dest_url": "http://y.z", "nickname": "A", "address": "111.111.111.111", "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s", "relay_average_bandwidth": 1000000000, "relay_burst_bandwidth": 123456, "relay_observed_bandwidth": 524288, "consensus_bandwidth": 600000, "consensus_bandwidth_is_unmeasured": false, "relay_in_recent_consensus": ["2018-04-07T14:09:07", "2018-04-07T14:09:07", "2018-04-07T14:09:07"], "relay_recent_measurement_attempt": ["2018-04-07T14:09:07", "2018-04-07T14:09:07"], "relay_recent_priority_list": ["2018-04-07T14:09:07", "2018-04-07T14:09:07", "2018-04-07T14:09:07"]}
{"version": 4, "time": 1523974147, "circ": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"], "type": "error-stream", "msg": "Something bad happened while measuring bandwidth", "fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "scanner": "IDidntEditTheSBWSConfig", "dest_url": "http://y.z", "nickname": "A", "address": "111.111.111.111", "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s", "relay_in_recent_consensus": ["2018-04-07T14:09:07", "2018-04-07T14:09:07", "2018-04-07T14:09:07"], "relay_recent_measurement_attempt": ["2018-04-07T14:09:07", "2018-04-07T14:09:07"], "relay_recent_priority_list": ["2018-04-07T14:09:07", "2018-04-07T14:09:07", "2018-04-07T14:09:07"]}
......@@ -69,12 +69,13 @@ raw_bwl_str = "bw=56 bw_mean=61423 bw_median=55656 "\
"consensus_bandwidth=600000 consensus_bandwidth_is_unmeasured=False "\
"desc_bw_avg=1000000000 desc_bw_bur=123456 desc_bw_obs_last=524288 "\
"desc_bw_obs_mean=524288 error_circ=0 error_destination=0 error_misc=0 " \
"error_second_relay=0 error_stream=1 " \
"error_second_relay=0 error_stream=2 " \
"master_key_ed25519=g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s " \
"nick=A " \
"node_id=$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA "\
"relay_in_recent_consensus_count=3 "\
"relay_recent_measurement_attempt_count=2 "\
"relay_recent_measurements_excluded_error_count=1 "\
"relay_recent_measurements_excluded_error_count=2 "\
"relay_recent_priority_list_count=3 "\
"rtt=456 success=1 " \
"time=2018-04-17T14:09:07\n"
......@@ -571,3 +572,24 @@ def test_recent_priority_relay_count(root_data_path, datadir):
results = load_result_file(str(datadir.join("results.txt")))
header = V3BWHeader.from_results(results, '', '', state_fpath)
assert "15" == header.recent_priority_relay_count
def test_relay_recent_measurement_attempt_count(root_data_path, datadir):
results = load_result_file(str(datadir.join("results.txt")))
for fp, values in results.items():
line = V3BWLine.from_results(values)
assert "2" == line[0].relay_recent_measurement_attempt_count
def test_relay_recent_priority_list_count(root_data_path, datadir):
results = load_result_file(str(datadir.join("results.txt")))
for fp, values in results.items():
line = V3BWLine.from_results(values)
assert "3" == line[0].relay_recent_priority_list_count
def test_relay_in_recent_consensus_count(root_data_path, datadir):
results = load_result_file(str(datadir.join("results.txt")))
for fp, values in results.items():
line = V3BWLine.from_results(values)
assert "3" == line[0].relay_in_recent_consensus_count
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment