Skip to content

test(core): add testcontainers for Milvus gRPC integration tests#78

Open
amondnet wants to merge 1 commit intomainfrom
test/add-testcontainers-milvus-integration
Open

test(core): add testcontainers for Milvus gRPC integration tests#78
amondnet wants to merge 1 commit intomainfrom
test/add-testcontainers-milvus-integration

Conversation

@amondnet
Copy link
Contributor

@amondnet amondnet commented Feb 3, 2026

Summary

Add comprehensive integration tests for the Milvus gRPC client using testcontainers for automatic container lifecycle management. This follows the same testing approach as the recent Qdrant integration tests (#77).

Changes

Test Infrastructure

  • Testcontainers integration: Automatic Milvus container management with graceful Docker unavailability handling
  • Milvus standalone mode: Uses embedded etcd (v2.5.10) to eliminate external dependencies
  • Smart test skipping: Tests automatically skip when Docker is unavailable

Test Coverage (15 test cases across 5 suites)

  1. Collection Operations

    • List collections
    • Check collection existence
    • Create and drop collections
  2. Document Insertion

    • Insert documents with metadata validation
  3. Query with Metadata Extraction

    • Extract metadata.codebasePath correctly
    • Handle string/integer field types
    • Return all fields when outputFields is empty
    • Filter by fileExtension
    • Handle empty collections gracefully
  4. Hybrid Search with BM25

    • Perform hybrid search with dense + sparse vectors
    • Handle empty sparse vector results
    • Verify BM25 model persistence across searches
  5. Sync Integration

    • Extract codebasePath from Milvus collections for sync functionality

Dependencies

  • Add testcontainers ^10.24.2 to core package devDependencies
  • Minor import reordering in ast-splitter.ts (code formatting)

Test Plan

  • All tests pass locally with Docker available
  • Tests skip gracefully when Docker is unavailable
  • Milvus container starts successfully (3-minute timeout)
  • Test cleanup properly drops collections after each test
  • pnpm build succeeds
  • No breaking changes to existing code

Testing Instructions

# Run integration tests (requires Docker)
pnpm test packages/core/test/integration/milvus-grpc.integration.test.ts

# Run all core tests
cd packages/core
pnpm test

# Verify tests skip gracefully without Docker
docker stop $(docker ps -q)  # Stop Docker daemon
pnpm test  # Should skip with warning message

Related


Summary by cubic

Adds Milvus gRPC integration tests using Testcontainers to run a standalone Milvus (v2.5.10 with embedded etcd) for automatic lifecycle. Expands coverage for collection ops, inserts, queries with metadata, and hybrid BM25 search; tests skip when Docker isn’t available.

  • New Features

    • Automatic Milvus container management with health checks and a 3-minute startup timeout.
    • 15 tests across 5 areas: collection ops, insert with metadata, query field/metadata extraction and filters, hybrid dense+sparse (BM25) search, and sync codebasePath extraction.
    • Per-test cleanup that drops collections.
  • Dependencies

    • Add testcontainers ^10.24.2 to core devDependencies.

Written for commit 9360254. Summary will update on new commits.

Add comprehensive integration tests for Milvus gRPC client using testcontainers:
- Automatic Milvus container management with embedded etcd
- Collection operations (create, drop, list, exists)
- Document insertion with metadata validation
- Query operations with metadata extraction
- Hybrid search with BM25 sparse vectors
- Field type validation (string, integer, JSON)
- Sync integration for codebasePath extraction

Tests automatically skip when Docker is unavailable. Uses Milvus standalone
mode (v2.5.10) with embedded etcd to avoid external dependencies.

Changes:
- Add testcontainers dependency to core package
- Create milvus-grpc.integration.test.ts with 15 test cases
- Minor import reordering in ast-splitter.ts
- Update pnpm-lock.yaml
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 3, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @amondnet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the testing infrastructure for the Milvus gRPC client by introducing a new set of integration tests. These tests utilize testcontainers to automate the lifecycle of Milvus Docker instances, ensuring a reliable and reproducible testing environment. The added test coverage validates a broad spectrum of Milvus operations, from basic data management to complex search and metadata handling, thereby improving the overall stability and correctness of Milvus interactions within the core package.

Highlights

  • New Milvus gRPC Integration Tests: Introduced a comprehensive suite of integration tests for the Milvus gRPC client, ensuring robust functionality and reliability.
  • Testcontainers for Automated Environment Management: Leveraged testcontainers to automatically manage Milvus instances within Docker containers, providing isolated and consistent testing environments. Tests gracefully skip if Docker is unavailable.
  • Extensive Test Coverage: Added 15 new test cases across 5 suites, covering collection operations, document insertion, advanced queries with metadata extraction, hybrid search with BM25, and sync integration functionalities.
  • Simplified Milvus Setup: Configured Milvus to run in standalone mode with embedded etcd, eliminating external dependencies and simplifying the test setup.
Changelog
  • packages/core/package.json
    • Added testcontainers (v10.24.2) as a development dependency.
  • packages/core/src/splitter/ast-splitter.ts
    • Performed minor import reordering for code formatting consistency.
  • packages/core/test/integration/milvus-grpc.integration.test.ts
    • Added a new file containing comprehensive integration tests for the Milvus gRPC client.
    • Implemented testcontainers setup for Milvus standalone with embedded etcd.
    • Included tests for collection creation, listing, and dropping.
    • Added tests for document insertion with metadata.
    • Developed tests for querying with metadata extraction, including handling string/integer types, returning all fields, and filtering by file extension.
    • Incorporated tests for hybrid search using dense and sparse vectors (BM25), covering empty sparse vector scenarios and model persistence.
    • Included a test to verify codebasePath extraction for sync integration.
  • pnpm-lock.yaml
    • Updated the lock file to include the new testcontainers dependency and its transitive dependencies.
Activity
  • The pull request introduces new integration tests for the Milvus gRPC client.
  • It leverages testcontainers to manage the Milvus Docker container for testing purposes.
  • The tests are designed to automatically skip if Docker is not available on the host machine.
  • The new test suite covers various Milvus operations, including collection management, document insertion, metadata querying, and hybrid search.
  • A minor formatting change was applied to ast-splitter.ts to reorder imports.
  • The testcontainers dependency was added to package.json and pnpm-lock.yaml.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
18.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive suite of integration tests for the Milvus gRPC client using testcontainers. The implementation is well-executed, including robust handling for environments where Docker is unavailable and good test isolation practices. The test coverage is thorough, spanning collection management, document handling, and various search functionalities. My feedback includes a few suggestions to enhance the maintainability and robustness of the new test code.

Comment on lines +39 to +44
async function dropCollectionIfExists(collectionName: string): Promise<void> {
const exists = await milvusDb.hasCollection(collectionName).catch(() => false)
if (exists) {
await milvusDb.dropCollection(collectionName).catch(() => {})
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

If new MilvusVectorDatabase() in beforeEach fails, milvusDb will be undefined. When afterEach runs, it will call dropCollectionIfExists, which will then throw a TypeError because it tries to access milvusDb.hasCollection. To make the cleanup more robust, you should add a check to ensure milvusDb is defined at the beginning of this function.

  async function dropCollectionIfExists(collectionName: string): Promise<void> {
    if (!milvusDb) {
      return
    }
    const exists = await milvusDb.hasCollection(collectionName).catch(() => false)
    if (exists) {
      await milvusDb.dropCollection(collectionName).catch(() => {})
    }
  }

})

it.skipIf(() => skipTests)('should create and drop collection', async () => {
await milvusDb.createHybridCollection(testCollectionName, 1536)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The vector dimension 1536 is a magic number that appears in multiple places (e.g., here, lines 114, 142, and in createTestDocument). The dimension 384 is also used for hybrid search tests. To improve readability and maintainability, consider defining these as named constants at the top of the file, for example: const DENSE_VECTOR_DIM = 1536; and const HYBRID_VECTOR_DIM = 384;.

Comment on lines +169 to +171
const metadata = typeof result.metadata === 'string'
? JSON.parse(result.metadata)
: result.metadata
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This logic for parsing metadata is duplicated in a few places (here and at lines 361-363). To improve maintainability and reduce code duplication, consider extracting this into a small helper function.

@dosubot dosubot bot added scope:dependencies Dependency updates type: testing Adding missing tests or correcting existing tests labels Feb 3, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/core/test/integration/milvus-grpc.integration.test.ts">

<violation number="1" location="packages/core/test/integration/milvus-grpc.integration.test.ts:92">
P1: `it.skipIf()` expects a boolean, not a function. Passing `() => skipTests` is always truthy, causing tests to always be skipped. Use `it.skipIf(skipTests)` instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

})

describe('collection Operations', () => {
it.skipIf(() => skipTests)('should list collections', async () => {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 3, 2026

Choose a reason for hiding this comment

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

P1: it.skipIf() expects a boolean, not a function. Passing () => skipTests is always truthy, causing tests to always be skipped. Use it.skipIf(skipTests) instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/test/integration/milvus-grpc.integration.test.ts, line 92:

<comment>`it.skipIf()` expects a boolean, not a function. Passing `() => skipTests` is always truthy, causing tests to always be skipped. Use `it.skipIf(skipTests)` instead.</comment>

<file context>
@@ -0,0 +1,369 @@
+  })
+
+  describe('collection Operations', () => {
+    it.skipIf(() => skipTests)('should list collections', async () => {
+      expect(Array.isArray(await milvusDb.listCollections())).toBe(true)
+    })
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:dependencies Dependency updates size:L This PR changes 100-499 lines, ignoring generated files. type: testing Adding missing tests or correcting existing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant