def test_correct_get_socket(self): mock_socket = mock.Mock() self.useFixture(fixtures.MonkeyPatch("glance.common.wsgi.ssl.wrap_socket", mock_socket)) self.useFixture(fixtures.MonkeyPatch("glance.common.wsgi.eventlet.listen", lambda *x, **y: None)) wsgi.get_socket(1234) self.assertIn(mock.call().setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1), mock_socket.mock_calls) self.assertIn(mock.call().setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1), mock_socket.mock_calls) if hasattr(socket, "TCP_KEEPIDLE"): self.assertIn( mock.call().setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, wsgi.CONF.tcp_keepidle), mock_socket.mock_calls, )
def test_correct_get_socket(self): mock_socket = mock.Mock() self.useFixture( fixtures.MonkeyPatch('glance.common.wsgi.ssl.wrap_socket', mock_socket)) self.useFixture( fixtures.MonkeyPatch('glance.common.wsgi.eventlet.listen', lambda *x, **y: None)) wsgi.get_socket(1234) self.assertTrue( mock.call().setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) in mock_socket.mock_calls) self.assertTrue( mock.call().setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) in mock_socket.mock_calls) if hasattr(socket, 'TCP_KEEPIDLE'): self.assertTrue(mock.call().setsockopt( socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, wsgi.CONF.tcp_keepidle) in mock_socket.mock_calls)