def test_backdoor_inuse(self):
     sock = eventlet.listen(('localhost', 0))
     port = sock.getsockname()[1]
     self.config(backdoor_port=port)
     svc = service.Service()
     self.assertRaises(socket.error, service.launch, svc)
     sock.close()
    def test_backdoor_port(self):
        self.config(backdoor_port='1234')

        sock = self.mox.CreateMockAnything()
        self.mox.StubOutWithMock(eventlet, 'listen')
        self.mox.StubOutWithMock(eventlet, 'spawn_n')

        eventlet.listen(('localhost', 1234)).AndReturn(sock)
        sock.getsockname().AndReturn(('127.0.0.1', 1234))
        eventlet.spawn_n(eventlet.backdoor.backdoor_server,
                         sock,
                         locals=mox.IsA(dict))

        self.mox.ReplayAll()

        svc = service.Service()
        launcher = service.launch(svc)
        self.assertEqual(svc.backdoor_port, 1234)
        launcher.stop()
    def test_backdoor_port_range_one_inuse(self):
        self.config(backdoor_port='8800:8900')

        sock = self.mox.CreateMockAnything()
        self.mox.StubOutWithMock(eventlet, 'listen')
        self.mox.StubOutWithMock(eventlet, 'spawn_n')

        eventlet.listen(
            ('localhost', 8800)).AndRaise(socket.error(errno.EADDRINUSE, ''))
        eventlet.listen(('localhost', 8801)).AndReturn(sock)
        sock.getsockname().AndReturn(('127.0.0.1', 8801))
        eventlet.spawn_n(eventlet.backdoor.backdoor_server,
                         sock,
                         locals=mox.IsA(dict))

        self.mox.ReplayAll()

        svc = service.Service()
        launcher = service.launch(svc)
        self.assertEqual(svc.backdoor_port, 8801)
        launcher.stop()
 def test_backdoor_port_reverse_range(self):
     # backdoor port should get passed to the service being launched
     self.config(backdoor_port='8888:7777')
     svc = service.Service()
     self.assertRaises(eventlet_backdoor.EventletBackdoorConfigValueError,
                       service.launch, svc)
Exemple #5
0
 def test_multiple_worker(self, mock_launch):
     svc = service.Service()
     service.launch(svc, workers=3)
     mock_launch.assert_called_with(svc, workers=3)
Exemple #6
0
 def _test_launch_single(self, workers, mock_launch):
     svc = service.Service()
     service.launch(svc, workers=workers)
     mock_launch.assert_called_with(svc)