learningequality / kolibri

Kolibri Learning Platform: the offline app for universal education
https://learningequality.org/kolibri/
MIT License
768 stars 647 forks source link

Flaky Python tests #8255

Open rtibbles opened 3 years ago

rtibbles commented 3 years ago

Observed behavior

This is a tracking issue to keep track of a few different Python tests that occasionally fail:

vkWeb commented 3 years ago

Will look into the first one!

rtibbles commented 3 years ago

Will look into the first one!

I suspect, but am not certain, that it is happening during the multiprocessing run of the tests.

vkWeb commented 3 years ago

I suspect, but am not certain, that it is happening during the multiprocessing run of the tests.

Will need to look into why that's the case.

marcellamaki commented 2 years ago

Closed in error -- only partially fixed

dbnicholson commented 1 year ago

I ran into the last one and it comes from a lack of consistent request mocking. That was exacerbated by 8e64e45b8769a6c7fb172a30f55192e3be2a7a37 since it now does a HEAD request before any GET requests. I've used requests-mock in another project and it makes it a lot harder to screw up since you'll immediately get errors for any URLs that haven't been registered for mocking.

rtibbles commented 4 months ago

More details for the MacOS worker test failure:

_____ TestWorker.test_high_tasks_dont_wait_when_regular_workers_busy[True] _____

self = <kolibri.core.tasks.test.taskrunner.test_worker.TestWorker object at 0x11d78cc70>
worker = <kolibri.core.tasks.worker.Worker object at 0x119d76560>

    def test_high_tasks_dont_wait_when_regular_workers_busy(self, worker):
        # We have one task running right now.
        worker.future_job_mapping = {"job_id": "future"}

        job = Job(id, args=(10,))
        worker.storage.enqueue_job(job, QUEUE, Priority.HIGH)

        job = worker.get_next_job()
        worker.future_job_mapping.clear()

        # Worker must get this job since its a 'high' priority job.
>       assert isinstance(job, Job) is True
E       assert False is True
E        +  where False = isinstance(None, Job)

kolibri/core/tasks/test/taskrunner/test_worker.py:202: AssertionError