Skip to content

Commit

Permalink
test: fixup timeouts
Browse files Browse the repository at this point in the history
The tests were failing because they weren't able to complete in 20
seconds. Ugh!
  • Loading branch information
ankush committed Mar 15, 2024
1 parent 0ca0e22 commit 48c24c7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions frappe/core/doctype/rq_job/test_rq_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from frappe.utils.background_jobs import get_job_status, is_job_enqueued


@timeout(seconds=20)
@timeout(seconds=60)
def wait_for_completion(job: Job):
while True:
if not (job.is_queued or job.is_started):
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_delete_doc(self):
with self.assertRaises(rq_exc.NoSuchJobError):
job.refresh()

@timeout(20)
@timeout
def test_multi_queue_burst_consumption(self):
for _ in range(3):
for q in ["default", "short"]:
Expand All @@ -102,7 +102,7 @@ def test_multi_queue_burst_consumption(self):
_, stderr = execute_in_shell("bench worker --queue short,default --burst", check_exit_code=True)
self.assertIn("quitting", cstr(stderr))

@timeout(20)
@timeout
def test_multi_queue_burst_consumption_worker_pool(self):
for _ in range(3):
for q in ["default", "short"]:
Expand All @@ -113,15 +113,13 @@ def test_multi_queue_burst_consumption_worker_pool(self):
)
self.assertIn("quitting", cstr(stderr))

@timeout(20)
def test_job_id_manual_dedup(self):
job_id = "test_dedup"
job = frappe.enqueue(self.BG_JOB, sleep=5, job_id=job_id)
self.assertTrue(is_job_enqueued(job_id))
self.check_status(job, "finished")
self.assertFalse(is_job_enqueued(job_id))

@timeout(20)
def test_auto_job_dedup(self):
job_id = "test_dedup"
job1 = frappe.enqueue(self.BG_JOB, sleep=2, job_id=job_id, deduplicate=True)
Expand All @@ -135,7 +133,7 @@ def test_auto_job_dedup(self):
job4 = frappe.enqueue(self.BG_JOB, sleep=1, job_id=job_id, deduplicate=True)
self.check_status(job4, "finished")

@timeout(20)
@timeout
def test_enqueue_after_commit(self):
job_id = frappe.generate_hash()

Expand All @@ -155,7 +153,6 @@ def test_enqueue_after_commit(self):
frappe.db.commit()
self.assertIsNone(get_job_status(job_id))

@timeout(20)
def test_memory_usage(self):
if frappe.db.db_type != "mariadb":
return
Expand All @@ -171,7 +168,6 @@ def test_memory_usage(self):
LAST_MEASURED_USAGE = 41
self.assertLessEqual(rss, LAST_MEASURED_USAGE * 1.05, msg)

@timeout(20)
def test_clear_failed_jobs(self):
limit = 10
update_site_config("rq_failed_jobs_limit", limit)
Expand Down

0 comments on commit 48c24c7

Please sign in to comment.