-
Notifications
You must be signed in to change notification settings - Fork 0
chore: tests fix/update #60
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
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
83695a0
1. Scope mismatch bug — Session-scoped credentials + function-scoped…
HardMax71 a91ed81
asyncio.get_event_loop -> get_running_loop
HardMax71 f282fbf
tests update: DI system instead of global circus
HardMax71 5e9945d
DI change: using from_context instead of separate container
HardMax71 90cf785
passing test settings also to workers during test process
HardMax71 d2a542c
passing test settings also to workers during test process
HardMax71 7d7a5b3
passing test settings also to workers during test process
HardMax71 131c28d
passing test settings also to workers during test process
HardMax71 dbbfc8c
passing test settings also to workers during test process
HardMax71 6efa5ac
passing test settings also to workers during test process
HardMax71 60131c7
passing test settings also to workers during test process
HardMax71 2b70e63
passing test settings also to workers during test process
HardMax71 7dc5d00
sonarcube fixes, mypy, ruff
HardMax71 cc8d013
single owner pattern
HardMax71 bc81c92
failing stuff fixes
HardMax71 d1d7d99
failing stuff fixes
HardMax71 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,15 @@ jobs: | |
| docker compose -f docker-compose.ci.yaml up -d --wait --wait-timeout 120 | ||
| docker compose -f docker-compose.ci.yaml ps | ||
|
|
||
| - name: Create Kafka topics | ||
| timeout-minutes: 2 | ||
| env: | ||
| KAFKA_BOOTSTRAP_SERVERS: localhost:9092 | ||
| KAFKA_TOPIC_PREFIX: "ci.${{ github.run_id }}." | ||
| run: | | ||
| cd backend | ||
| uv run python -m scripts.create_topics | ||
|
|
||
| - name: Run integration tests | ||
| timeout-minutes: 10 | ||
| env: | ||
|
|
@@ -99,6 +108,7 @@ jobs: | |
| MONGODB_PORT: 27017 | ||
| MONGODB_URL: mongodb://root:[email protected]:27017/?authSource=admin | ||
| KAFKA_BOOTSTRAP_SERVERS: localhost:9092 | ||
| KAFKA_TOPIC_PREFIX: "ci.${{ github.run_id }}." | ||
| SCHEMA_REGISTRY_URL: http://localhost:8081 | ||
| REDIS_HOST: localhost | ||
| REDIS_PORT: 6379 | ||
|
|
@@ -174,13 +184,23 @@ jobs: | |
| timeout 90 bash -c 'until sudo k3s kubectl cluster-info; do sleep 5; done' | ||
| kubectl create namespace integr8scode --dry-run=client -o yaml | kubectl apply -f - | ||
|
|
||
| - name: Create Kafka topics | ||
| timeout-minutes: 2 | ||
| env: | ||
| KAFKA_BOOTSTRAP_SERVERS: localhost:9092 | ||
| KAFKA_TOPIC_PREFIX: "ci.${{ github.run_id }}." | ||
| run: | | ||
| cd backend | ||
| uv run python -m scripts.create_topics | ||
|
|
||
| - name: Run E2E tests | ||
| timeout-minutes: 10 | ||
| env: | ||
| MONGO_ROOT_USER: root | ||
| MONGO_ROOT_PASSWORD: rootpassword | ||
| MONGODB_URL: mongodb://root:[email protected]:27017/?authSource=admin | ||
| KAFKA_BOOTSTRAP_SERVERS: localhost:9092 | ||
| KAFKA_TOPIC_PREFIX: "ci.${{ github.run_id }}." | ||
| SCHEMA_REGISTRY_URL: http://localhost:8081 | ||
| REDIS_HOST: localhost | ||
| REDIS_PORT: 6379 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,62 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from types import TracebackType | ||
| from typing import Optional, Self, Type | ||
| from typing import Self | ||
|
|
||
|
|
||
| class LifecycleEnabled: | ||
| async def start(self) -> None: # pragma: no cover | ||
| raise NotImplementedError | ||
| """Base class for services with async lifecycle management. | ||
|
|
||
| async def stop(self) -> None: # pragma: no cover | ||
| raise NotImplementedError | ||
| Usage: | ||
| async with MyService() as service: | ||
| # service is running | ||
| # service is stopped | ||
|
|
||
| Subclasses override _on_start() and _on_stop() for their logic. | ||
| Base class handles idempotency and context manager protocol. | ||
|
|
||
| For internal component cleanup, use aclose() which follows Python's | ||
| standard async cleanup pattern (like aiofiles, aiohttp). | ||
| """ | ||
|
|
||
| def __init__(self) -> None: | ||
| self._lifecycle_started: bool = False | ||
|
|
||
| async def _on_start(self) -> None: | ||
| """Override with startup logic. Called once on enter.""" | ||
| pass | ||
|
|
||
| async def _on_stop(self) -> None: | ||
| """Override with cleanup logic. Called once on exit.""" | ||
| pass | ||
|
|
||
| async def aclose(self) -> None: | ||
| """Close the service. For internal component cleanup. | ||
|
|
||
| Mirrors Python's standard aclose() pattern (like aiofiles, aiohttp). | ||
| Idempotent - safe to call multiple times. | ||
| """ | ||
| if not self._lifecycle_started: | ||
| return | ||
| self._lifecycle_started = False | ||
| await self._on_stop() | ||
|
|
||
| @property | ||
| def is_running(self) -> bool: | ||
| """Check if service is currently running.""" | ||
| return self._lifecycle_started | ||
|
|
||
| async def __aenter__(self) -> Self: | ||
| await self.start() | ||
| if self._lifecycle_started: | ||
| return self # Already started, idempotent | ||
| await self._on_start() | ||
| self._lifecycle_started = True | ||
| return self | ||
|
|
||
| async def __aexit__( | ||
| self, | ||
| exc_type: Optional[Type[BaseException]], | ||
| exc: Optional[BaseException], | ||
| tb: Optional[TracebackType], | ||
| exc_type: type[BaseException] | None, | ||
| exc: BaseException | None, | ||
| tb: TracebackType | None, | ||
| ) -> None: | ||
| await self.stop() | ||
| await self.aclose() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.