Files
FastGPT/test/integrationTest/vectorDB/README.md
Archer 64f70a41c1 feat: vector integrationTest;feat: ob quantization (#6366)
* feat(vectordb): add OceanBase HNSW quantization (HNSW_SQ/HNSW_BQ) (#6348)

Support OceanBase vector index quantization via VECTOR_VQ_LEVEL:
- 32 (default): hnsw + inner_product
- 8: hnsw_sq + inner_product (2-3x memory savings)
- 1: hnsw_bq + cosine (~15x memory savings)

HNSW_BQ requires cosine distance per OceanBase docs.
Tested on OceanBase 4.3.5.5 (BP5).

Closes #6202

* feat: add test inclusion for vectorDB tests in vitest configuration (#6358)

* feat: add test inclusion for vectorDB tests in vitest configuration

* refactor: update vectorDB README and setup for environment configuration

- Enhanced README to clarify the use of factory pattern for vectorDB integration tests.
- Updated instructions for setting up environment variables from a local file.
- Removed obsolete PG integration test file and adjusted test execution instructions.
- Improved structure explanation for shared test data and factory functions.

* perf: integrationTest

* feat: vector integration

---------

Co-authored-by: ZHANG Yixin <hi.yixinz@gmail.com>
Co-authored-by: Jingchao <alswlx@gmail.com>
2026-02-02 18:48:25 +08:00

43 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 向量数据库集成测试
对 FastGPT 各向量库控制器PGVector、后续 Oceanbase/Milvus做真实环境下的集成测试保证向量相关操作兼容和稳定。采用**工厂模式**同一套数据集fixtures和同一套用例factory驱动 n 个向量库测试。
## 环境变量
测试环境变量由 **test/.env.test.local** 提供(不提交到 git。请复制模板并填写
```bash
cp test/.env.test.template test/.env.test.local
# 编辑 test/.env.test.local填入 PG_URL 等
```
`setup.ts` 会在测试启动时读取 `test/.env.test.local` 并注入到 `process.env`
| 变量 | 说明 | 适用驱动 |
|------|------|----------|
| `PG_URL` | PostgreSQL + pgvector 连接串 | PgVectorCtrl |
| `OCEANBASE_URL` | Oceanbase 连接串(后续) | ObVectorCtrl |
| `MILVUS_ADDRESS` | Milvus 地址(后续) | MilvusCtrl |
未设置对应环境变量时,该驱动的集成测试会**整体跳过**,不会报错。
## 运行方式
在项目根目录执行:
```bash
# 仅运行单元测试(未配置 .env.test.local 或未设 PG_URL 时vectorDB 集成测试会跳过)
pnpm test
# 运行所有向量库测试(包含 vectorDB 集成测试与相关单元测试)
pnpm test:vector
```
## 结构说明
- **fixtures.ts**:统一测试数据(`TEST_TEAM_ID``TEST_DATASET_ID``TEST_COLLECTION_ID`、1536 维 `TEST_VECTORS`),所有向量库共用。
- **factory.ts**:工厂函数 `runVectorDBTests(driver)`同一套用例init、insert、getVectorCount、embRecall、getVectorDataByTime、delete供各驱动复用。
- **integration.test.ts**注册各驱动PG、后续 Oceanbase/Milvus`driver.envKey` 决定是否跳过;每个驱动执行同一套 `runVectorDBTests(driver)`
新增向量库时:在 `integration.test.ts``drivers` 数组中增加一项(`name``envKey``createCtrl`),无需改 fixtures 或 factory。