Skip to content

Commit

Permalink
Add test case for down NXDOMAIN case
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Apr 24, 2024
1 parent 012660e commit f4c7d52
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions oonipipeline/tests/_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"20221110235922.335062_IR_webconnectivity_e4114ee32b8dbf74", # Iran blocking reddit
"20240420235427.477327_US_webconnectivity_9b3cac038dc2ba22", # down site
"20240302000048.790188_RU_webconnectivity_e7ffd3bc0f525eb7", # connection reset RU
"20240302000050.000654_SN_webconnectivity_fe4221088fbdcb0a", # nxdomain down
]

SAMPLE_POSTCANS = ["2024030100_AM_webconnectivity.n1.0.tar.gz"]
Expand Down
33 changes: 33 additions & 0 deletions oonipipeline/tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,36 @@ def test_website_web_analysis_blocked_connect_reset(

assert sum(down_dict.values()) < sum(blocked_dict.values())
assert blocked_dict["tls.connection_reset"] > 0.5


def print_debug_er(er):
for idx, e in enumerate(er):
print(f"\n# ER#{idx}")
for idx, transcript in enumerate(e.analysis_transcript_list):
print(f"## Analysis #{idx}")
print("\n".join(transcript))
pprint(er)

Check warning on line 389 in oonipipeline/tests/test_analysis.py

View check run for this annotation

Codecov / codecov/patch

oonipipeline/tests/test_analysis.py#L384-L389

Added lines #L384 - L389 were not covered by tests


def test_website_web_analysis_nxdomain_down(measurements, netinfodb, fingerprintdb):
msmt_path = measurements[
"20240302000050.000654_SN_webconnectivity_fe4221088fbdcb0a"
]
msmt = load_measurement(msmt_path=msmt_path)
er, web_analysis, web_obs, web_ctrl_obs = make_web_er_from_msmt(
msmt, fingerprintdb=fingerprintdb, netinfodb=netinfodb
)
assert len(web_analysis) == len(web_obs)
assert len(web_ctrl_obs) == 2

assert len(er) == 1
assert er[0].loni_ok_value < 0.2

ok_dict = dict(zip(er[0].loni_ok_keys, er[0].loni_ok_values))
assert ok_dict["dns"] == 0

down_dict = dict(zip(er[0].loni_down_keys, er[0].loni_down_values))
blocked_dict = dict(zip(er[0].loni_blocked_keys, er[0].loni_blocked_values))

assert sum(down_dict.values()) > sum(blocked_dict.values())
assert down_dict["dns.nxdomain"] > 0.7

0 comments on commit f4c7d52

Please sign in to comment.