Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible scheduling #2786

Merged
merged 201 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
201 commits
Select commit Hold shift + click to select a range
a52d173
Update flexible scheduling to new main
jpbruinsslot Jan 2, 2024
3447649
Continue refactor
jpbruinsslot Jan 3, 2024
99aeeba
Make test work
jpbruinsslot Jan 4, 2024
0a96e21
Continue adding tests
jpbruinsslot Jan 8, 2024
3ead50e
Add job_store tests
jpbruinsslot Jan 9, 2024
e762a79
Add boefje test for 'no ooi' boefjes
jpbruinsslot Jan 9, 2024
e6f4773
Add more job storage tests, and fix big
jpbruinsslot Jan 9, 2024
d111b51
Remove re-enable of job when task pushed
jpbruinsslot Jan 10, 2024
3a9a95d
Remove test-case
jpbruinsslot Jan 10, 2024
9535b70
Start with api endpoints for jobs
jpbruinsslot Jan 10, 2024
21e8f33
Implement api endpoints, tests, and ranker
jpbruinsslot Jan 11, 2024
5123f33
Basic deadline calculation
jpbruinsslot Jan 15, 2024
fa15756
Update
jpbruinsslot Jan 15, 2024
45fb545
Implement cron like functionality
jpbruinsslot Jan 16, 2024
291a73d
Add ValidationError
jpbruinsslot Jan 17, 2024
ed2fd7f
Remove rate limit mentions in favour of feature branch
jpbruinsslot Jan 18, 2024
8e78f9c
Merge branch 'main' into feature/mula/flexible-scheduling
jpbruinsslot Jan 18, 2024
4d020a7
Trying pre-commit
jpbruinsslot Jan 18, 2024
0f193fb
Update documentation
jpbruinsslot Jan 22, 2024
9b34f56
Update docs with schematic
jpbruinsslot Jan 23, 2024
776242d
Update schematic
jpbruinsslot Jan 24, 2024
dcecb2f
Update architecture documentation
jpbruinsslot Jan 24, 2024
cc85e65
Add diagrams
jpbruinsslot Jan 25, 2024
01e01c5
Update documentation
jpbruinsslot Jan 25, 2024
44e415f
Update docs and restructure some code
jpbruinsslot Jan 29, 2024
8968abe
Fix diagram010.svg
jpbruinsslot Jan 29, 2024
86db29b
Fix
jpbruinsslot Jan 29, 2024
04995f7
Merge branch 'main' into chore/mula/update-architecture-doc
jpbruinsslot Jan 29, 2024
e76dc69
Merge branch 'main' into feature/mula/flexible-scheduling
jpbruinsslot Jan 29, 2024
2a7693b
Merge branch 'chore/mula/update-architecture-doc' into feature/mula/f…
jpbruinsslot Jan 29, 2024
a9cd630
Update docs
jpbruinsslot Jan 29, 2024
4416704
Update documentation
jpbruinsslot Jan 30, 2024
e12c0ee
Refactor naming
jpbruinsslot Jan 30, 2024
97b0350
Update docs
jpbruinsslot Jan 31, 2024
85777ea
Merge branch 'main' into feature/mula/flexible-scheduling
jpbruinsslot Mar 5, 2024
245ca61
First round of git pre-commit
jpbruinsslot Mar 5, 2024
2838b45
Fix mypy suggestions
jpbruinsslot Mar 6, 2024
5b2bda7
Restructure of models
jpbruinsslot Mar 7, 2024
1175452
Continue implementing data deduplication fixes
jpbruinsslot Mar 12, 2024
c29a747
Refactoring
jpbruinsslot Mar 13, 2024
47466a0
Fixing sqlalchemy nested, removing TaskSchedule
jpbruinsslot Mar 14, 2024
a82c344
Continue refactoring
jpbruinsslot Mar 18, 2024
4cfbbcb
Refactor filtering
jpbruinsslot Mar 20, 2024
5f9b2bf
Continue with nested queries
jpbruinsslot Mar 21, 2024
a58a69f
Fix filtering with relationship
jpbruinsslot Mar 25, 2024
be79fc6
Fix tests for updated filters
jpbruinsslot Mar 26, 2024
b54bdf8
Testing out queue refactor
jpbruinsslot Mar 27, 2024
4e98e6c
Alternative keeping PrioritizedItem present
jpbruinsslot Apr 1, 2024
e25d1f7
Make priority queue test work
jpbruinsslot Apr 2, 2024
fd29038
Update scheduler.py
jpbruinsslot Apr 2, 2024
ff94126
Update scheduler.py testing
jpbruinsslot Apr 2, 2024
57f30f1
Going through test_scheduler.py
jpbruinsslot Apr 3, 2024
0fa1a55
Clean ups
jpbruinsslot Apr 3, 2024
2fa57b6
Fix naming
jpbruinsslot Apr 3, 2024
652fc2c
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Apr 4, 2024
42dac16
Fix packages
jpbruinsslot Apr 4, 2024
505c38f
Clean up
jpbruinsslot Apr 4, 2024
bb72127
Clean up
jpbruinsslot Apr 4, 2024
171f797
Reset
jpbruinsslot Apr 4, 2024
1b03896
Reset
jpbruinsslot Apr 4, 2024
e788158
Clean up
jpbruinsslot Apr 4, 2024
12e1758
Reset
jpbruinsslot Apr 4, 2024
fc7ccf3
Fix status
jpbruinsslot Apr 4, 2024
fb08bb1
Starting with fixing tests
jpbruinsslot Apr 4, 2024
c5f9f7d
Fix tests
jpbruinsslot Apr 8, 2024
c96de0f
Fix pq
jpbruinsslot Apr 8, 2024
58a0224
Continue with fixing tests
jpbruinsslot Apr 15, 2024
c5d7aae
Continue updating tests
jpbruinsslot Apr 16, 2024
45019f3
Continue with fixing tests
jpbruinsslot Apr 17, 2024
1f46615
Update tests
jpbruinsslot Apr 18, 2024
5275ec4
Fixing tests
jpbruinsslot Apr 22, 2024
88208b4
Fix stalled tests
jpbruinsslot Apr 30, 2024
b729d7c
Remove PrioritizedItem
jpbruinsslot May 1, 2024
3942029
Updating tests
jpbruinsslot May 2, 2024
473199e
Restructure deadline calculation
jpbruinsslot May 20, 2024
8f31c61
Start fixing normalizer scheduler
jpbruinsslot May 20, 2024
cc53a39
Restructure
jpbruinsslot May 27, 2024
a0f4be6
Remove obsolete code
jpbruinsslot May 28, 2024
8c5d7bf
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Jun 11, 2024
c90e216
Some more merge conflict fixes
jpbruinsslot Jun 11, 2024
592270f
Update
jpbruinsslot Jun 24, 2024
5aefdb9
Refactor push task
jpbruinsslot Jun 25, 2024
8d29a3e
Refactor
jpbruinsslot Jun 26, 2024
51f40fd
Start with normalizer refactor
jpbruinsslot Jun 26, 2024
4c46160
Todo
jpbruinsslot Jun 27, 2024
ee9a234
Refactor push task normalizer
jpbruinsslot Jun 27, 2024
25bfe06
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Jun 27, 2024
064d930
Fix conflict
jpbruinsslot Jun 27, 2024
0c27657
Fix server api tests
jpbruinsslot Jul 1, 2024
35c57bb
Refactor server
jpbruinsslot Jul 1, 2024
44c9b8e
Add api endpoints for schedules
jpbruinsslot Jul 2, 2024
5459ccd
Rename method normalizer scheduler
jpbruinsslot Jul 3, 2024
126ab04
Changes
jpbruinsslot Jul 3, 2024
76ad63e
Trying to fix bug
jpbruinsslot Jul 4, 2024
3cb590f
Update normalizer
jpbruinsslot Jul 8, 2024
8e9b401
Fix validation and setting of schedule
jpbruinsslot Jul 8, 2024
3c1c9d3
Bug finally fixed
jpbruinsslot Jul 9, 2024
4820d1b
Continue fixing bugs
jpbruinsslot Jul 10, 2024
c48d93f
Fix retrieving schedules from database
jpbruinsslot Jul 11, 2024
d673789
Make tests work
jpbruinsslot Jul 11, 2024
f2f7ca9
Fixing bugs, updating tests
jpbruinsslot Jul 11, 2024
e9ce420
Fix tests
jpbruinsslot Jul 15, 2024
ec03654
Fixing tests
jpbruinsslot Jul 15, 2024
448b580
For now skip test
jpbruinsslot Jul 16, 2024
78e0101
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Jul 16, 2024
6f6836d
Integration scheduler changes with other services
jpbruinsslot Jul 17, 2024
8f18cd6
Fix normalizer bug
jpbruinsslot Jul 18, 2024
8e358a8
Update and fix scripts
jpbruinsslot Jul 18, 2024
09d8861
Add tests
jpbruinsslot Jul 18, 2024
8e67fe3
Fixes
jpbruinsslot Jul 22, 2024
afe8acb
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Jul 23, 2024
64487b4
Add some tests
jpbruinsslot Jul 23, 2024
7a2a938
Update migration
jpbruinsslot Jul 23, 2024
b576a2d
Update migrations
jpbruinsslot Jul 23, 2024
e68a7e7
Update migrations
jpbruinsslot Jul 23, 2024
64e6820
Fix new boefjes
jpbruinsslot Jul 23, 2024
4405160
Add tests
jpbruinsslot Jul 24, 2024
7fb719e
Remove breakpoint
jpbruinsslot Jul 24, 2024
5b360a5
Precommit
jpbruinsslot Jul 24, 2024
260a2f3
Restructure scripts
jpbruinsslot Jul 24, 2024
cd64da4
Restructure storage
jpbruinsslot Jul 24, 2024
395ae2f
Restructure server
jpbruinsslot Jul 24, 2024
81b1a34
Fix new boefjes issue
jpbruinsslot Jul 24, 2024
83ef876
Add thread safety tests
jpbruinsslot Jul 24, 2024
ba3a81d
Add additional thread safety test for the other caches
jpbruinsslot Jul 25, 2024
7e4ce13
Add more tests
jpbruinsslot Jul 25, 2024
d90d6d5
Merge branch 'fix/mula/new_boefjes' into feature/mula/refactor-queue
jpbruinsslot Jul 25, 2024
e6c800c
Merge branch 'main' into fix/mula/new_boefjes
underdarknl Jul 25, 2024
88e7bb7
Exclude folder from pre-commit
jpbruinsslot Jul 29, 2024
1d83f0f
Update .pre-commit-config.yaml
jpbruinsslot Jul 29, 2024
8dc860c
Update pyproject.toml
jpbruinsslot Jul 29, 2024
95ed5ed
Update .pre-commit-config.yaml
jpbruinsslot Jul 29, 2024
8c08c9a
Remove logging statements
jpbruinsslot Jul 29, 2024
1a19d77
Precommit
jpbruinsslot Jul 29, 2024
626301d
Merge branch 'main' into feature/mula/server-updates
jpbruinsslot Jul 29, 2024
b9553ad
Merge branch 'main' into feature/mula/storage-updates
jpbruinsslot Jul 29, 2024
35fc046
Fix mypy suggestions
jpbruinsslot Jul 29, 2024
51089dd
Update tests
jpbruinsslot Jul 29, 2024
e5823be
Update
jpbruinsslot Jul 29, 2024
cea7f53
Fix tests
jpbruinsslot Jul 29, 2024
b63faa0
Pre-commit
jpbruinsslot Jul 29, 2024
ff49bc5
Merge branch 'feature/mula/storage-updates' into feature/mula/refacto…
jpbruinsslot Jul 29, 2024
79c860e
Merge branch 'feature/mula/scripts' into feature/mula/refactor-queue
jpbruinsslot Jul 29, 2024
66c2a16
Pre-commit
jpbruinsslot Jul 29, 2024
c446e13
Merge branch 'feature/mula/server-updates' into feature/mula/refactor…
jpbruinsslot Jul 29, 2024
e30ba73
Pre-commit
jpbruinsslot Jul 29, 2024
0b45e49
Merge branch 'feature/mula/scripts' into feature/mula/refactor-queue
jpbruinsslot Jul 29, 2024
408227d
Pre-commit
jpbruinsslot Jul 29, 2024
55e4673
Update mula/scheduler/connectors/services/katalogus.py
jpbruinsslot Jul 30, 2024
f97b196
Updates according to code-review
jpbruinsslot Jul 30, 2024
019752b
Pre-commit
jpbruinsslot Jul 30, 2024
7cdb525
Update filters.py
jpbruinsslot Jul 30, 2024
093276c
Update logging
jpbruinsslot Jul 30, 2024
33bac6e
Update filters.py
jpbruinsslot Jul 30, 2024
4e1dc9e
Pre-commit
jpbruinsslot Jul 30, 2024
da875c5
Fix filters
jpbruinsslot Jul 30, 2024
df4855e
Trying to fix mypy errors
jpbruinsslot Jul 30, 2024
9185597
Merge branch 'main' into feature/mula/storage-updates
jpbruinsslot Jul 30, 2024
e97a460
Fix datastore connection
jpbruinsslot Jul 30, 2024
0633a06
Trying to fix boefje tests
jpbruinsslot Jul 30, 2024
9bfd16b
Fix boefje tests
jpbruinsslot Jul 30, 2024
5a60394
Merge branch 'main' into fix/mula/new_boefjes
ammar92 Jul 31, 2024
de2eef7
Remove unnecessary type hints
jpbruinsslot Jul 31, 2024
c560581
Fix rocky tests
jpbruinsslot Jul 31, 2024
494a558
Fix rocky tests
jpbruinsslot Jul 31, 2024
ad44c02
Fix rocky tests
jpbruinsslot Jul 31, 2024
aa5aa2d
Update filters.py
jpbruinsslot Jul 31, 2024
e9950a9
Pre-commit
jpbruinsslot Jul 31, 2024
bd1a99e
Fix mypy
jpbruinsslot Jul 31, 2024
86901ab
Trying to add stubs
jpbruinsslot Jul 31, 2024
1fbceb6
Update mula/scheduler/context/context.py
jpbruinsslot Jul 31, 2024
4fbbe42
Update mula/scheduler/context/context.py
jpbruinsslot Jul 31, 2024
875cf08
Updates according to code review
jpbruinsslot Jul 31, 2024
7a78358
Add code-review suggestions
jpbruinsslot Jul 31, 2024
48bd09d
Merge branch 'feature/mula/scripts' into feature/mula/refactor-queue
jpbruinsslot Jul 31, 2024
20654d5
Merge remote-tracking branch 'origin/fix/mula/new_boefjes' into featu…
jpbruinsslot Jul 31, 2024
b862117
Merge remote-tracking branch 'origin/feature/mula/server-updates' int…
jpbruinsslot Jul 31, 2024
9f64326
Merge remote-tracking branch 'origin/feature/mula/storage-updates' in…
jpbruinsslot Jul 31, 2024
14fbe54
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Jul 31, 2024
aebb870
Fix for boefje/normalizer runner
jpbruinsslot Aug 1, 2024
f6be13a
Pre-commit
jpbruinsslot Aug 1, 2024
2516b1b
Fix requirements
jpbruinsslot Aug 1, 2024
abf5bf1
Update croniter
jpbruinsslot Aug 1, 2024
f777ef3
Update from croniter types
jpbruinsslot Aug 1, 2024
dc7f1f4
Ignore type
jpbruinsslot Aug 1, 2024
6ed961f
Ignore security-sensitive check of random
jpbruinsslot Aug 1, 2024
beeab12
Fix shadowing of python builtin
jpbruinsslot Aug 1, 2024
c849d0a
Pre-commit
jpbruinsslot Aug 1, 2024
00c126d
Fix linting
jpbruinsslot Aug 1, 2024
7926f53
Fix manual rescheduling
jpbruinsslot Aug 5, 2024
4b46b0c
Fix schedule_id when manual rescheduling
jpbruinsslot Aug 5, 2024
6ee70e9
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Aug 6, 2024
69e6faf
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Aug 6, 2024
0e4b2fa
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Aug 6, 2024
7371c55
Fix formatting
jpbruinsslot Aug 7, 2024
e4daab6
Formatting
jpbruinsslot Aug 7, 2024
bfda8fb
Formatting
jpbruinsslot Aug 7, 2024
299fc22
Updates according to code review
jpbruinsslot Aug 8, 2024
efb871a
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Aug 8, 2024
50c39a2
Fix poetry
jpbruinsslot Aug 8, 2024
ee4c395
Merge branch 'main' into feature/mula/refactor-queue
jpbruinsslot Aug 13, 2024
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
10 changes: 5 additions & 5 deletions boefjes/boefjes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async def boefje_output(
bytes_client.save_boefje_meta(boefje_meta)

if boefje_output.files:
mime_types = _default_mime_types(task.p_item.data.boefje)
mime_types = _default_mime_types(task.data.boefje)
for file in boefje_output.files:
raw = base64.b64decode(file.content)
# when supported, also save file.name to Bytes
Expand All @@ -149,13 +149,13 @@ def get_task(task_id, scheduler_client):


def create_boefje_meta(task, local_repository):
boefje = task.p_item.data.boefje
boefje = task.data.boefje
boefje_resource = local_repository.by_id(boefje.id)
env_keys = boefje_resource.environment_keys
environment = get_environment_settings(task.p_item.data, env_keys) if env_keys else {}
environment = get_environment_settings(task.data, env_keys) if env_keys else {}

organization = task.p_item.data.organization
input_ooi = task.p_item.data.input_ooi
organization = task.data.organization
input_ooi = task.data.input_ooi
arguments = {"oci_arguments": boefje_resource.oci_arguments}

if input_ooi:
Expand Down
9 changes: 2 additions & 7 deletions boefjes/boefjes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
from httpx import HTTPError
from pydantic import ValidationError

from boefjes.clients.scheduler_client import (
QueuePrioritizedItem,
SchedulerAPIClient,
SchedulerClientInterface,
TaskStatus,
)
from boefjes.clients.scheduler_client import SchedulerAPIClient, SchedulerClientInterface, Task, TaskStatus
from boefjes.config import Settings
from boefjes.job_handler import BoefjeHandler, NormalizerHandler, bytes_api_client
from boefjes.local import LocalBoefjeJobRunner, LocalNormalizerJobRunner
Expand Down Expand Up @@ -192,7 +187,7 @@ def exit(self, queue_type: WorkerManager.Queue, signum: int | None = None):
logger.info("Received %s, exiting", signal.Signals(signum).name)

if not self.task_queue.empty():
items: list[QueuePrioritizedItem] = [self.task_queue.get() for _ in range(self.task_queue.qsize())]
items: list[Task] = [self.task_queue.get() for _ in range(self.task_queue.qsize())]

for p_item in items:
try:
Expand Down
30 changes: 11 additions & 19 deletions boefjes/boefjes/clients/scheduler_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ class Queue(BaseModel):
size: int


class QueuePrioritizedItem(BaseModel):
"""Representation of a queue.PrioritizedItem on the priority queue. Used
for unmarshalling of priority queue prioritized items to a JSON
representation.
"""

id: uuid.UUID
priority: int
hash: str | None = None
data: BoefjeMeta | NormalizerMeta


class TaskStatus(Enum):
"""Status of a task."""

Expand All @@ -34,14 +22,18 @@ class TaskStatus(Enum):
RUNNING = "running"
COMPLETED = "completed"
FAILED = "failed"
CANCELLED = "cancelled"


class Task(BaseModel):
id: uuid.UUID
scheduler_id: str
type: str
p_item: QueuePrioritizedItem
schedule_id: str | None
priority: int
status: TaskStatus
type: str
hash: str | None = None
data: BoefjeMeta | NormalizerMeta
created_at: datetime.datetime
modified_at: datetime.datetime

Expand All @@ -50,7 +42,7 @@ class SchedulerClientInterface:
def get_queues(self) -> list[Queue]:
raise NotImplementedError()

def pop_item(self, queue: str) -> QueuePrioritizedItem | None:
def pop_item(self, queue: str) -> Task | None:
raise NotImplementedError()

def patch_task(self, task_id: uuid.UUID, status: TaskStatus) -> None:
Expand All @@ -59,7 +51,7 @@ def patch_task(self, task_id: uuid.UUID, status: TaskStatus) -> None:
def get_task(self, task_id: uuid.UUID) -> Task:
raise NotImplementedError()

def push_item(self, queue_id: str, p_item: QueuePrioritizedItem) -> None:
def push_item(self, queue_id: str, p_item: Task) -> None:
raise NotImplementedError()


Expand All @@ -77,13 +69,13 @@ def get_queues(self) -> list[Queue]:

return TypeAdapter(list[Queue]).validate_json(response.content)

def pop_item(self, queue: str) -> QueuePrioritizedItem | None:
def pop_item(self, queue: str) -> Task | None:
response = self._session.post(f"/queues/{queue}/pop")
self._verify_response(response)

return TypeAdapter(QueuePrioritizedItem | None).validate_json(response.content)
return TypeAdapter(Task | None).validate_json(response.content)

def push_item(self, queue_id: str, p_item: QueuePrioritizedItem) -> None:
def push_item(self, queue_id: str, p_item: Task) -> None:
response = self._session.post(f"/queues/{queue_id}/push", content=p_item.json())
self._verify_response(response)

Expand Down
34 changes: 14 additions & 20 deletions boefjes/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from boefjes.app import SchedulerWorkerManager
from boefjes.clients.bytes_client import BytesAPIClient
from boefjes.clients.scheduler_client import Queue, QueuePrioritizedItem, SchedulerClientInterface, Task, TaskStatus
from boefjes.clients.scheduler_client import Queue, SchedulerClientInterface, Task, TaskStatus
from boefjes.config import Settings, settings
from boefjes.job_handler import bytes_api_client
from boefjes.job_models import BoefjeMeta, NormalizerMeta
Expand Down Expand Up @@ -52,25 +52,25 @@ def __init__(

self._iterations = 0
self._tasks: dict[str, Task] = multiprocessing.Manager().dict()
self._popped_items: dict[str, QueuePrioritizedItem] = multiprocessing.Manager().dict()
self._pushed_items: dict[str, tuple[str, QueuePrioritizedItem]] = multiprocessing.Manager().dict()
self._popped_items: dict[str, Task] = multiprocessing.Manager().dict()
self._pushed_items: dict[str, tuple[str, Task]] = multiprocessing.Manager().dict()

def get_queues(self) -> list[Queue]:
time.sleep(self.sleep_time)
return TypeAdapter(list[Queue]).validate_json(self.queue_response)

def pop_item(self, queue: str) -> QueuePrioritizedItem | None:
def pop_item(self, queue: str) -> Task | None:
time.sleep(self.sleep_time)

try:
if WorkerManager.Queue.BOEFJES.value in queue:
p_item = TypeAdapter(QueuePrioritizedItem).validate_json(self.boefje_responses.pop(0))
p_item = TypeAdapter(Task).validate_json(self.boefje_responses.pop(0))
self._popped_items[str(p_item.id)] = p_item
self._tasks[str(p_item.id)] = self._task_from_id(p_item.id)
return p_item

if WorkerManager.Queue.NORMALIZERS.value in queue:
p_item = TypeAdapter(QueuePrioritizedItem).validate_json(self.normalizer_responses.pop(0))
p_item = TypeAdapter(Task).validate_json(self.normalizer_responses.pop(0))
self._popped_items[str(p_item.id)] = p_item
return p_item
except IndexError:
Expand All @@ -92,17 +92,9 @@ def get_task(self, task_id: UUID) -> Task:
return self._task_from_id(task_id) if str(task_id) not in self._tasks else self._tasks[str(task_id)]

def _task_from_id(self, task_id: UUID):
return Task(
id=task_id,
scheduler_id="test",
type="test",
p_item=self._popped_items[str(task_id)],
status=TaskStatus.DISPATCHED,
created_at=datetime.now(timezone.utc),
modified_at=datetime.now(timezone.utc),
)
return self._popped_items[str(task_id)]

def push_item(self, queue_id: str, p_item: QueuePrioritizedItem) -> None:
def push_item(self, queue_id: str, p_item: Task) -> None:
self._pushed_items[str(p_item.id)] = (queue_id, p_item)


Expand Down Expand Up @@ -131,10 +123,12 @@ def item_handler(tmp_path: Path):
@pytest.fixture
def manager(item_handler: MockHandler, tmp_path: Path) -> SchedulerWorkerManager:
scheduler_client = MockSchedulerClient(
get_dummy_data("scheduler/queues_response.json"),
2 * [get_dummy_data("scheduler/pop_response_boefje.json")] + [get_dummy_data("scheduler/should_crash.json")],
[get_dummy_data("scheduler/pop_response_normalizer.json")],
tmp_path / "patch_task_log",
queue_response=get_dummy_data("scheduler/queues_response.json"),
boefje_responses=(
2 * [get_dummy_data("scheduler/pop_response_boefje.json")] + [get_dummy_data("scheduler/should_crash.json")]
),
normalizer_responses=[get_dummy_data("scheduler/pop_response_normalizer.json")],
log_path=tmp_path / "patch_task_log",
)

return SchedulerWorkerManager(item_handler, scheduler_client, Settings(pool_size=1, poll_interval=0.01), "DEBUG")
Expand Down
8 changes: 7 additions & 1 deletion boefjes/tests/examples/scheduler/pop_response_boefje.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"id": "70da7d4f-f41f-4940-901b-d98a92e9014b",
"priority": 1,
"scheduler_id": "boefje-_dev",
"schedule_id": null,
"status": "dispatched",
"type": "boefje",
"hash": "70da7d4f-f41f-4940-901b-d98a92e9014b",
"data": {
"id": "70da7d4f-f41f-4940-901b-d98a92e9014b",
Expand All @@ -15,5 +19,7 @@
"runnable_hash": null,
"environment": null,
"ended_at": null
}
},
"created_at": "2021-06-29T14:00:00",
"modified_at": "2021-06-29T14:00:00"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"id": "70da7d4f-f41f-4940-901b-d98a92e9014b",
"priority": 1,
"scheduler_id": "boefje-_dev",
"schedule_id": null,
"status": "dispatched",
"type": "boefje",
"hash": "70da7d4f-f41f-4940-901b-d98a92e9014b",
"data": {
"id": "70da7d4f-f41f-4940-901b-d98a92e9014b",
Expand All @@ -15,5 +19,7 @@
"runnable_hash": null,
"environment": null,
"ended_at": null
}
},
"created_at": "2021-06-29T14:00:00",
"modified_at": "2021-06-29T14:00:00"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"id": "60da7d4ff41f4940901bd98a92e9014b",
"priority": 1,
"scheduler_id": "normalizer-_dev",
"schedule_id": null,
"status": "dispatched",
"type": "normalizer",
"hash": "7e698c377cfd85015c0d7086b76b76b4",
"data": {
"id": "60da7d4ff41f4940901bd98a92e9014b",
Expand Down Expand Up @@ -48,5 +51,7 @@
"normalizer": {
"id": "kat_dns_normalize"
}
}
},
"created_at": "2021-06-29T14:00:00",
"modified_at": "2021-06-29T14:00:00"
}
7 changes: 6 additions & 1 deletion boefjes/tests/examples/scheduler/should_crash.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"id": "9071c9fd-2b9f-440f-a524-ef1ca4824fd4",
"priority": 1,
"scheduler_id": "boefje-_dev",
"schedule_id": null,
"status": "dispatched",
"type": "boefje",
"hash": "7e698c377cfd85015c0d7086b76b76b4",
"data": {
"id": "9071c9fd-2b9f-440f-a524-ef1ca4824fd4",
Expand Down Expand Up @@ -34,5 +37,7 @@
"input_ooi": "Hostname|internet|test.test",
"organization": "_dev",
"dispatches": []
}
},
"created_at": "2021-06-29T14:00:00",
"modified_at": "2021-06-29T14:00:00"
}
8 changes: 4 additions & 4 deletions boefjes/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

def _mocked_scheduler_client(tmp_path: Path):
return MockSchedulerClient(
get_dummy_data("scheduler/queues_response.json"),
[get_dummy_data("scheduler/pop_response_boefje_no_ooi.json")],
[],
tmp_path / "patch_task_log",
queue_response=get_dummy_data("scheduler/queues_response.json"),
boefje_responses=[get_dummy_data("scheduler/pop_response_boefje_no_ooi.json")],
normalizer_responses=[],
log_path=tmp_path / "patch_task_log",
)


Expand Down
4 changes: 3 additions & 1 deletion mula/.ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ services:
- ci_rabbitmq

ci_postgres:
image: docker.io/library/postgres:15
image: postgres:15
command:
["postgres", "-c", "log_statement=all", "-c", "log_destination=stderr"]
healthcheck:
test: ["CMD", "gosu", "postgres", "pg_isready"]
interval: 3s
Expand Down
Loading