Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit ff4b04f

Browse files
committed
Remove BackFillCommitData task/command
I believe this was a data migration that was completed a while back, so the code should now be cleaned up.
1 parent f8ac094 commit ff4b04f

File tree

4 files changed

+1
-194
lines changed

4 files changed

+1
-194
lines changed

core/management/commands/backfill_commits.py

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import unittest.mock as mock
22
from io import StringIO
33

4-
import fakeredis
54
import pytest
65
from django.core.management import call_command
76
from shared.config import ConfigHelper
8-
from shared.django_apps.core.tests.factories import (
9-
CommitFactory,
10-
OwnerFactory,
11-
RepositoryFactory,
12-
)
7+
from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory
138

149

1510
@pytest.mark.django_db
@@ -82,90 +77,3 @@ def test_update_gitlab_webhook_command(mocker):
8277
secret=repo3.webhook_secret,
8378
),
8479
]
85-
86-
87-
@pytest.mark.django_db
88-
def test_backfill_commits_command(mocker):
89-
storage_redis = fakeredis.FakeStrictRedis()
90-
celery_redis = fakeredis.FakeStrictRedis()
91-
mocker.patch(
92-
"core.management.commands.backfill_commits.get_storage_redis",
93-
return_value=storage_redis,
94-
)
95-
mocker.patch(
96-
"core.management.commands.backfill_commits.get_celery_redis",
97-
return_value=celery_redis,
98-
)
99-
100-
backfill_commits = mocker.patch("services.task.TaskService.backfill_commit_data")
101-
102-
get_config = mocker.patch("shared.config._get_config_instance")
103-
config_helper = ConfigHelper()
104-
config_helper.set_params(
105-
{
106-
"setup": {
107-
"webhook_url": "http://example.com",
108-
},
109-
}
110-
)
111-
get_config.return_value = config_helper
112-
113-
commit1 = CommitFactory()
114-
commit2 = CommitFactory()
115-
commit3 = CommitFactory()
116-
117-
# undrained queue
118-
119-
celery_redis.lpush("archive", "placeholder") # mimic > 0 items in the queue
120-
call_command(
121-
"backfill_commits",
122-
stdout=StringIO(),
123-
stderr=StringIO(),
124-
batch_size=2,
125-
)
126-
127-
# noop - waits for queue to drain
128-
assert backfill_commits.mock_calls == []
129-
celery_redis.delete("archive")
130-
131-
# 1st batch
132-
133-
call_command(
134-
"backfill_commits",
135-
stdout=StringIO(),
136-
stderr=StringIO(),
137-
batch_size=2,
138-
)
139-
140-
assert backfill_commits.mock_calls == [
141-
mock.call(commit_id=commit3.id),
142-
mock.call(commit_id=commit2.id),
143-
]
144-
145-
backfill_commits.reset_mock()
146-
147-
# 2nd batch
148-
149-
call_command(
150-
"backfill_commits",
151-
stdout=StringIO(),
152-
stderr=StringIO(),
153-
batch_size=2,
154-
)
155-
156-
assert backfill_commits.mock_calls == [
157-
mock.call(commit_id=commit1.id),
158-
]
159-
160-
backfill_commits.reset_mock()
161-
162-
# empty batch
163-
164-
call_command(
165-
"backfill_commits",
166-
stdout=StringIO(),
167-
stderr=StringIO(),
168-
batch_size=2,
169-
)
170-
171-
assert backfill_commits.mock_calls == []

services/task/task.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,6 @@ def manual_upload_completion_trigger(
380380
),
381381
).apply_async()
382382

383-
def backfill_commit_data(self, commit_id: int):
384-
self._create_signature(
385-
"app.tasks.archive.BackfillCommitDataToStorage",
386-
kwargs=dict(
387-
commitid=commit_id,
388-
),
389-
).apply_async()
390-
391383
def preprocess_upload(self, repoid, commitid, report_code):
392384
self._create_signature(
393385
"app.tasks.upload.PreProcessUpload",

services/tests/test_task.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -322,32 +322,3 @@ def test_make_http_request_task(mocker):
322322
headers=dict(created_timestamp="2023-06-13T10:01:01.000123"),
323323
immutable=False,
324324
)
325-
326-
327-
@freeze_time("2023-06-13T10:01:01.000123")
328-
def test_backfill_commit_data_task(mocker):
329-
signature_mock = mocker.patch("services.task.task.signature")
330-
mock_route_task = mocker.patch(
331-
"services.task.task.route_task",
332-
return_value={
333-
"queue": "celery",
334-
"extra_config": {"soft_timelimit": 300, "hard_timelimit": 400},
335-
},
336-
)
337-
TaskService().backfill_commit_data(123)
338-
mock_route_task.assert_called_with(
339-
"app.tasks.archive.BackfillCommitDataToStorage",
340-
args=None,
341-
kwargs=dict(commitid=123),
342-
)
343-
signature_mock.assert_called_with(
344-
"app.tasks.archive.BackfillCommitDataToStorage",
345-
args=None,
346-
kwargs=dict(commitid=123),
347-
app=celery_app,
348-
queue="celery",
349-
soft_time_limit=300,
350-
time_limit=400,
351-
headers=dict(created_timestamp="2023-06-13T10:01:01.000123"),
352-
immutable=False,
353-
)

0 commit comments

Comments
 (0)