Skip to content

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Oct 31, 2025

Description

LCORE-628: OpenAPI integration tests

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement

Related Tickets & Documents

  • Related Issue #LCORE-628

Summary by CodeRabbit

  • Tests
    • Extended OpenAPI validation to support loading specifications from both file and URL sources
    • Added configuration template with service settings, integration options, and data collection controls

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

Walkthrough

This patch introduces a new YAML test configuration file for Lightspeed Core Service and expands OpenAPI integration tests to validate API specifications loaded from both files and HTTP URLs, with new test fixtures and comprehensive endpoint validation.

Changes

Cohort / File(s) Summary
New Test Configuration
tests/configuration/lightspeed-stack-proper-name.yaml
Adds YAML configuration file defining Lightspeed Core Service settings including service parameters (host, port, workers, CORS), remote llama-stack integration, user data collection toggles, and MCP server endpoints.
OpenAPI Integration Tests
tests/integration/test_openapi_json.py
Introduces URL-based OpenAPI spec loading alongside existing file-based loading. Adds two new public test fixtures (spec_from_file, spec_from_url) returning OpenAPI dicts. Implements helper functions for top-level validation, server section checks, and path/response verification. Extends parameterized tests to validate paths, methods, and response codes from both sources.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • New YAML configuration is purely declarative with no executable logic
  • Test changes follow a consistent pattern of fixture addition and test expansion without complex conditional logic
  • Helper functions are straightforward validation utilities
  • Changes are homogeneous in nature (systematic test infrastructure additions)

Possibly related PRs

Suggested reviewers

  • radofuchs

Poem

🐰 A config file hops into place,
And tests now fetch specs with grace,
From files and URLs they dance and play,
Validating paths the OpenAPI way! 🔍

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "LCORE-628: OpenAPI integration tests" is directly related to the main change in this changeset. The most substantial modification is in tests/integration/test_openapi_json.py, which extends OpenAPI integration testing by introducing dual pathways for loading OpenAPI specs (from file and URL), adding public test fixtures, and expanding validation coverage. The PR objectives explicitly state the purpose is to "Add OpenAPI integration tests associated with ticket LCORE-628," which aligns perfectly with the title. The secondary addition of a supporting YAML configuration file does not diminish the primary focus. The title is concise, specific, and clearly communicates the main intent of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 92.31% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tisnik tisnik force-pushed the lcore-628-openapi-integration-tests branch from c05cc8e to 3768324 Compare October 31, 2025 08:24
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/integration/test_openapi_json.py (1)

178-231: Consolidate shared endpoint data.

Both parametrized tests repeat the same (path, method, expected_codes) tuples; extracting them into a shared constant (or helper generator) would keep the assertions in sync and reduce maintenance churn.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36d0a94 and 3768324.

📒 Files selected for processing (2)
  • tests/configuration/lightspeed-stack-proper-name.yaml (1 hunks)
  • tests/integration/test_openapi_json.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: All modules start with descriptive module-level docstrings explaining purpose
Use logger = logging.getLogger(name) for module logging after import logging
Define type aliases at module level for clarity
All functions require docstrings with brief descriptions
Provide complete type annotations for all function parameters and return types
Use typing_extensions.Self in model validators where appropriate
Use modern union syntax (str | int) and Optional[T] or T | None consistently
Function names use snake_case with descriptive, action-oriented prefixes (get_, validate_, check_)
Avoid in-place parameter modification; return new data structures instead of mutating arguments
Use appropriate logging levels: debug, info, warning, error with clear messages
All classes require descriptive docstrings explaining purpose
Class names use PascalCase with conventional suffixes (Configuration, Error/Exception, Resolver, Interface)
Abstract base classes should use abc.ABC and @AbstractMethod for interfaces
Provide complete type annotations for all class attributes
Follow Google Python docstring style for modules, classes, and functions, including Args, Returns, Raises, Attributes sections as needed

Files:

  • tests/integration/test_openapi_json.py
tests/{unit,integration}/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests
Do not use unittest in tests; pytest is the standard

Files:

  • tests/integration/test_openapi_json.py
tests/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

tests/**/*.py: Use pytest-mock to create AsyncMock objects for async interactions in tests
Use the shared auth mock constant: MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token") in tests

Files:

  • tests/integration/test_openapi_json.py
🧠 Learnings (1)
📓 Common learnings
Learnt from: radofuchs
Repo: lightspeed-core/lightspeed-stack PR: 485
File: tests/e2e/features/environment.py:87-95
Timestamp: 2025-09-02T11:09:40.404Z
Learning: In the lightspeed-stack e2e tests, noop authentication tests use the default lightspeed-stack.yaml configuration, while noop-with-token tests use the Authorized tag to trigger a config swap to the specialized noop-with-token configuration file.
🧬 Code graph analysis (1)
tests/integration/test_openapi_json.py (1)
src/configuration.py (2)
  • configuration (73-77)
  • load_configuration (56-62)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build-pr
  • GitHub Check: e2e_tests (azure)
  • GitHub Check: e2e_tests (ci)

Comment on lines +37 to +52
configuration_filename = "tests/configuration/lightspeed-stack-proper-name.yaml"
cfg = configuration
cfg.load_configuration(configuration_filename)
from app.main import app # pylint: disable=C0415

client = TestClient(app)
response = client.get("/openapi.json")
assert response.status_code == requests.codes.ok # pylint: disable=no-member

# this line ensures that response payload contains proper JSON
payload = response.json()
assert payload is not None, "Incorrect response"

return payload


Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Restore configuration after overriding.

configuration.load_configuration(...) mutates the shared singleton for the whole process. Because we never reload the previous/default file, every later test in the same session inherits lightspeed-stack-proper-name.yaml, breaking isolation for suites that expect the stock stack config (notably the Authorized/Noop swaps noted in our e2e learnings). Please scope this override and restore the prior configuration once the OpenAPI payload is fetched (e.g., capture the active config, yield the TestClient, then reload the original file in finally). Based on learnings

🤖 Prompt for AI Agents
In tests/integration/test_openapi_json.py around lines 37 to 52, the call to
configuration.load_configuration(...) mutates the shared singleton and is not
restored; capture the current active configuration (e.g., save the currently
loaded configuration filename or serialized config state) before calling
load_configuration, perform the TestClient request, and then in a finally block
(or using yield in a fixture) reload the saved configuration to restore the
prior state so other tests aren't affected.

@tisnik tisnik merged commit af32bec into lightspeed-core:main Oct 31, 2025
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant