Skip to content
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

Make wait_for_* methods fail-fast by default #518

Open
voodam opened this issue Sep 24, 2023 · 0 comments
Open

Make wait_for_* methods fail-fast by default #518

voodam opened this issue Sep 24, 2023 · 0 comments
Labels
Infrastructure The framework reworking and extensions low priority
Milestone

Comments

@voodam
Copy link
Contributor

voodam commented Sep 24, 2023

Problem:

We have several wait_for_* methods that by default return bool value (timeout was exceeded or not). The proper usage of this methods usualy is like this:

self.assertTrue(nginx.wait_for_connections())

Here we have problems when we forgot self.assertTrue - it can lead to hard to detect bugs (now some part of invocations of this methods haven't assert).

Proposal:

Introduce strict parameter, and check the timeout inside the method by default:

    def wait_for_connection_close(self, timeout=5, strict=True):
        """
        Try to use strict mode whenever it's possible
        to prevent tests from hard to detect errors.
        """
        timeout = adjust_timeout_for_tcp_segmentation(timeout)
        timeout_not_exceeded = util.wait_until(
            lambda: not self.connection_is_closed(),
            timeout,
            abort_cond=lambda: self.state != stateful.STATE_STARTED,
        )
        if strict:
            assert (
                timeout_not_exceeded != False
            ), f"Timeout exceeded while waiting connection close: {timeout}"
        return timeout_not_exceeded

Now we have this implemented in BaseDeproxyClient, but we should implement this in all related wait_for_* methods and switch default strict value to True (after refactoring all affected tests).

@voodam voodam added low priority Infrastructure The framework reworking and extensions labels Sep 24, 2023
@krizhanovsky krizhanovsky added this to the Backlog milestone Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure The framework reworking and extensions low priority
Projects
None yet
Development

No branches or pull requests

2 participants