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

Add task duration intervals to the scheduler #2451

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
11a7504
Add task events
jpbruinsslot Dec 21, 2023
26bc615
Merge branch 'main' into feature/mula/task-events-alternative
jpbruinsslot Dec 28, 2023
76b3759
Implement alternative task events
jpbruinsslot Dec 28, 2023
dffc491
Set index for task_id
jpbruinsslot Jan 2, 2024
740ad93
Merge branch 'main' into feature/mula/task-events-alternative
jpbruinsslot Jan 2, 2024
8d6718f
Implement alternative
jpbruinsslot Jan 31, 2024
3f25a24
Fix and update tests
jpbruinsslot Feb 5, 2024
f3b257c
Add tests
jpbruinsslot Feb 5, 2024
e9875f0
Pre commit
jpbruinsslot Feb 7, 2024
8a64695
Merge branch 'main' into feature/mula/task-events-alternative-2
jpbruinsslot Feb 7, 2024
7754dc8
Fix
jpbruinsslot Feb 7, 2024
1139f27
Merge branch 'main' into feature/mula/task-events-alternative-2
jpbruinsslot Feb 8, 2024
b559b2b
Merge branch 'main' into feature/mula/task-events-alternative-2
jpbruinsslot Feb 12, 2024
ccc315d
Merge branch 'main' into feature/mula/task-events-alternative-2
jpbruinsslot Feb 12, 2024
7c60699
Change datetime fields
jpbruinsslot Mar 4, 2024
33bf243
Merge branch 'main' into feature/mula/task-events-alternative-2
jpbruinsslot Mar 5, 2024
49abda1
Pre-commit
jpbruinsslot Mar 5, 2024
657e936
Feature/efficient reporting for all reports (#2586)
Donnype Mar 5, 2024
4b8df88
Filter out undeserializable objects from xtdb query in `construct_nei…
originalsouth Mar 5, 2024
fb71c62
TLS Report unit tests (#2593)
madelondohmen Mar 5, 2024
6015d7c
Translations update from Hosted Weblate (#2594)
weblate Mar 5, 2024
c5e79db
Fix missing finding_type table (#2596)
madelondohmen Mar 5, 2024
33f8aab
add extra checks for findings to dns report (#2506)
underdarknl Mar 5, 2024
c8590ab
fix deprecated warning due to old env in .env-defaults (#2597)
underdarknl Mar 5, 2024
5cd2e5d
Merge branch 'main' into feature/mula/task-events-alternative-2
jpbruinsslot Mar 5, 2024
03ec671
Fix tests
jpbruinsslot Mar 6, 2024
5abb1ae
Fix tests
jpbruinsslot Mar 6, 2024
39c0704
Fix tests
jpbruinsslot Mar 6, 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
14 changes: 13 additions & 1 deletion boefjes/.ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,19 @@ services:
env_file:
- .ci/.env.test
volumes:
- .:/app/boefjes
- .:/app/boefjes

boefjes:
build:
context: ..
dockerfile: boefjes/Dockerfile
args:
- ENVIRONMENT=dev
command: sh -c 'python -m pytest -v tests'
env_file:
- .ci/.env.test
volumes:
- .:/app/boefjes

ci_katalogus-db:
image: postgres:15
Expand Down
7 changes: 7 additions & 0 deletions boefjes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ ci-docker-compose := docker compose -f base.yml -f .ci/docker-compose.yml

test: itest ## Run all tests.

utest: ## Run the unit tests.
Donnype marked this conversation as resolved.
Show resolved Hide resolved
$(ci-docker-compose) build
$(ci-docker-compose) down --remove-orphans
$(ci-docker-compose) run --rm boefjes
$(ci-docker-compose) down


itest: ## Run the integration tests.
$(ci-docker-compose) build
$(ci-docker-compose) down --remove-orphans
Expand Down
2 changes: 2 additions & 0 deletions boefjes/boefjes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ def _start_working(

while True:
p_item = task_queue.get()
scheduler_client.patch_task(p_item.id, TaskStatus.RUNNING) # Note: implicitly, we have p_item.id == task_id
Donnype marked this conversation as resolved.
Show resolved Hide resolved

status = TaskStatus.FAILED
handling_tasks[os.getpid()] = str(p_item.id)

Expand Down
25 changes: 16 additions & 9 deletions boefjes/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ def test_one_process(manager: SchedulerWorkerManager, item_handler: MockHandler)

patched_tasks = manager.scheduler_client.get_all_patched_tasks()

assert len(patched_tasks) == 3
assert patched_tasks[0] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "completed")
assert len(patched_tasks) == 6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Donnype would you mind taking a look if I'm making the correct assumptions within these tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpbruinsslot These patches seem logical right? All of them go from running to either completed or failed 👍

assert patched_tasks[0] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "running")
assert patched_tasks[1] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "completed")
assert patched_tasks[2] == ("9071c9fd-2b9f-440f-a524-ef1ca4824fd4", "failed")
assert patched_tasks[2] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "running")
assert patched_tasks[3] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "completed")
assert patched_tasks[4] == ("9071c9fd-2b9f-440f-a524-ef1ca4824fd4", "running")
assert patched_tasks[5] == ("9071c9fd-2b9f-440f-a524-ef1ca4824fd4", "failed")


def test_two_processes(manager: SchedulerWorkerManager, item_handler: MockHandler) -> None:
Expand All @@ -39,7 +42,7 @@ def test_two_processes(manager: SchedulerWorkerManager, item_handler: MockHandle
assert len(items) == 2

patched_tasks = manager.scheduler_client.get_all_patched_tasks()
assert len(patched_tasks) == 3
assert len(patched_tasks) == 6
assert patched_tasks.count(("70da7d4f-f41f-4940-901b-d98a92e9014b", "completed")) == 2
assert patched_tasks.count(("9071c9fd-2b9f-440f-a524-ef1ca4824fd4", "failed")) == 1

Expand Down Expand Up @@ -78,7 +81,7 @@ def test_two_processes_handler_exception(manager: SchedulerWorkerManager, item_h

patched_tasks = manager.scheduler_client.get_all_patched_tasks()

assert len(patched_tasks) == 3
assert len(patched_tasks) == 6
# Handler starts raising an Exception from the second call onward,
# so we have 2 completed tasks and 4 failed tasks.
assert patched_tasks.count(("70da7d4f-f41f-4940-901b-d98a92e9014b", "completed")) == 1
Expand Down Expand Up @@ -112,7 +115,7 @@ def test_two_processes_cleanup_unfinished_tasks(
assert len(items) == 0

patched_tasks = manager.scheduler_client.get_all_patched_tasks()
assert len(patched_tasks) == 1
assert len(patched_tasks) == 3

# Task was running but main process crashed intentionally and cleaned it up
assert patched_tasks.count(("70da7d4f-f41f-4940-901b-d98a92e9014b", "failed")) == 1
Expand Down Expand Up @@ -149,9 +152,13 @@ def test_null(manager: SchedulerWorkerManager, tmp_path: Path, item_handler: Moc
patched_tasks = manager.scheduler_client.get_all_patched_tasks()

assert len(items) == 3
assert len(patched_tasks) == 3
assert patched_tasks[0] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "completed")
assert patched_tasks[2] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "completed")
assert len(patched_tasks) == 6
assert patched_tasks[0] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "running")
assert patched_tasks[1] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "completed")
assert patched_tasks[2] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "running")
assert patched_tasks[3] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "completed")
assert patched_tasks[4] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "running")
assert patched_tasks[5] == ("70da7d4f-f41f-4940-901b-d98a92e9014b", "completed")


def test_create_manager():
Expand Down
1 change: 1 addition & 0 deletions mula/.ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:

ci_postgres:
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