1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-07 14:25:37 +00:00

Merge branch 'fix-flaky-job-tests' into 'develop'

Fix flaky job tests

See merge request 
This commit is contained in:
Bram Wiepjes 2025-02-14 12:36:20 +00:00
commit a68444b1fd
5 changed files with 27 additions and 16 deletions
backend
requirements
tests/baserow
enterprise/backend/tests/baserow_enterprise_tests/ws

View file

@ -40,6 +40,7 @@ mypy-extensions==1.0.0
isort==5.13.2
ipython
fakeredis[lua]==2.23.2
pytest-retry==1.7.0
ipdb
# build is used to compile a wheel package with `python -m build .` command.
build

View file

@ -224,6 +224,7 @@ pytest==8.2.0
# pytest-metadata
# pytest-mock
# pytest-ordering
# pytest-retry
# pytest-split
# pytest-unordered
# pytest-xdist
@ -245,13 +246,15 @@ pytest-mock==3.14.0
# via -r dev.in
pytest-ordering==0.6
# via -r dev.in
pytest-retry==1.7.0
# via -r dev.in
pytest-split==0.8.2
# via -r dev.in
pytest-unordered==0.6.0
# via -r dev.in
pytest-xdist==3.6.1
# via -r dev.in
python-dateutil==2.9.0.post0
python-dateutil==2.8.2
# via
# -c base.txt
# freezegun

View file

@ -272,6 +272,7 @@ def test_get_job(data_fixture, api_client):
@pytest.mark.django_db(transaction=True)
@pytest.mark.flaky(retries=3, delay=1)
def test_cancel_job_running(
data_fixture,
api_client,
@ -360,6 +361,7 @@ def test_cancel_job_running(
@pytest.mark.django_db(transaction=True)
@pytest.mark.flaky(retries=3, delay=1)
def test_cancel_job_pending(
data_fixture,
api_client,
@ -433,6 +435,7 @@ def test_cancel_job_pending(
@pytest.mark.django_db(transaction=True)
@pytest.mark.flaky(retries=3, delay=1)
def test_cancel_job_finished(
data_fixture,
api_client,
@ -493,9 +496,9 @@ def test_cancel_job_finished(
assert job.pending, job.get_cached_state()
t.start()
assert m_start.wait(0.1)
assert m_start.wait(0.5)
m_set_stop.set()
assert m_end.wait(0.1)
assert m_end.wait(0.5)
response = api_client.post(
reverse("api:jobs:cancel", args=(job.id,)),

View file

@ -121,6 +121,7 @@ def test_job_progress_changed_bug_regression(data_fixture, mutable_job_type_regi
@pytest.mark.django_db(transaction=True)
@pytest.mark.flaky(retries=3, delay=1)
def test_job_cancel_before_run(
data_fixture, test_thread, mutable_job_type_registry, enable_locmem_testing
):
@ -140,7 +141,7 @@ def test_job_cancel_before_run(
def run(self, job, progress):
m_start.set()
m_set_stop.wait(0.1)
m_set_stop.wait(0.5)
progress.set_progress(10)
m_end.set()
@ -172,7 +173,7 @@ def test_job_cancel_before_run(
@pytest.mark.django_db(transaction=True)
@pytest.mark.skip(reason="intermittently failing")
@pytest.mark.flaky(retries=3, delay=1)
def test_job_cancel_when_running(
data_fixture, test_thread, mutable_job_type_registry, enable_locmem_testing
):
@ -194,7 +195,7 @@ def test_job_cancel_when_running(
progress.set_progress(11)
m_start.set()
progress.set_progress(11)
assert m_set_stop.wait(0.1)
assert m_set_stop.wait(0.5)
progress.set_progress(12)
m_end.set()
@ -215,7 +216,7 @@ def test_job_cancel_when_running(
assert job.get_cached_progress_percentage() == 0
t.start()
assert m_start.wait(0.1)
assert m_start.wait(0.5)
assert job.started, job.get_cached_state()
assert (
job.get_cached_progress_percentage() == 11
@ -223,7 +224,7 @@ def test_job_cancel_when_running(
jh.cancel_job(job)
m_set_stop.set()
assert not m_end.wait(0.1)
assert not m_end.wait(0.5)
job.refresh_from_db()
# progress percentage is set from model's state, not from cache,
@ -233,7 +234,7 @@ def test_job_cancel_when_running(
@pytest.mark.django_db(transaction=True)
@pytest.mark.skip(reason="intermittently failing")
@pytest.mark.flaky(retries=3, delay=1)
def test_job_cancel_failed(
data_fixture, test_thread, mutable_job_type_registry, enable_locmem_testing
):
@ -265,7 +266,7 @@ def test_job_cancel_failed(
t.start()
assert t.is_alive()
assert m_start.wait(0.1)
assert m_start.wait(0.5)
# a job failed, so we can't cancel it
job.refresh_from_db()
@ -277,6 +278,7 @@ def test_job_cancel_failed(
@pytest.mark.django_db(transaction=True)
@pytest.mark.flaky(retries=3, delay=1)
def test_job_cancel_finished(
data_fixture, test_thread, mutable_job_type_registry, enable_locmem_testing
):
@ -291,7 +293,7 @@ def test_job_cancel_finished(
def run(self, job, progress):
m_start.set()
assert m_set_stop.wait(0.1)
assert m_set_stop.wait(0.5)
m_end.set()
jh = JobHandler()
@ -310,9 +312,9 @@ def test_job_cancel_finished(
t.start()
assert t.is_alive()
assert m_start.wait(0.1)
assert m_start.wait(0.5)
m_set_stop.set()
assert m_end.wait(0.1)
assert m_end.wait(0.5)
job.refresh_from_db()
with pytest.raises(JobNotCancellable):
@ -321,7 +323,7 @@ def test_job_cancel_finished(
@pytest.mark.django_db(transaction=True)
@pytest.mark.disabled_in_ci
@pytest.mark.flaky(retries=3, delay=1)
def test_job_cancel_cancelled(
data_fixture, test_thread, mutable_job_type_registry, enable_locmem_testing
):
@ -337,7 +339,7 @@ def test_job_cancel_cancelled(
def run(self, job, progress):
m_start.set()
progress.set_progress(10)
assert m_set_stop.wait(0.1)
assert m_set_stop.wait(0.5)
progress.set_progress(20)
m_end.set()
progress.set_progress(30)
@ -358,7 +360,7 @@ def test_job_cancel_cancelled(
t.start()
assert t.is_alive()
assert m_start.wait(0.1)
assert m_start.wait(0.5)
out = JobHandler.cancel_job(job)
assert isinstance(out, Job)
m_set_stop.set()

View file

@ -448,6 +448,7 @@ async def test_unsubscribe_subject_from_table_teams_multiple_users(
@pytest.mark.asyncio
@pytest.mark.django_db(transaction=True)
@pytest.mark.websockets
@pytest.mark.flaky(retries=3, delay=1)
async def test_unsubscribe_user_from_tables_and_rows_when_role_updated(data_fixture):
channel_layer = get_channel_layer()
user_1, token_1 = data_fixture.create_user_and_token()
@ -536,6 +537,7 @@ async def test_unsubscribe_user_from_tables_and_rows_when_role_updated(data_fixt
@pytest.mark.asyncio
@pytest.mark.django_db(transaction=True)
@pytest.mark.websockets
@pytest.mark.flaky(retries=3, delay=1)
async def test_unsubscribe_user_from_tables_and_rows_when_team_trashed(
data_fixture, enterprise_data_fixture
):