コード例 #1
0
ファイル: test_utils.py プロジェクト: golemfactory/goth
def test_get_container_address_no_network(mock_docker_client):
    """Test if the correct exception is raised when no matching network is found.

    Uses a modified network name, to which the returned container is not connected.
    """
    with pytest.raises(KeyError):
        get_container_address(
            mock_docker_client, TEST_CONTAINER_NAME, "missing_network"
        )
コード例 #2
0
ファイル: test_utils.py プロジェクト: golemfactory/goth
def test_get_container_address_partial_name(mock_docker_client):
    """Test if `get_container_address` returns the expected IP address.

    Uses a partial container name.
    """
    ip_address = get_container_address(mock_docker_client, "mock")
    assert ip_address == TEST_IP_ADDRESS
コード例 #3
0
ファイル: test_utils.py プロジェクト: golemfactory/goth
def test_get_container_address(mock_docker_client):
    """Test if `get_container_address` returns the expected IP address.

    Uses the default network and container names.
    """
    ip_address = get_container_address(mock_docker_client, TEST_CONTAINER_NAME)
    assert ip_address == TEST_IP_ADDRESS
コード例 #4
0
    async def _start_container(self) -> None:
        """
        Start the probe's Docker container.

        Performs all necessary steps to make the daemon ready for testing
        (e.g. creating the default app key).
        """
        self.container.start()

        # Wait until the daemon is ready to create an app key.
        self._logger.info("Waiting for connection to ya-sb-router")
        if self.container.logs:
            await self.container.logs.wait_for_entry(
                ".*connected with server: ya-sb-router.*", timeout=30
            )
        await self.create_app_key()

        self._logger.info("Waiting for yagna REST API to be listening")
        if self.container.logs:
            await self.container.logs.wait_for_entry(
                "Starting .*actix-web-service.* service on .*.", timeout=30
            )

        # Obtain the IP address of the container
        self.ip_address = get_container_address(
            self._docker_client, self.container.name
        )
        self._logger.info("IP address: %s", self.ip_address)
コード例 #5
0
 def _log_running_containers(self):
     for container in self._docker_client.containers.list():
         logger.info(
             "[%-25s] IP address: %-15s image: %s",
             container.name,
             get_container_address(self._docker_client, container.name),
             container.image.tags[0],
         )
コード例 #6
0
ファイル: test_utils.py プロジェクト: golemfactory/goth
def test_get_container_address_no_container(mock_docker_client):
    """Test if the correct exception is raised when no matching container is found."""
    mock_docker_client.containers.list.return_value = []
    with pytest.raises(ContainerNotFoundError):
        get_container_address(mock_docker_client, TEST_CONTAINER_NAME)