From 2a24660ca4b53b51bde3daedde80d8489bdeb37c Mon Sep 17 00:00:00 2001 From: Federico Ceratto Date: Tue, 14 Dec 2021 17:28:45 +0000 Subject: [PATCH] 0.51 Extract test runtime and bootstrap time --- af/fastpath/debian/changelog | 6 ++ af/fastpath/fastpath/core.py | 8 ++- af/fastpath/fastpath/tests/test_functional.py | 61 ++++++++++++++++++- af/fastpath/fastpath/tests/test_unit.py | 3 +- 4 files changed, 75 insertions(+), 3 deletions(-) diff --git a/af/fastpath/debian/changelog b/af/fastpath/debian/changelog index 4af689db..9aa5504d 100644 --- a/af/fastpath/debian/changelog +++ b/af/fastpath/debian/changelog @@ -1,3 +1,9 @@ +fastpath (0.51) unstable; urgency=medium + + * Extract test runtime from pluggable transport measurements + + -- Federico Ceratto Tue, 30 Nov 2021 17:49:15 +0000 + fastpath (0.48) unstable; urgency=medium * Bump up python version diff --git a/af/fastpath/fastpath/core.py b/af/fastpath/fastpath/core.py index d931ce64..ddef987a 100644 --- a/af/fastpath/fastpath/core.py +++ b/af/fastpath/fastpath/core.py @@ -1080,6 +1080,8 @@ def score_psiphon(msm) -> dict: logbug(0, "no resolver_ip", msm) scores["accuracy"] = 0.0 + truntime = msm.get("test_runtime") + scores["extra"] = dict(test_runtime=truntime, bootstrap_time=bootstrap_time) return scores @@ -1128,6 +1130,7 @@ def score_tor(msm) -> dict: else: scores["accuracy"] = 0.0 + scores["extra"] = dict(test_runtime=msm.get("test_runtime")) return scores @@ -1264,7 +1267,9 @@ def score_torsf(msm) -> dict: scores["blocking_general"] = 1.0 return scores - scores["extra"] = dict(bootstrap_time=tk.get("bootstrap_time")) + scores["extra"] = dict( + bootstrap_time=tk.get("bootstrap_time"), test_runtime=msm.get("test_runtime") + ) return scores @@ -1286,6 +1291,7 @@ def score_riseupvpn(msm) -> dict: if anomaly: scores["blocking_general"] = 1.0 + scores["extra"] = dict(test_runtime=msm.get("test_runtime")) return scores diff --git a/af/fastpath/fastpath/tests/test_functional.py b/af/fastpath/fastpath/tests/test_functional.py index 428402db..8bec8b46 100644 --- a/af/fastpath/fastpath/tests/test_functional.py +++ b/af/fastpath/fastpath/tests/test_functional.py @@ -142,6 +142,7 @@ def minicans(test_name, start_date: date, end_date: date, end=None): file_cnt = 0 while day <= end_date: tn_filter = set([test_name.replace("_", "")]) + log.info(day) li = s3feeder.list_minicans_on_s3_for_a_day(s3, day, None, tn_filter) for s3fname, s3size in li: # s3fname: raw/20210426/23/YE/ndt/2021042623_YE_ndt.n0.0.tar.gz @@ -613,6 +614,7 @@ def test_score_tor(): "blocking_country": 0.0, "blocking_isp": 0.0, "blocking_local": 0.0, + "extra": {"test_runtime": 31.942783471}, } # TODO: review tests break @@ -974,7 +976,7 @@ def test_score_meek_fronted_requests_test(cans): def test_score_psiphon(cans): - for can_fn, msm in s3msmts("psiphon", date(2019, 12, 20), date(2020, 1, 10)): + for can_fn, msm in s3msmts("psiphon", date(2020, 1, 9), date(2020, 1, 10)): assert msm["test_name"] == "psiphon" rid = msm["report_id"] # test version 0.3.1 has different mkeys than before @@ -993,7 +995,29 @@ def test_score_psiphon(cans): "blocking_country": 0.0, "blocking_isp": 0.0, "blocking_local": 0.0, + "extra": {"test_runtime": 15.25602748, "bootstrap_time": 5.532639553}, } + break + + +@pytest.mark.skip("slow") +def test_score_psiphon_2(): + for can_fn, msm in minicans("psiphon", date(2021, 11, 1), date(2021, 11, 2), 1): + rid = msm["report_id"] + scores = fp.score_measurement(msm) + if rid == "20211101T002503Z_psiphon_AT_40980_n1_pJPrpMWu3rfDXEcV": + assert scores == { + "accuracy": 1.0, + "blocking_general": 0.0, + "blocking_global": 0.0, + "blocking_country": 0.0, + "blocking_isp": 0.0, + "blocking_local": 0.0, + "extra": {"test_runtime": 6.774142658}, + }, msm + return + + assert 0, "Measurement not found" def test_score_http_invalid_request_line_1(): @@ -1107,6 +1131,41 @@ def test_score_signal(): # elif "accuracy" in scores: +def test_score_torsf(): + for can_fn, msm in minicans("torsf", date(2021, 11, 23), date(2021, 11, 23), 1): + scores = fp.score_measurement(msm) + assert scores == { + "blocking_general": 0.0, + "blocking_global": 0.0, + "blocking_country": 0.0, + "blocking_isp": 0.0, + "blocking_local": 0.0, + "extra": {"bootstrap_time": 142.883336871, "test_runtime": 143.090651217}, + } + assert msm["report_id"] == "20211123T142631Z_torsf_IT_30722_n1_vrWHDorLfK5ROZzS" + return + + assert 0, "Measurement not found" + + +def test_score_riseupvpn(): + for can_fn, msm in minicans("riseupvpn", date(2021, 10, 15), date(2021, 10, 16), 1): + scores = fp.score_measurement(msm) + assert scores == { + "blocking_general": 0.0, + "blocking_global": 0.0, + "blocking_country": 0.0, + "blocking_isp": 0.0, + "blocking_local": 0.0, + 'extra': {'test_runtime': 3.8260852}, + + } + assert msm["report_id"] == "20211015T005140Z_riseupvpn_AR_7303_n1_gc8so3BXiS9thxBJ" + return + + assert 0, "Measurement not found" + + def test_flag_measurements_with_wrong_date_from_future(): # measurement_start_time > msmt_uid timestamp msm = {"measurement_start_time": "2021-11-09 23:59:31"} diff --git a/af/fastpath/fastpath/tests/test_unit.py b/af/fastpath/fastpath/tests/test_unit.py index cdea6e23..b9abaccb 100644 --- a/af/fastpath/fastpath/tests/test_unit.py +++ b/af/fastpath/fastpath/tests/test_unit.py @@ -146,6 +146,7 @@ def test_score_tor(): "blocking_country": 0.0, "blocking_isp": 0.0, "blocking_local": 0.0, + "extra": {"test_runtime": 0.7671142980000001}, } @@ -229,7 +230,7 @@ def test_score_torsf2(): "blocking_global": 0.0, "blocking_isp": 0.0, "blocking_local": 0.0, - "extra": {"bootstrap_time": 78.980935917}, + "extra": {"bootstrap_time": 78.980935917, "test_runtime": 79.196301917}, }