diff options
Diffstat (limited to 'tests/integration')
| -rw-r--r-- | tests/integration/test_config.py | 29 | ||||
| -rw-r--r-- | tests/integration/test_expiry.py | 7 |
2 files changed, 35 insertions, 1 deletions
diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py new file mode 100644 index 0000000..1a84fa7 --- /dev/null +++ b/tests/integration/test_config.py | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | """Settings the tracker has to accept, and still work with. | ||
| 2 | |||
| 3 | An unrecognised key makes opentracker refuse to start, so a test that it | ||
| 4 | comes up at all is a test that the key was understood. | ||
| 5 | """ | ||
| 6 | |||
| 7 | import unittest | ||
| 8 | |||
| 9 | from harness import Tracker, TrackerTestCase, free_port | ||
| 10 | |||
| 11 | |||
| 12 | class TcpWorkers(TrackerTestCase): | ||
| 13 | config = "listen.tcp.workers 2\n" | ||
| 14 | |||
| 15 | def test_the_tracker_serves_with_tcp_workers_asked_for(self): | ||
| 16 | self.assertEqual(self.tracker.announce(self.hash_for("tcpworkers"))[b"complete"], 1) | ||
| 17 | |||
| 18 | |||
| 19 | class WorkersOnAListenStatement(unittest.TestCase): | ||
| 20 | def test_a_listen_statement_may_carry_a_worker_count(self): | ||
| 21 | """The option is read off the statement rather than inherited.""" | ||
| 22 | second = free_port() | ||
| 23 | tracker = Tracker("listen.tcp 127.0.0.1:%d workers=2\n" % second) | ||
| 24 | try: | ||
| 25 | self.assertEqual(tracker.announce(b"listenopts\0\0\0\0\0\0\0\0\0\0")[b"complete"], 1) | ||
| 26 | complaints = tracker.stop() | ||
| 27 | self.assertEqual(complaints, [], "the tracker reported:\n" + "\n".join(complaints)) | ||
| 28 | finally: | ||
| 29 | tracker._cleanup() | ||
diff --git a/tests/integration/test_expiry.py b/tests/integration/test_expiry.py index 5a21e57..5e6dc0a 100644 --- a/tests/integration/test_expiry.py +++ b/tests/integration/test_expiry.py | |||
| @@ -27,6 +27,11 @@ class ExpirySweep(TrackerTestCase): | |||
| 27 | def test_the_sweep_takes_the_idle_and_leaves_the_answered(self): | 27 | def test_the_sweep_takes_the_idle_and_leaves_the_answered(self): |
| 28 | idle = socket.create_connection(("127.0.0.1", self.tracker.port), timeout=5) | 28 | idle = socket.create_connection(("127.0.0.1", self.tracker.port), timeout=5) |
| 29 | try: | 29 | try: |
| 30 | # Enough for a kernel that holds a connection back until data | ||
| 31 | # arrives to hand it over, and far too little to be answered, so | ||
| 32 | # the tracker has accepted it and is waiting for the rest | ||
| 33 | idle.sendall(b"GET /ann") | ||
| 34 | |||
| 30 | self.assertEqual(self.tracker.announce(self.hash_for("expiry-sweep"))[b"complete"], 1) | 35 | self.assertEqual(self.tracker.announce(self.hash_for("expiry-sweep"))[b"complete"], 1) |
| 31 | 36 | ||
| 32 | time.sleep(CLIENT_TIMEOUT + 3 * CHECK_INTERVAL) | 37 | time.sleep(CLIENT_TIMEOUT + 3 * CHECK_INTERVAL) |
| @@ -34,6 +39,6 @@ class ExpirySweep(TrackerTestCase): | |||
| 34 | self.assertEqual(self.tracker.torrent_count(), 1, "the tracker stopped serving while sweeping") | 39 | self.assertEqual(self.tracker.torrent_count(), 1, "the tracker stopped serving while sweeping") |
| 35 | 40 | ||
| 36 | idle.settimeout(5) | 41 | idle.settimeout(5) |
| 37 | self.assertEqual(idle.recv(64), b"", "a connection that never sent a request was not swept") | 42 | self.assertEqual(idle.recv(64), b"", "a connection that went quiet mid-request was not swept") |
| 38 | finally: | 43 | finally: |
| 39 | idle.close() | 44 | idle.close() |
