summaryrefslogtreecommitdiff
path: root/tests/integration/test_config.py
blob: 1a84fa7a102db082a20530fb9982afa6552f713f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Settings the tracker has to accept, and still work with.

An unrecognised key makes opentracker refuse to start, so a test that it
comes up at all is a test that the key was understood.
"""

import unittest

from harness import Tracker, TrackerTestCase, free_port


class TcpWorkers(TrackerTestCase):
    config = "listen.tcp.workers 2\n"

    def test_the_tracker_serves_with_tcp_workers_asked_for(self):
        self.assertEqual(self.tracker.announce(self.hash_for("tcpworkers"))[b"complete"], 1)


class WorkersOnAListenStatement(unittest.TestCase):
    def test_a_listen_statement_may_carry_a_worker_count(self):
        """The option is read off the statement rather than inherited."""
        second = free_port()
        tracker = Tracker("listen.tcp 127.0.0.1:%d workers=2\n" % second)
        try:
            self.assertEqual(tracker.announce(b"listenopts\0\0\0\0\0\0\0\0\0\0")[b"complete"], 1)
            complaints = tracker.stop()
            self.assertEqual(complaints, [], "the tracker reported:\n" + "\n".join(complaints))
        finally:
            tracker._cleanup()