test(core): add testcontainers for Milvus gRPC integration tests#78
test(core): add testcontainers for Milvus gRPC integration tests#78
Conversation
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
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
|
There was a problem hiding this comment.
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.
| async function dropCollectionIfExists(collectionName: string): Promise<void> { | ||
| const exists = await milvusDb.hasCollection(collectionName).catch(() => false) | ||
| if (exists) { | ||
| await milvusDb.dropCollection(collectionName).catch(() => {}) | ||
| } | ||
| } |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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;.
| const metadata = typeof result.metadata === 'string' | ||
| ? JSON.parse(result.metadata) | ||
| : result.metadata |
There was a problem hiding this comment.
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 () => { |
There was a problem hiding this comment.
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>


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
Test Coverage (15 test cases across 5 suites)
Collection Operations
Document Insertion
Query with Metadata Extraction
Hybrid Search with BM25
Sync Integration
Dependencies
testcontainers^10.24.2 to core package devDependenciesTest Plan
Testing Instructions
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
Dependencies
Written for commit 9360254. Summary will update on new commits.