diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-08 20:08:44 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-08 20:08:44 +0100 |
| commit | 1c2af535eb3052405503f136578e30b24a8e18ae (patch) | |
| tree | 4842c19092623f0c8d666fe97065be329ad538c1 /tests/integration/test_stats.py | |
| parent | 0d4be1abb93d37b10e0c7835bd79b62639945651 (diff) | |
Retire the busy network tracker. /24 networks don't say anything anymore in 2026 and in v6 it was broken from the beginning
Diffstat (limited to 'tests/integration/test_stats.py')
| -rw-r--r-- | tests/integration/test_stats.py | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/tests/integration/test_stats.py b/tests/integration/test_stats.py index c4ac95a..46ca39b 100644 --- a/tests/integration/test_stats.py +++ b/tests/integration/test_stats.py | |||
| @@ -5,9 +5,7 @@ every one of them and, where the number means something, that it moves when | |||
| 5 | the thing it counts happens. | 5 | the thing it counts happens. |
| 6 | """ | 6 | """ |
| 7 | 7 | ||
| 8 | import ipaddress | ||
| 9 | import re | 8 | import re |
| 10 | import socket | ||
| 11 | import unittest | 9 | import unittest |
| 12 | import urllib.error | 10 | import urllib.error |
| 13 | import xml.etree.ElementTree | 11 | import xml.etree.ElementTree |
| @@ -18,7 +16,7 @@ from harness import TrackerTestCase | |||
| 18 | # and belong to test_fullscrape; "woodpeckers" sits behind a | 16 | # and belong to test_fullscrape; "woodpeckers" sits behind a |
| 19 | # feature flag this build does not set. | 17 | # feature flag this build does not set. |
| 20 | MRTG_MODES = ["peer", "conn", "scrp", "udp4", "tcp4", "torr", "fscr", "completed", "syncs"] | 18 | MRTG_MODES = ["peer", "conn", "scrp", "udp4", "tcp4", "torr", "fscr", "completed", "syncs"] |
| 21 | TEXT_MODES = ["herr", "s24s", "top10", "top100", "renew"] | 19 | TEXT_MODES = ["herr", "top10", "top100", "renew"] |
| 22 | 20 | ||
| 23 | 21 | ||
| 24 | class StatsShape(TrackerTestCase): | 22 | class StatsShape(TrackerTestCase): |
| @@ -144,48 +142,5 @@ class StatsTop(TrackerTestCase): | |||
| 144 | self.assertIn(heading, body) | 142 | self.assertIn(heading, body) |
| 145 | 143 | ||
| 146 | 144 | ||
| 147 | class StatsNetworks(TrackerTestCase): | ||
| 148 | def source_address(self): | ||
| 149 | """Which address the tracker sees us from is not ours to choose: a | ||
| 150 | FreeBSD jail relocates a loopback connection to the jail's own | ||
| 151 | address, so ask the socket rather than assume 127.0.0.1.""" | ||
| 152 | probe = socket.create_connection(("127.0.0.1", self.tracker.port), timeout=5) | ||
| 153 | try: | ||
| 154 | return probe.getsockname()[0] | ||
| 155 | finally: | ||
| 156 | probe.close() | ||
| 157 | |||
| 158 | def test_the_slash24_report_names_the_announcing_network(self): | ||
| 159 | source = self.source_address() | ||
| 160 | self.tracker.announce(self.hash_for("s24"), port=6001, left=0) | ||
| 161 | body = self.tracker.stats("s24s") | ||
| 162 | self.assertIn(b"Networks, limit /28:", body) | ||
| 163 | self.assertIn(b"Networks, limit /24:", body) | ||
| 164 | |||
| 165 | # The prefix is the first three address bytes of a v4 peer, left | ||
| 166 | # aligned in a sixteen byte buffer and then printed by the v6 | ||
| 167 | # formatter, so 127.0.0.0/24 reads as "7f00::" rather than as the | ||
| 168 | # network an operator asked about. Pinned as it is, not blessed. | ||
| 169 | prefix = socket.inet_aton(source)[:3] + b"\0" * 13 | ||
| 170 | self.assertIn(str(ipaddress.IPv6Address(prefix)).encode(), body) | ||
| 171 | |||
| 172 | def test_the_report_counts_one_network_per_announcing_address(self): | ||
| 173 | for port in (6001, 6002, 6003): | ||
| 174 | self.tracker.announce(self.hash_for("s24count"), port=port, left=0) | ||
| 175 | lines = [line for line in self.tracker.stats("s24s").splitlines() if b":" in line and b"limit" not in line] | ||
| 176 | self.assertEqual(len(lines), 2, "one line under each of the two limits") | ||
| 177 | for line in lines: | ||
| 178 | self.assertEqual(int(line.split(b":")[0]), 3, "three peers from the one network") | ||
| 179 | |||
| 180 | def test_the_report_survives_a_torrent_with_no_v4_peers(self): | ||
| 181 | # A torrent whose only peer is v6 has no v4 peer list once the lists | ||
| 182 | # are allocated on demand. The s24 report walks the v4 list of every | ||
| 183 | # torrent, so it has to skip the absent one rather than follow a null | ||
| 184 | # pointer. Needs WANT_IP_FROM_QUERY_STRING to force the family; without | ||
| 185 | # it the peer is loopback v4 and the walk is never asked to skip. | ||
| 186 | self.tracker.announce(self.hash_for("s24v6only"), ip="2001:db8::1", port=6001, left=0) | ||
| 187 | self.assertIn(b"Networks, limit /24:", self.tracker.stats("s24s")) | ||
| 188 | |||
| 189 | |||
| 190 | if __name__ == "__main__": | 145 | if __name__ == "__main__": |
| 191 | unittest.main() | 146 | unittest.main() |
