Skip to content

wait_for_logs fails for DockerCompose #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bitplane opened this issue May 11, 2021 · 1 comment
Closed

wait_for_logs fails for DockerCompose #144

bitplane opened this issue May 11, 2021 · 1 comment

Comments

@bitplane
Copy link
Contributor

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
@yakimka
Copy link
Collaborator

yakimka commented Mar 27, 2022

Closed by #149

@yakimka yakimka closed this as completed Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants