summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/test_stats.py25
-rw-r--r--tests/integration/test_version.py36
2 files changed, 55 insertions, 6 deletions
diff --git a/tests/integration/test_stats.py b/tests/integration/test_stats.py
index 820b917..088d8a1 100644
--- a/tests/integration/test_stats.py
+++ b/tests/integration/test_stats.py
@@ -15,10 +15,10 @@ import xml.etree.ElementTree
15from harness import TrackerTestCase 15from harness import TrackerTestCase
16 16
17# The modes a default build answers. "tpbs" and "statedump" are full scrapes 17# The modes a default build answers. "tpbs" and "statedump" are full scrapes
18# and belong to test_fullscrape; "fulllog" and "woodpeckers" sit behind 18# and belong to test_fullscrape; "woodpeckers" sits behind a
19# feature flags this build does not set. 19# feature flag this build does not set.
20MRTG_MODES = ["peer", "conn", "scrp", "udp4", "tcp4", "torr", "fscr", "completed", "syncs"] 20MRTG_MODES = ["peer", "conn", "scrp", "udp4", "tcp4", "torr", "fscr", "completed", "syncs"]
21TEXT_MODES = ["herr", "s24s", "top10", "top100", "renew", "version"] 21TEXT_MODES = ["herr", "s24s", "top10", "top100", "renew"]
22 22
23 23
24class StatsShape(TrackerTestCase): 24class StatsShape(TrackerTestCase):
@@ -55,9 +55,22 @@ class StatsShape(TrackerTestCase):
55 self.assertIsNotNone(root.find("torrents/count_mutex")) 55 self.assertIsNotNone(root.find("torrents/count_mutex"))
56 self.assertIsNotNone(root.find("connections/tcp/announce")) 56 self.assertIsNotNone(root.find("connections/tcp/announce"))
57 57
58 def test_version_names_a_commit(self): 58 def test_the_version_mode_is_gone(self):
59 self.assertIn(b"opentracker", self.tracker.stats("version").lower() + b"opentracker") 59 """Which build a tracker is and what went into it is of use to whoever
60 self.assertRegex(self.tracker.stats("version"), rb"https?://") 60 attacks it and to nobody else on the far end of a socket. It is
61 reported by -v, to whoever already has the binary."""
62 with self.assertRaises(urllib.error.HTTPError) as caught:
63 self.tracker.stats("version")
64 self.assertEqual(caught.exception.code, 400, "an unknown mode, like any other")
65
66 def test_everything_does_not_name_the_build(self):
67 self.assertNotIn(b"opentracker 1", self.tracker.stats("everything"))
68
69 def test_everything_does_not_name_the_tracker_id(self):
70 """The id a tracker recognises its own live sync packets by. Knowing
71 it is of no use to a client and of some use to whoever would like a
72 tracker to discard what it is told."""
73 self.assertNotIn(b"tracker_id", self.tracker.stats("everything"))
61 74
62 75
63class StatsCount(TrackerTestCase): 76class StatsCount(TrackerTestCase):
diff --git a/tests/integration/test_version.py b/tests/integration/test_version.py
new file mode 100644
index 0000000..66f570d
--- /dev/null
+++ b/tests/integration/test_version.py
@@ -0,0 +1,36 @@
1"""The -v report, which is where a build says what went into it.
2
3Driving the binary is the only way to see this: the feature list is a table
4of #ifdefs, so it is only true for the flags the binary itself was built with.
5"""
6
7import subprocess
8import unittest
9
10from harness import TRACKER
11
12
13class VersionFlag(unittest.TestCase):
14 def report(self):
15 # -v writes to stderr and exits before it binds anything
16 done = subprocess.run([TRACKER, "-v"], capture_output=True, timeout=30)
17 self.assertEqual(done.returncode, 0, done.stderr)
18 return done.stderr.decode()
19
20 def test_first_line_names_the_release(self):
21 # The commit in brackets is there in a checkout and in a release
22 # tarball, and absent in a build that had neither to ask.
23 first = self.report().splitlines()[0]
24 self.assertRegex(first, r"^opentracker \d+\.\d+\.\d+( \(\S+\))?$")
25
26 def test_names_the_event_mechanism(self):
27 self.assertRegex(self.report(), r"(?m)^events: (epoll|kqueue|poll)$")
28
29 def test_lists_the_features_this_build_has(self):
30 # The Makefile builds this binary with these and not with those, so a
31 # feature table that stops following the build fails here.
32 report = self.report()
33 for want in ("WANT_KEEPALIVE", "WANT_ACCESSLIST_BLACK", "WANT_DYNAMIC_ACCESSLIST"):
34 self.assertIn(want, report)
35 for unwanted in ("WANT_SPOT_WOODPECKER", "WANT_V4_ONLY", "WANT_RESTRICT_STATS"):
36 self.assertNotIn(unwanted, report)