-
Notifications
You must be signed in to change notification settings - Fork 43
Add integration test for upserting graph in StateManager #353
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
NiveditJain
merged 4 commits into
FailproofAI:main
from
NiveditJain:adding-actual-integration-tests
Sep 4, 2025
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
06efe24
Add integration test for upserting graph in StateManager
NiveditJain 14cceb0
Remove unused threading import from test_upsert_graph.py
NiveditJain f425aca
Refactor test_upsert_graph.py to use threading for runtime management
NiveditJain a6e9d30
Add integration test for fan-out functionality in StateManager
NiveditJain 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
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 |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import pytest | ||
| import asyncio | ||
| from pydantic import BaseModel | ||
| from exospherehost import BaseNode, Runtime, StateManager, GraphNodeModel | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_upsert_graph(running_server): | ||
|
|
||
| class PrintNode(BaseNode): | ||
| class Inputs(BaseModel): | ||
| message: str | ||
|
|
||
| async def execute(self): | ||
| print(self.inputs.message) # type: ignore | ||
|
|
||
|
NiveditJain marked this conversation as resolved.
|
||
|
|
||
| state_machine_url = running_server.base_url | ||
|
NiveditJain marked this conversation as resolved.
|
||
| runtime = Runtime( | ||
| namespace="test", | ||
| name="test", | ||
| nodes=[ | ||
| PrintNode | ||
| ], | ||
| state_manager_uri=state_machine_url, | ||
| ) | ||
|
|
||
| # Use asyncio task instead of thread for proper cleanup | ||
| runtime_task = None | ||
|
|
||
| try: | ||
| # Start runtime as an asyncio task (non-blocking) | ||
| runtime_task = asyncio.create_task(runtime._start()) | ||
|
|
||
| # Give runtime time to initialize | ||
| await asyncio.sleep(2) | ||
|
|
||
|
NiveditJain marked this conversation as resolved.
Outdated
|
||
| state_manager = StateManager( | ||
| namespace="test", | ||
| state_manager_uri=state_machine_url, | ||
| ) | ||
| data = await state_manager.upsert_graph( | ||
| graph_name="test_graph", | ||
| graph_nodes=[ | ||
| GraphNodeModel( | ||
| node_name="PrintNode", | ||
| namespace="test", | ||
| identifier="node1", | ||
| inputs={ | ||
| "message": "Hello, world!", | ||
| }, | ||
| ) | ||
| ], | ||
| secrets={}, | ||
| ) | ||
| assert data is not None | ||
|
|
||
|
NiveditJain marked this conversation as resolved.
Outdated
|
||
| finally: | ||
| # Ensure proper cleanup of the runtime task | ||
| if runtime_task and not runtime_task.done(): | ||
| runtime_task.cancel() | ||
| try: | ||
| await runtime_task | ||
| except asyncio.CancelledError: | ||
| pass # Expected when cancelling | ||
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.