Skip to content

wait_for_logs fails for DockerCompose #144

Closed

Description

@bitplane

Example code:

    container = DockerCompose('.', dockerfile, pull=True)
    container.start()
    wait_for_logs(container, 'Connected with result code 0', timeout=60)

Output:

container = <testcontainers.compose.DockerCompose object at 0x10fd9a7c0>, predicate = <built-in method search of re.Pattern object at 0x7fe22e561000>, timeout = 60, interval = 1

    def wait_for_logs(container, predicate, timeout=None, interval=1):
        """
        Wait for the container to emit logs satisfying the predicate.
    
        Parameters
        ----------
        container : DockerContainer
            Container whose logs to wait for.
        predicate : callable or str
            Predicate that should be satisfied by the logs. If a string, the it is used as the pattern
            for a multiline regular expression search.
        timeout : float or None
            Number of seconds to wait for the predicate to be satisfied. Defaults to wait indefinitely.
        interval : float
            Interval at which to poll the logs.
    
        Returns
        -------
        duration : float
            Number of seconds until the predicate was satisfied.
        """
        if isinstance(predicate, str):
            predicate = re.compile(predicate, re.MULTILINE).search
        start = time.time()
        while True:
            duration = time.time() - start
>           if predicate(container._container.logs().decode()):
E           AttributeError: 'DockerCompose' object has no attribute '_container'

../../venv/lib/python3.9/site-packages/testcontainers/core/waiting_utils.py:87: AttributeError

Activity

  1. yakimka commented on Mar 27, 2022

    @yakimka
    Contributor

    Closed by #149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions