Skip to content

RHIDP-14000: update tests for vector stores#1912

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
Jdubrick:vector-store-test-update
Jun 12, 2026
Merged

RHIDP-14000: update tests for vector stores#1912
tisnik merged 1 commit into
lightspeed-core:mainfrom
Jdubrick:vector-store-test-update

Conversation

@Jdubrick

@Jdubrick Jdubrick commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Description

  • Confirmed standalone DELETE /v1/files/{fileId} endpoint does not exist

    • only the nested DELETE /v1/vector-stores/{id}/files/{file_id} route is implemented (already has unit tests)
  • Added 3 unit tests to test_vector_stores.py covering previously untested error/edge-case paths:

    • get_vector_store connection error (503) — the only handler missing this test
    • create_file auto-appending .txt extension to files without one
    • create_file returning 400 for non-size-related BadRequestError
  • Added 8 VectorStoreCreateRequest model validation tests

    • the only request model in the vector stores module that had no validation coverage
  • Added 5 E2E Gherkin scenarios in vector_stores.feature for HTTP-level validation (list 200, empty body 422, extra fields 422, empty update 422, empty file-add 422)

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
  • Benchmarks improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: Claude
  • Generated by: (e.g., tool name and version; N/A if not used)

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for vector stores API endpoints and request validation
    • Added tests for error handling, input validation, and edge case scenarios to ensure robust vector store operations

Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR adds comprehensive test coverage for the vector stores API across three levels: end-to-end feature tests that define expected behavior, unit tests validating endpoint error handling and file operations, and unit tests for request model validation constraints.

Changes

Vector Stores API Test Coverage

Layer / File(s) Summary
E2E feature tests for vector stores API
tests/e2e/features/vector_stores.feature, tests/e2e/test_list.txt
Gherkin feature file defines scenarios validating HTTP 200 for list operations with JSON content type, HTTP 422 for POST/PUT with empty bodies or extra fields, and service startup background with Bearer token auth and noop-token configuration. Test list is updated to run the new feature file.
Unit tests for endpoint error handling and file operations
tests/unit/app/endpoints/test_vector_stores.py
Tests for get_vector_store propagating APIConnectionError as HTTP 503, create_file normalizing filenames by appending .txt extension when missing, and create_file mapping BadRequestError with "invalid file format" message to HTTP 400 with specific detail response.
Unit tests for VectorStoreCreateRequest validation
tests/unit/models/requests/test_vector_store_requests.py
Validates request model constraints: name field is required, non-empty, with maximum 256 characters; embedding_dimension must be positive; optional fields (embedding model, provider id, metadata) are accepted; extra/unknown fields are rejected by Pydantic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • tisnik
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically refers to updating tests for vector stores, which directly matches the changeset's primary focus of adding unit tests and e2e tests for vector store endpoints.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/e2e/features/vector_stores.feature`:
- Line 8: Replace the hardcoded JWT in the step "I set the Authorization header
to Bearer eyJhbGci..." with a non-secret placeholder or env-driven value: update
the feature step to use a placeholder token like "I set the Authorization header
to Bearer <TEST_TOKEN>" (or call a step that reads from test config/env), and
update the corresponding step definition to inject process.env.TEST_TOKEN or a
fixture value so no real JWT is committed in the feature file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a8fa371a-4b72-4cf9-b4c1-e17c9f9ddc78

📥 Commits

Reviewing files that changed from the base of the PR and between 6116ef7 and 0b2aa08.

📒 Files selected for processing (4)
  • tests/e2e/features/vector_stores.feature
  • tests/e2e/test_list.txt
  • tests/unit/app/endpoints/test_vector_stores.py
  • tests/unit/models/requests/test_vector_store_requests.py
📜 Review details
⏰ 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). (14)
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: spectral
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: build-pr
  • GitHub Check: Pylinter
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-6-on-pull-request
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
🧰 Additional context used
📓 Path-based instructions (2)
tests/e2e/**/*.{py,feature}

📄 CodeRabbit inference engine (AGENTS.md)

Use behave (BDD) framework for end-to-end testing with Gherkin feature files

Files:

  • tests/e2e/features/vector_stores.feature
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.py: Use pytest for all unit and integration tests; do not use unittest
Use pytest.mark.asyncio marker for async tests

Files:

  • tests/unit/models/requests/test_vector_store_requests.py
  • tests/unit/app/endpoints/test_vector_stores.py
🪛 Betterleaks (1.3.1)
tests/e2e/features/vector_stores.feature

[high] 8-8: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

(jwt)

🔇 Additional comments (4)
tests/e2e/features/vector_stores.feature (1)

1-7: LGTM!

Also applies to: 9-46

tests/e2e/test_list.txt (1)

32-32: LGTM!

tests/unit/app/endpoints/test_vector_stores.py (1)

1186-1284: LGTM!

tests/unit/models/requests/test_vector_store_requests.py (1)

6-10: LGTM!

Also applies to: 13-70

Background:
Given The service is started locally
And The system is in default state
And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove hardcoded bearer token from test feature data.

Line 8 commits a JWT-like token directly in the feature file. Even for test fixtures, this creates secret-scanner noise and weakens security hygiene in-repo. Replace with a non-token placeholder step/fixture value (or load from test config/env).

🧰 Tools
🪛 Betterleaks (1.3.1)

[high] 8-8: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

(jwt)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/features/vector_stores.feature` at line 8, Replace the hardcoded
JWT in the step "I set the Authorization header to Bearer eyJhbGci..." with a
non-secret placeholder or env-driven value: update the feature step to use a
placeholder token like "I set the Authorization header to Bearer <TEST_TOKEN>"
(or call a step that reads from test config/env), and update the corresponding
step definition to inject process.env.TEST_TOKEN or a fixture value so no real
JWT is committed in the feature file.

Source: Linters/SAST tools

@tisnik tisnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@tisnik tisnik merged commit d447014 into lightspeed-core:main Jun 12, 2026
38 of 39 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.

2 participants