Skip to content

Commit

Permalink
0.51 Extract test runtime and bootstrap time
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Ceratto committed Dec 14, 2021
1 parent 597decd commit 2a24660
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
6 changes: 6 additions & 0 deletions af/fastpath/debian/changelog
@@ -1,3 +1,9 @@
fastpath (0.51) unstable; urgency=medium

* Extract test runtime from pluggable transport measurements

-- Federico Ceratto <federico@debian.org> Tue, 30 Nov 2021 17:49:15 +0000

fastpath (0.48) unstable; urgency=medium

* Bump up python version
Expand Down
8 changes: 7 additions & 1 deletion af/fastpath/fastpath/core.py
Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand All @@ -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


Expand Down
61 changes: 60 additions & 1 deletion af/fastpath/fastpath/tests/test_functional.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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():
Expand Down Expand Up @@ -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"}
Expand Down
3 changes: 2 additions & 1 deletion af/fastpath/fastpath/tests/test_unit.py
Expand Up @@ -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},
}


Expand Down Expand Up @@ -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},
}


Expand Down

0 comments on commit 2a24660

Please sign in to comment.