def setUp(self):
     """Per-test setup."""
     # Put each test in its own test dir, so it's hermetic.
     self.test_dir = tempfile.mkdtemp(dir=ClientTests.test_dir)
     self.address = os.path.join(self.test_dir,
                                 lxc.DEFAULT_CONTAINER_POOL_SOCKET)
     self.listener = async_listener.AsyncListener(self.address)
     self.listener.start()
Ejemplo n.º 2
0
    def __init__(self, host_dir, pool=None):
        """Sets up a new container pool service.

        @param host_dir: A SharedHostDir.  This will be used for Zygote
                         configuration as well as for general pool operation
                         (e.g. opening linux domain sockets for communication).
        @param pool: (for testing) A container pool that the service will
                     maintain.  This parameter exists for DI, for testing.
                     Under normal circumstances the service instantiates the
                     container pool internally.
        """
        # Create socket for receiving container pool requests.  This also acts
        # as a mutex, preventing multiple container pools from being
        # instantiated.
        self._socket_path = os.path.join(
            host_dir.path, constants.DEFAULT_CONTAINER_POOL_SOCKET)
        self._connection_listener = async_listener.AsyncListener(
            self._socket_path)
        self._client_threads = []
        self._stop_event = None
        self._running = False
        self._pool = pool
Ejemplo n.º 3
0
 def testInetAddresses(self):
     """Verifies that inet addresses raise errors."""
     with self.assertRaises(TypeError):
         async_listener.AsyncListener(('127.0.0.1', 0))
Ejemplo n.º 4
0
 def testAddressConflict(self):
     """Verifies that address conflicts raise errors."""
     with self.assertRaises(socket.error):
         async_listener.AsyncListener(self.address)
Ejemplo n.º 5
0
 def testInvalidAddresses(self):
     """Verifies that invalid socket paths raise errors."""
     with self.assertRaises(socket.error):
         invalid_address = os.path.join(self.tmpdir, 'foo', 'socket')
         async_listener.AsyncListener(invalid_address)
Ejemplo n.º 6
0
 def setUp(self):
     self.tmpdir = tempfile.mkdtemp()
     self.address = os.path.join(self.tmpdir, 'socket')
     self.authkey = 'foo'
     self.listener = async_listener.AsyncListener(self.address)