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

CI fails due to timing issue occasionally #1106

Closed
BenediktBurger opened this issue May 10, 2024 · 5 comments · Fixed by #1110
Closed

CI fails due to timing issue occasionally #1106

BenediktBurger opened this issue May 10, 2024 · 5 comments · Fixed by #1110
Labels

Comments

@BenediktBurger
Copy link
Member

Quite often one test fails due to timing issues making the whole CI pipeline fail, probably the time limit should be reduced slightly:

    def test_check_query_delay():
        with expected_protocol(ATSBase, [("TTIM?", "7")]) as inst:
            start = perf_counter()
            assert inst.maximum_test_time == 7
            delay = perf_counter() - start
>           assert delay > 0.05
E           assert 0.0491846000000038 > 0.05

tests\instruments\temptronic\test_temptronic_base.py:36: AssertionError
@CasperSchippers
Copy link
Collaborator

CasperSchippers commented May 13, 2024

It sounds a bit like a floating-point errors: the start and delay might be too large (numericall) such that that difference cannot be calculated accurately. Not sure if this is indeed the case, but something to consider. If this is the case, it could be circumvented by using perf_counter_ns, which returnes the time as an int (in nanoseconds) in stead of float.

@BenediktBurger
Copy link
Member Author

Another solution could be pytest.approx, however, we should check first, what is actually tested, maybe the test is ok, but the code under test not.

@BenediktBurger
Copy link
Member Author

Having merged #1109, CI runs succeed. After the previous two merges, they always failed.

Seems to work, we should keep it open though for some more time.

@BenediktBurger
Copy link
Member Author

It did not work in CI run:

    def test_check_query_delay():
        with expected_protocol(ATSBase, [("TTIM?", "7")]) as inst:
            start = perf_counter_ns()
            assert inst.maximum_test_time == 7
            delay = perf_counter_ns() - start
>           assert delay > 0.05 * 1e9
E           assert 47828800 > (0.05 * 1000000000.0)

@BenediktBurger
Copy link
Member Author

Interestingly, it is always Python 3.8 or Python 3.9 on windows, which fails.

It's crazy, but it seems, that sleep sleeps only 95% of the specified time.

Last resort: using an error margin of 5%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants