Skip to content

Conversation

@pandafy
Copy link
Member

@pandafy pandafy commented May 22, 2025

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #464

Description of Changes

Retry selenium tests if the tests fails on the first attempt. This prevents failng the CI build from flaky tests.

@pandafy pandafy moved this from To do (general) to In progress in OpenWISP Contributor's Board May 22, 2025
@coveralls
Copy link

coveralls commented May 22, 2025

Coverage Status

coverage: 95.962% (-0.2%) from 96.156%
when pulling 750df2f on issues/464-retry-selenium
into 60e8e44 on master.

@pandafy
Copy link
Member Author

pandafy commented May 22, 2025

The test suite would fail if the test is flaky

Found 1 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
--------------------------------------------------------------------------------
[Retry] Retrying "test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism.test_retry_mechanism_fails", attempt 1/5. 
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
[Retry] Retrying "test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism.test_retry_mechanism_fails", attempt 2/5. 
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
[Retry] Retrying "test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism.test_retry_mechanism_fails", attempt 3/5. 
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
[Retry] Retrying "test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism.test_retry_mechanism_fails", attempt 4/5. 
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
[Retry] Retrying "test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism.test_retry_mechanism_fails", attempt 5/5. 
--------------------------------------------------------------------------------

Summary of slow tests (>0.3s)


Total slow tests detected: 0

======================================================================
FAIL: test_retry_mechanism_fails (test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/pandafy/openwisp/openwisp-utils/tests/test_project/tests/test_selenium.py", line 796, in test_retry_mechanism_fails
    self.fail('Report failed tests')
AssertionError: Report failed tests

----------------------------------------------------------------------
Ran 1 test in 2.187s

FAILED (failures=1)
Destroying test database for alias 'default'...

The test will be considered as pass, it it has success rate of 80%

Found 1 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
--------------------------------------------------------------------------------
[Retry] Retrying "test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism.test_retry_mechanism_pass", attempt 1/5. 
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
[Retry] Retrying "test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism.test_retry_mechanism_pass", attempt 2/5. 
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
[Retry] Retrying "test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism.test_retry_mechanism_pass", attempt 3/5. 
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
[Retry] Retrying "test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism.test_retry_mechanism_pass", attempt 4/5. 
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
[Retry] Retrying "test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism.test_retry_mechanism_pass", attempt 5/5. 
--------------------------------------------------------------------------------
.
Summary of slow tests (>0.3s)

(test_project.tests.test_selenium.TestSeleniumMixinRetryMechanism)
  (2.15s) test_retry_mechanism_pass

Total slow tests detected: 1

----------------------------------------------------------------------
Ran 1 test in 2.150s

OK
Destroying test database for alias 'default'...

@pandafy pandafy force-pushed the issues/464-retry-selenium branch from 5ff8818 to 89d1aef Compare May 22, 2025 14:59
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please double check the docs text.

methods that must be used across all OpenWISP modules based on Django to
enforce best practices and avoid flaky tests.

It also provides a retry mechanism for flaky tests, which executes the a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It also provides a retry mechanism for flaky tests, which executes the a
It also provides a retry mechanism for *"flaky tests"*, which repeats any

This functionality can be configured using the following class attributes:

- ``retry_max``: Number of times to retry a test (default: ``5``).
- ``retry_delay``: Numbed of seconds to wait before retrying a test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- ``retry_delay``: Numbed of seconds to wait before retrying a test
- ``retry_delay``: Number of seconds to wait before retrying a test


- ``retry_max``: Number of times to retry a test (default: ``5``).
- ``retry_delay``: Numbed of seconds to wait before retrying a test
(default: ``2``).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to wait to repeat tests? I'd set this to zero to avoid increasing build times.

Retry selenium tests if the tests fails on the first attempt.
This prevents failng the CI build from flaky tests.

Closes #464
@pandafy pandafy force-pushed the issues/464-retry-selenium branch from 89d1aef to 750df2f Compare May 23, 2025 10:45
@nemesifier nemesifier merged commit ad85b27 into master May 23, 2025
20 of 22 checks passed
@nemesifier nemesifier deleted the issues/464-retry-selenium branch May 23, 2025 17:19
@github-project-automation github-project-automation bot moved this from In progress to Done in OpenWISP Contributor's Board May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

[tests] Retry failing selenium tests

4 participants