Repository navigation
feat(ci): Add e2e test suite, including barebones test_smoke.py
#125
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
matthewgrossman
merged 24 commits into
main
from
mgrossman/aircore-679-fix-nemo-platform-pypi-readme-to-show-top-level-project-info
Jun 1, 2026
Merged
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
34f44ba
fix(docs): Update `nemo-platform` README.md to be more public-facing
matthewgrossman b36af3e
add readme
matthewgrossman 569b6d4
Merge branch 'main' into mgrossman/aircore-679-fix-nemo-platform-pypi…
matthewgrossman 2051bf1
Merge branch 'main' into mgrossman/aircore-679-fix-nemo-platform-pypi…
matthewgrossman dbc2afb
fix up nemo-platform-plugin
matthewgrossman 72d7c8f
apply code review feedback
matthewgrossman b3ed16a
remove coming soon
matthewgrossman c9600ef
code review
matthewgrossman 7326046
feat(ci): Add e2e tests
matthewgrossman ebdee3f
Merge branch 'main' into mgrossman/aircore-679-fix-nemo-platform-pypi…
matthewgrossman 8aa78e5
fix conftest
matthewgrossman b002fd1
fix wheel-build
matthewgrossman c1f8c67
run latest version
matthewgrossman ed36b2d
bring into PRs
matthewgrossman 6bc3597
comments
matthewgrossman b57fea8
Merge branch 'main' into mgrossman/aircore-679-fix-nemo-platform-pypi…
matthewgrossman 87eea1f
fixes
matthewgrossman 7765621
fixes
matthewgrossman 6a3e4a0
Merge branch 'main' into mgrossman/aircore-679-fix-nemo-platform-pypi…
matthewgrossman bd5012c
add e2e test
matthewgrossman 539cf94
fixes
matthewgrossman 14c8005
add testing.md
matthewgrossman 4e24680
fix name
matthewgrossman e60a061
add comment
matthewgrossman 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
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 |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| """E2E test fixtures that run against a real ``nemo services`` process. | ||
|
|
||
| Usage:: | ||
|
|
||
| # Start services, run e2e tests, stop services | ||
| make test-e2e | ||
|
|
||
| # Or manually | ||
| uv run --frozen pytest e2e -v --run-e2e | ||
|
|
||
| # If you already have services running | ||
| NMP_BASE_URL=http://localhost:9090 uv run --frozen pytest e2e -v --run-e2e | ||
|
|
||
| When ``NMP_BASE_URL`` is set the harness skips service startup/shutdown and | ||
| connects to the given URL. Otherwise it spawns ``nemo services run`` as a | ||
| child process on a free port, polls ``/health/ready`` until ready, and | ||
| terminates the process after the session. | ||
| """ | ||
|
|
||
| import logging | ||
| import os | ||
| import socket | ||
| import subprocess | ||
| import sys | ||
| import time | ||
| import uuid | ||
| from collections.abc import Iterator | ||
| from pathlib import Path | ||
|
|
||
| import httpx | ||
| import pytest | ||
| from nemo_platform import NeMoPlatform | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| _HEALTH_TIMEOUT = 60 | ||
| _HEALTH_POLL_INTERVAL = 1.0 | ||
|
|
||
|
|
||
| def _find_free_port() -> int: | ||
| """Bind to port 0 and let the OS assign a free port.""" | ||
| with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
| s.bind(("127.0.0.1", 0)) | ||
| return s.getsockname()[1] | ||
|
|
||
|
|
||
| def _wait_for_healthy(url: str, timeout: float = _HEALTH_TIMEOUT) -> bool: | ||
| """Poll /health/ready until it returns 200 or timeout expires.""" | ||
| deadline = time.monotonic() + timeout | ||
| while time.monotonic() < deadline: | ||
| try: | ||
| resp = httpx.get(f"{url}/health/ready", timeout=2.0) | ||
| if resp.status_code == 200: | ||
| return True | ||
| except httpx.RequestError: | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| pass | ||
| time.sleep(_HEALTH_POLL_INTERVAL) | ||
| return False | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def _services() -> Iterator[str]: | ||
| """Spawn ``nemo services run`` and yield the base URL. | ||
|
|
||
| Skipped when ``NMP_BASE_URL`` is already set (external services). | ||
| The process is our direct child — on teardown we just terminate it. | ||
| """ | ||
| external_url = os.environ.get("NMP_BASE_URL") | ||
| if external_url: | ||
| yield external_url | ||
| return | ||
|
|
||
| port = _find_free_port() | ||
| url = f"http://127.0.0.1:{port}" | ||
|
|
||
| nemo_bin = str(Path(sys.executable).parent / "nemo") | ||
| args = [ | ||
| nemo_bin, | ||
| "services", | ||
| "run", | ||
| "--service-group", | ||
| "all", | ||
| "--port", | ||
| str(port), | ||
| ] | ||
|
|
||
| logger.info("Starting nemo services on port %d", port) | ||
|
|
||
| proc = subprocess.Popen( | ||
| args, | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.STDOUT, | ||
| text=True, | ||
| ) | ||
|
|
||
| if not _wait_for_healthy(url): | ||
| # Grab whatever output we have for diagnostics | ||
| proc.terminate() | ||
| stdout, _ = proc.communicate(timeout=10) | ||
| pytest.fail(f"nemo services run did not become healthy within {_HEALTH_TIMEOUT}s.\nstdout:\n{stdout}") | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| logger.info("Platform services ready on port %d (pid %d)", port, proc.pid) | ||
|
|
||
| yield url | ||
|
|
||
| logger.info("Terminating nemo services (pid %d)", proc.pid) | ||
| proc.terminate() | ||
| try: | ||
| proc.wait(timeout=10) | ||
| except subprocess.TimeoutExpired: | ||
| logger.warning("Process did not exit after SIGTERM, sending SIGKILL") | ||
| proc.kill() | ||
| proc.wait(timeout=5) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def sdk(_services: str) -> NeMoPlatform: | ||
| """Provide an SDK client connected to the running platform.""" | ||
| return NeMoPlatform(base_url=_services, max_retries=2) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="function") | ||
| def workspace(sdk: NeMoPlatform) -> Iterator[str]: | ||
| """Create a unique workspace for each test, deleted on teardown.""" | ||
| name = f"e2e-{uuid.uuid4().hex[:8]}" | ||
| sdk.workspaces.create(name=name) | ||
| yield name | ||
| sdk.workspaces.delete(name) | ||
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,37 @@ | ||
| """Smoke tests that verify the platform is reachable and core APIs respond. | ||
|
|
||
| These are intentionally minimal — they validate the e2e harness works and | ||
| that services are up. Add more substantive tests in separate files. | ||
| """ | ||
|
|
||
| from nemo_platform import NeMoPlatform | ||
|
|
||
|
|
||
| def test_health_ready(sdk: NeMoPlatform): | ||
| """GET /health/ready returns 200 when all services are up.""" | ||
| resp = sdk._client.get("/health/ready") | ||
| assert resp.status_code == 200 | ||
|
|
||
|
|
||
| def test_health_live(sdk: NeMoPlatform): | ||
| """GET /health/live returns 200 (liveness probe).""" | ||
| resp = sdk._client.get("/health/live") | ||
| assert resp.status_code == 200 | ||
|
|
||
|
|
||
| def test_create_and_delete_workspace(workspace: str, sdk: NeMoPlatform): | ||
| """Workspace CRUD round-trips through the platform. | ||
|
|
||
| Uses the ``workspace`` fixture which creates a unique workspace | ||
| and deletes it on teardown. | ||
| """ | ||
| page = sdk.workspaces.list() | ||
| names = [w.name for w in page.data] | ||
| assert workspace in names | ||
|
|
||
|
|
||
| def test_list_workspaces(sdk: NeMoPlatform, workspace: str): | ||
| """Listing workspaces returns at least the test workspace.""" | ||
| page = sdk.workspaces.list() | ||
| names = [w.name for w in page.data] | ||
| assert workspace in names |
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.