Beispiel #1
0
    def test_start(self, select):
        select.select.side_effect = [KeyboardInterrupt, SystemExit]
        # TODO: v6 not supported on Travis
        # s1 = Server(mock.MagicMock(), '::1', '1234')
        # s1.start()
        # self.assertEqual(s1.socket.family, socket.AF_INET6)

        s2 = Server(mock.MagicMock(), '127.0.0.1', '2345')
        s2.start()
        self.assertEqual(s2.socket.family, socket.AF_INET6)

        s2 = Server(mock.MagicMock(), 'foo', '80')
        s2.start()
        self.assertFalse(s2.running)
Beispiel #2
0
    def setUp(self):
        aggregator = MetricsAggregator("test_host")
        self.server = Server(aggregator, "localhost", STATSD_PORT)
        self.reporter = DummyReporter(aggregator)

        self.t1 = threading.Thread(target=self.server.start)
        self.t1.start()

        confd_path = os.path.join(os.path.dirname(__file__))
        self.jmx_daemon = JMXFetch(confd_path, {'sdstatsd_port': STATSD_PORT})
        self.t2 = threading.Thread(target=self.jmx_daemon.run)
        self.t2.start()
Beispiel #3
0
    def test_start(self, select):
        select.select.side_effect = [KeyboardInterrupt, SystemExit]
        ipv6_test = False
        if _ipv6_available('::1', '1234'):
            ipv6_test = True
            s1 = Server(mock.MagicMock(), '::1', '1234')
            s1.start()
            self.assertEqual(s1.socket.family, socket.AF_INET6)

            original_so_rcvbuf = s1.socket.getsockopt(socket.SOL_SOCKET,
                                                      socket.SO_RCVBUF)

        s2 = Server(mock.MagicMock(), '127.0.0.1', '2345', so_rcvbuf=1023)
        s2.start()
        self.assertEqual(s2.socket.family, socket.AF_INET6)

        if ipv6_test:
            self.assertNotEquals(
                original_so_rcvbuf,
                s2.socket.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF))

        s2 = Server(mock.MagicMock(), 'foo', '80')
        s2.start()
        self.assertFalse(s2.running)
Beispiel #4
0
    def test_init(self):
        s = Server(None, 'localhost', '1234')

        self.assertIsNone(s.sockaddr)
        self.assertIsNone(s.socket)