Beispiel #1
0
    def test_init_poolmanager(self, mock_parent_init_poolmanager, mock_socket):
        spec = ['IPPROTO_TCP', 'TCP_NODELAY', 'SOL_SOCKET', 'SO_KEEPALIVE']
        mock_socket.mock_add_spec(spec)
        adapter = client_session.TCPKeepAliveAdapter()
        adapter.init_poolmanager()

        call_args, call_kwargs = mock_parent_init_poolmanager.call_args
        called_socket_opts = call_kwargs['socket_options']
        call_options = [opt for (protocol, opt, value) in called_socket_opts]
        self.assertEqual([mock_socket.TCP_NODELAY, mock_socket.SO_KEEPALIVE],
                         call_options)
    def test_init_poolmanager(self, mock_parent_init_poolmanager, mock_socket):
        spec = ['IPPROTO_TCP', 'TCP_NODELAY', 'SOL_SOCKET', 'SO_KEEPALIVE']
        mock_socket.mock_add_spec(spec)
        adapter = client_session.TCPKeepAliveAdapter()
        adapter.init_poolmanager()

        call_args, call_kwargs = mock_parent_init_poolmanager.call_args
        called_socket_opts = call_kwargs['socket_options']
        call_options = [opt for (protocol, opt, value) in called_socket_opts]
        self.assertEqual([mock_socket.TCP_NODELAY, mock_socket.SO_KEEPALIVE],
                         call_options)
 def test_init_poolmanager(self, mock_init_poolmgr):
     adapter = novaclient.client.TCPKeepAliveAdapter()
     kwargs = {}
     adapter.init_poolmanager(**kwargs)
     if requests.__version__ >= '2.4.1':
         kwargs.setdefault('socket_options', [
             (socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),
             (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
         ])
     # NOTE(melwitt): This is called twice because
     #                HTTPAdapter.__init__ calls it first.
     self.assertEqual(2, mock_init_poolmgr.call_count)
     mock_init_poolmgr.assert_called_with(**kwargs)
Beispiel #4
0
 def test_init_poolmanager(self, mock_init_poolmgr):
     adapter = novaclient.client.TCPKeepAliveAdapter()
     kwargs = {}
     adapter.init_poolmanager(**kwargs)
     if requests.__version__ >= '2.4.1':
         kwargs.setdefault('socket_options', [
             (socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),
             (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
         ])
     # NOTE(melwitt): This is called twice because
     #                HTTPAdapter.__init__ calls it first.
     self.assertEqual(2, mock_init_poolmgr.call_count)
     mock_init_poolmgr.assert_called_with(**kwargs)
Beispiel #5
0
    def test_init_poolmanager_all_options(self, mock_parent_init_poolmanager,
                                          mock_socket):
        # properties expected to be in socket.
        mock_socket.TCP_KEEPIDLE = mock.sentinel.TCP_KEEPIDLE
        mock_socket.TCP_KEEPCNT = mock.sentinel.TCP_KEEPCNT
        mock_socket.TCP_KEEPINTVL = mock.sentinel.TCP_KEEPINTVL
        desired_opts = [mock_socket.TCP_KEEPIDLE, mock_socket.TCP_KEEPCNT,
                        mock_socket.TCP_KEEPINTVL]

        adapter = client_session.TCPKeepAliveAdapter()
        adapter.init_poolmanager()

        call_args, call_kwargs = mock_parent_init_poolmanager.call_args
        called_socket_opts = call_kwargs['socket_options']
        call_options = [opt for (protocol, opt, value) in called_socket_opts]
        for opt in desired_opts:
            self.assertIn(opt, call_options)
    def test_init_poolmanager_all_options(self, mock_parent_init_poolmanager,
                                          mock_socket):
        # properties expected to be in socket.
        mock_socket.TCP_KEEPIDLE = mock.sentinel.TCP_KEEPIDLE
        mock_socket.TCP_KEEPCNT = mock.sentinel.TCP_KEEPCNT
        mock_socket.TCP_KEEPINTVL = mock.sentinel.TCP_KEEPINTVL
        desired_opts = [mock_socket.TCP_KEEPIDLE, mock_socket.TCP_KEEPCNT,
                        mock_socket.TCP_KEEPINTVL]

        adapter = client_session.TCPKeepAliveAdapter()
        adapter.init_poolmanager()

        call_args, call_kwargs = mock_parent_init_poolmanager.call_args
        called_socket_opts = call_kwargs['socket_options']
        call_options = [opt for (protocol, opt, value) in called_socket_opts]
        for opt in desired_opts:
            self.assertIn(opt, call_options)