예제 #1
0
    def testInit(self):
        """Test `IdleConnectionMonitoringProtocol.__init__`."""
        monitor = IdleConnectionMonitoringProtocol(None, self.server,
                                                   self.config)
        IC = IdleConnectionMonitoringProtocol
        self.assertEqual(monitor.maxDelay, IC.MAX_DELAY)
        self.assertEqual(monitor.toCleanReconnect, IC.TIMEOUT_CLEAN_RECONNECT)
        self.assertEqual(monitor.keepAlive, IC.KEEPALIVE)
        self.assertEqual(monitor.keepAliveRetries, IC.KEEPALIVE_RETRIES)
        self.assertEqual(monitor.keepAliveIdle, IC.KEEPALIVE_IDLE)
        self.assertEqual(monitor.keepAliveInterval, IC.KEEPALIVE_INTERVAL)

        self.config.update({
            'idleconnection.max-delay': '123',
            'idleconnection.timeout-clean-reconnect': '456',
            'idleconnection.keepalive': 'true',
            'idleconnection.keepalive-retries': 5,
            'idleconnection.keepalive-idle': 8,
            'idleconnection.keepalive-interval': 60
        })
        monitor = IdleConnectionMonitoringProtocol(None, self.server,
                                                   self.config)
        self.assertEqual(monitor.maxDelay, 123)
        self.assertEqual(monitor.toCleanReconnect, 456)
        self.assertTrue(monitor.keepAlive)
        self.assertEqual(monitor.keepAliveRetries, 5)
        self.assertEqual(monitor.keepAliveIdle, 8)
        self.assertEqual(monitor.keepAliveInterval, 60)
예제 #2
0
 def testInit(self):
     """Test `IdleConnectionMonitoringProtocol.__init__`."""
     monitor = IdleConnectionMonitoringProtocol(None, None, self.config)
     self.assertEquals(monitor.maxDelay,
                       IdleConnectionMonitoringProtocol.MAX_DELAY)
     self.assertEquals(
         monitor.toCleanReconnect,
         IdleConnectionMonitoringProtocol.TIMEOUT_CLEAN_RECONNECT)
     self.config['idleconnection.max-delay'] = '123'
     self.config['idleconnection.timeout-clean-reconnect'] = '456'
     monitor = IdleConnectionMonitoringProtocol(None, None, self.config)
     self.assertEquals(monitor.maxDelay, 123)
     self.assertEquals(monitor.toCleanReconnect, 456)
예제 #3
0
class IdleConnectionMonitoringProtocolTestCase(PyBalTestCase):
    """Test case for `pybal.monitors.IdleConnectionMonitoringProtocol`."""
    def setUp(self):
        super(IdleConnectionMonitoringProtocolTestCase, self).setUp()
        self.config = pybal.util.ConfigDict()
        self.monitor = IdleConnectionMonitoringProtocol(
            self.coordinator, self.server, self.config)
        self.monitor.reactor = self.reactor

    def testInit(self):
        """Test `IdleConnectionMonitoringProtocol.__init__`."""
        monitor = IdleConnectionMonitoringProtocol(None, self.server,
                                                   self.config)
        self.assertEquals(monitor.maxDelay,
                          IdleConnectionMonitoringProtocol.MAX_DELAY)
        self.assertEquals(
            monitor.toCleanReconnect,
            IdleConnectionMonitoringProtocol.TIMEOUT_CLEAN_RECONNECT)
        self.config['idleconnection.max-delay'] = '123'
        self.config['idleconnection.timeout-clean-reconnect'] = '456'
        monitor = IdleConnectionMonitoringProtocol(None, self.server,
                                                   self.config)
        self.assertEquals(monitor.maxDelay, 123)
        self.assertEquals(monitor.toCleanReconnect, 456)

    def testRun(self):
        """Test `IdleConnectionMonitoringProtocol.run`."""
        self.monitor.run()
        connector = self.reactor.connectors.pop()
        destination = connector.getDestination()
        self.assert_((destination.host, destination.port)
                     == (self.server.host, self.server.port)
                     or (destination.host, destination.port)
                     == (self.server.ip, self.server.port))

    def testClientConnectionMade(self):
        """Test `IdleConnectionMonitoringProtocol.clientConnectionMade`."""
        self.monitor.run()
        self.monitor.up = False
        self.monitor.clientConnectionMade()
        self.assertTrue(self.monitor.up)

    def testBuildProtocol(self):
        """Test `IdleConnectionMonitoringProtocol.buildProtocol`."""
        self.monitor.run()
        self.monitor.up = False
        self.monitor.buildProtocol(None)
        self.assertTrue(self.monitor.up)
예제 #4
0
class IdleConnectionMonitoringProtocolTestCase(PyBalTestCase):
    """Test case for `pybal.monitors.IdleConnectionMonitoringProtocol`."""

    def setUp(self):
        super(IdleConnectionMonitoringProtocolTestCase, self).setUp()
        self.config = pybal.util.ConfigDict()
        self.monitor = IdleConnectionMonitoringProtocol(
            self.coordinator, self.server, self.config)
        self.monitor.reactor = self.reactor

    def testInit(self):
        """Test `IdleConnectionMonitoringProtocol.__init__`."""
        monitor = IdleConnectionMonitoringProtocol(None, None, self.config)
        self.assertEquals(
            monitor.maxDelay, IdleConnectionMonitoringProtocol.MAX_DELAY)
        self.assertEquals(
            monitor.toCleanReconnect,
            IdleConnectionMonitoringProtocol.TIMEOUT_CLEAN_RECONNECT
        )
        self.config['idleconnection.max-delay'] = '123'
        self.config['idleconnection.timeout-clean-reconnect'] = '456'
        monitor = IdleConnectionMonitoringProtocol(None, None, self.config)
        self.assertEquals(monitor.maxDelay, 123)
        self.assertEquals(monitor.toCleanReconnect, 456)

    def testRun(self):
        """Test `IdleConnectionMonitoringProtocol.run`."""
        self.monitor.run()
        connector = self.reactor.connectors.pop()
        destination = connector.getDestination()
        self.assertEquals((destination.host, destination.port),
                          (self.server.host, self.server.port))

    def testClientConnectionMade(self):
        """Test `IdleConnectionMonitoringProtocol.clientConnectionMade`."""
        self.monitor.run()
        self.monitor.up = False
        self.monitor.clientConnectionMade()
        self.assertTrue(self.monitor.up)

    def testBuildProtocol(self):
        """Test `IdleConnectionMonitoringProtocol.buildProtocol`."""
        self.monitor.run()
        self.monitor.up = False
        self.monitor.buildProtocol(None)
        self.assertTrue(self.monitor.up)
예제 #5
0
 def setUp(self):
     super(IdleConnectionMonitoringProtocolTestCase, self).setUp()
     self.config = pybal.util.ConfigDict()
     self.monitor = IdleConnectionMonitoringProtocol(
         self.coordinator, self.server, self.config)
     self.monitor.reactor = self.reactor
예제 #6
0
 def setUp(self):
     super(IdleConnectionMonitoringProtocolTestCase, self).setUp()
     self.config = pybal.util.ConfigDict()
     self.monitor = IdleConnectionMonitoringProtocol(
         self.coordinator, self.server, self.config)
     self.monitor.reactor = self.reactor