[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/master] Add test about the measured relays statistics
commit 2d705ee3029cebeb2254b5011d02a94ab285ba1e
Author: juga0 <juga@xxxxxxxxxx>
Date: Tue Oct 23 12:24:32 2018 +0000
Add test about the measured relays statistics
---
tests/unit/lib/test_v3bwfile.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/tests/unit/lib/test_v3bwfile.py b/tests/unit/lib/test_v3bwfile.py
index a53d5db..0618167 100644
--- a/tests/unit/lib/test_v3bwfile.py
+++ b/tests/unit/lib/test_v3bwfile.py
@@ -182,3 +182,33 @@ def test_results_away_each_other(datadir):
values = results["CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"]
success_results = [r for r in values if isinstance(r, ResultSuccess)]
assert len(success_results) < min_num
+
+
+def test_measured_progress_stats(datadir):
+ num_net_relays = 3
+ bw_lines_raw = []
+ statsd_exp = {'perc_measured_relays': 100, 'perc_measured_targed': 60,
+ 'num_net_relays': 3, 'num_target_relays': 2,
+ 'num_measured_relays': 3}
+ min_perc_reached_before = None
+ results = load_result_file(str(datadir.join("results_away.txt")))
+ for fp, values in results.items():
+ # log.debug("Relay fp %s", fp)
+ line = V3BWLine.from_results(values)
+ if line is not None:
+ bw_lines_raw.append(line)
+ assert len(bw_lines_raw) == 3
+ bw_lines = V3BWFile.bw_torflow_scale(bw_lines_raw)
+ assert len(bw_lines) == 3
+ statsd, success = V3BWFile.measured_progress_stats(bw_lines,
+ num_net_relays, min_perc_reached_before)
+ assert success
+ assert statsd == statsd_exp
+ num_net_relays = 6
+ statsd, success = V3BWFile.measured_progress_stats(bw_lines,
+ num_net_relays, min_perc_reached_before)
+ assert not success
+ statsd_exp = {'perc_measured_relays': 50, 'perc_measured_targed': 60,
+ 'num_net_relays': 6, 'num_target_relays': 4,
+ 'num_measured_relays': 3}
+ assert statsd_exp == statsd
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits