imranariffin / aiotaskq

A simple asynchronous task queue
MIT License
4 stars 1 forks source link

Fix flaky tests #66

Open imranariffin opened 6 months ago

imranariffin commented 6 months ago

At least this test (there's probably more) is a flaky. We need to ensure that it fails/succeeds consistently 99.99% of the time.

test_async_concurrency

One solution I can think of now is to just use a much bigger number of tasks and a bigger error margin. Even though the error margin is bigger, a much bigger of tasks would make up for it and make the error margin negligible.

-    results_actual = await asyncio.gather(*[simple_app.wait.apply_async(t_s=1) for _ in range(5)])
+    results_actual = await asyncio.gather(*[simple_app.wait.apply_async(t_s=1) for _ in range(20)])

-    error = 0.1
+    error = 0.5
    assert 1.0 < dt_actual < 1.0 + error
    # And the results should be correct
    results_expected = [1] * 20
    assert results_actual == results_expected