Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/settings/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
LOGGING,
)

import django_rq.queues
import django_rq.connection_utils

from fakeredis import FakeRedis, FakeStrictRedis

Expand Down Expand Up @@ -86,7 +86,7 @@ def __call__(self, _, strict):
RQ_QUEUES["testing"] = _RQ_DATABASE # noqa: F405
RQ["WORKER_CLASS"] = "grimoirelab.core.scheduler.worker.GrimoireLabSimpleWorker"

django_rq.queues.get_redis_connection = FakeRedisConn()
django_rq.connection_utils.get_redis_connection = FakeRedisConn()

# Ignore warnings raised by the tests

Expand Down
1,970 changes: 1,059 additions & 911 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions releases/unreleased/bug-fix-in-job-retrieval-method.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Bug fix in job retrieval method
category: fixed
author: Jose Javier Merchante <jjmerchante@bitergia.com>
issue: null
notes: >
Fixed an issue with job ID retrieval to ensure compatibility
with the latest RQ version.
2 changes: 1 addition & 1 deletion src/grimoirelab/core/scheduler/tasks/chronicler.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def chronicler_job(
perceval_gen = perceval.backend.BackendItemsGenerator(
backend_class, backend_args, datasource_category
)
progress = ChroniclerProgress(rq_job.get_id(), datasource_type, datasource_category, None)
progress = ChroniclerProgress(rq_job.id, datasource_type, datasource_category, None)
rq_job.progress = progress

# The chronicler generator will eventize the data items
Expand Down
12 changes: 9 additions & 3 deletions src/grimoirelab/core/scheduler/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
logger = structlog.get_logger(__name__)


class GrimoireLabWorker(rq.worker.Worker):
"""Worker to run GrimoireLab jobs.
class GrimoireLabWorkerMixin:
"""Shared functionality for GrimoireLab workers.

This class includes some extra functionality to run GrimoireLab
jobs, like for example, update Job status on models.
Expand All @@ -60,7 +60,13 @@ def prepare_job_execution(
job_db.task.save()


class GrimoireLabSimpleWorker(GrimoireLabWorker, rq.worker.SimpleWorker):
class GrimoireLabWorker(GrimoireLabWorkerMixin, rq.worker.Worker):
"""Worker to run GrimoireLab jobs with process forking."""

pass


class GrimoireLabSimpleWorker(GrimoireLabWorkerMixin, rq.worker.SimpleWorker):
"""Worker to run GrimoireLab jobs in the same process, specially for testing"""

pass
4 changes: 2 additions & 2 deletions tests/unit/scheduler/test_task_eventizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_job(self):
result = job.return_value()

# Check job result
self.assertEqual(result.job_id, job.get_id())
self.assertEqual(result.job_id, job.id)
self.assertEqual(result.backend, "git")
self.assertEqual(result.category, "commit")
self.assertEqual(result.summary.last_uuid, "1375b60d3c23ac9b81da92523e4144abc4489d4c")
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_job_no_result(self):
result = job.return_value()

# Check job result
self.assertEqual(result.job_id, job.get_id())
self.assertEqual(result.job_id, job.id)
self.assertEqual(result.backend, "git")
self.assertEqual(result.category, "commit")
self.assertEqual(result.summary.last_uuid, None)
Expand Down
Loading