[tor-commits] [sbws/maint-1.1] fix: tests: Add bw filtered from results
juga at torproject.org
juga at torproject.org
Tue Mar 16 14:17:53 UTC 2021
commit e3b4c4ed4d84bee543b47fd0d683050b3d00182b
Author: juga0 <juga at riseup.net>
Date: Mon Mar 15 14:25:13 2021 +0000
fix: tests: Add bw filtered from results
---
tests/unit/lib/test_scaling.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tests/unit/lib/test_scaling.py b/tests/unit/lib/test_scaling.py
index 2e4212c..4a02359 100644
--- a/tests/unit/lib/test_scaling.py
+++ b/tests/unit/lib/test_scaling.py
@@ -1,7 +1,9 @@
"""Unit tests for scaling.py."""
+import os
from statistics import mean
from sbws.lib import scaling
+from sbws.lib.resultdump import load_result_file, ResultSuccess
def test_bw_filt():
@@ -38,3 +40,30 @@ def test_bw_filt():
assert 10 == round(mean(bw_measurements))
# Because 10 and 20 are bigger or equal than the mean
assert 15 == scaling.bw_filt(bw_measurements)
+
+
+def test_bw_filt_from_results(root_data_path):
+ results_file = os.path.join(
+ root_data_path, ".sbws", "datadir", "2019-03-25.txt"
+ )
+ results = load_result_file(results_file)
+ bw_filts = {}
+ for fp, values in results.items():
+ success_results = [r for r in values if isinstance(r, ResultSuccess)]
+ if success_results:
+ bw_measurements = scaling.bw_measurements_from_results(
+ success_results
+ )
+ mu = round(mean(bw_measurements))
+ muf = scaling.bw_filt(bw_measurements)
+ bw_filts[fp] = (mu, muf)
+ for fp, values in bw_filts.items():
+ assert bw_filts[fp][0] <= bw_filts[fp][1]
+ assert 5526756 == bw_filts['117A456C911114076BEB4E757AC48B16CC0CCC5F'][0]
+ assert 5643086 == bw_filts['117A456C911114076BEB4E757AC48B16CC0CCC5F'][1]
+ assert 5664965 == bw_filts['693F73187624BE760AAD2A12C5ED89DB1DE044F5'][0]
+ assert 5774274 == bw_filts['693F73187624BE760AAD2A12C5ED89DB1DE044F5'][1]
+ assert 5508279 == bw_filts['270A861ABED22EC2B625198BCCD7B2B9DBFFC93C'][0]
+ assert 5583737 == bw_filts['270A861ABED22EC2B625198BCCD7B2B9DBFFC93C'][1]
+ assert 5379911 == bw_filts['E894C65997F8EC96558B554176EEEA39C6A43EF6'][0]
+ assert 5485088 == bw_filts['E894C65997F8EC96558B554176EEEA39C6A43EF6'][1]
More information about the tor-commits
mailing list