Skip to content

feat(test): Support result saving functionality for multiple storage#764

Merged
Wwwzff merged 7 commits intoModelEngine-Group:developfrom
Potterluo:develop_testResults_capture
Mar 13, 2026
Merged

feat(test): Support result saving functionality for multiple storage#764
Wwwzff merged 7 commits intoModelEngine-Group:developfrom
Potterluo:develop_testResults_capture

Conversation

@Potterluo
Copy link
Copy Markdown
Contributor

PR: feat(test): Support result saving functionality for multiple storage backends

Description

This PR introduces a robust, multi-backend storage system for test results. It replaces the legacy database utility functions with a unified interface that supports Local File, MongoDB, and PostgreSQL backends. This enhancement allows users to configure and switch between different storage solutions seamlessly based on their infrastructure needs.

Key Changes

New Features

  • Multi-Backend Support: Implemented concrete storage adapters for:
    • localFile: Saves results to the local filesystem (JSON/CSV).
    • mongodb: Stores results in MongoDB collections.
    • postgresql: Stores results in PostgreSQL tables.
  • Automatic Type Inference: Added logic to automatically infer and convert data types during the saving process, ensuring schema consistency across different backends.
  • Resilience Mechanisms: Implemented connection management pools and automatic retry mechanisms specifically for MongoDB and PostgreSQL to handle transient network issues.

Refactoring

  • Unified Interface: Updated capture_utils to utilize the new generic storage backend interface, decoupling business logic from specific storage implementations.
  • Legacy Cleanup: Removed obsolete database utility functions and consolidated them into the new general result-saving mechanism.
  • Configuration Overhaul: Modified the configuration file structure to support dynamic multi-storage backend definitions (e.g., selecting the active backend and providing specific connection strings).

Configuration Example

The configuration file now supports a storage section:

results:
  - localFile: # Save the storage results to a local file. The default formats are jsonl and csv.
      path: "./results"
  - postgresql:
      host: "localhost"
      port: 5432
      dbname: "ucm_test"
      user: "postgres"
      password: "123456"
      retry: 3
  - mongodb:
      host: "127.0.0.1"
      port: 27017
      dbname: "myapp"
      user: "root"
      password: "123456"
      authSource: "admin"
      retry: 3

Testing

image

@Potterluo Potterluo force-pushed the develop_testResults_capture branch 2 times, most recently from 84a5b7e to 2821b05 Compare February 28, 2026 01:31
@Potterluo Potterluo force-pushed the develop_testResults_capture branch 3 times, most recently from 5c8f0a7 to 4e80964 Compare March 2, 2026 11:24
…backends

- Added implementation of localFile, mongodb and postgresql storage backends
- Modified configuration file to support multi-storage backend configuration
- Updated capture_utils to use the new storage backend interface
- Removed old database utility functions and refactored them into a general result saving mechanism
- Added automatic inference and conversion functions for multiple data types
- Implemented connection management and retry mechanisms for MongoDB and PostgreSQL
…ndency injection

- Add new global build_id management functions set_build_id and get_build_id in capture_utils
- Remove the independent build_id setting logic in each database module and uniformly use global management
- Implement lazy loading database dependency injection mode to optimize module initialization performance
- Simplify the PostgreSQL and MongoDB write processes, removing redundant parameter passing
…y injection

- Remove the singleton dependency injection class DbDeps from the MongoDB module
- Remove the singleton dependency injection class DbDeps from the PostgreSQL module
- Replace the variables related to build_id with variables test_id and test_items
- Update the configuration instructions for saving test results in the README document
- Remove the unused global variable _test_build_id in localFile.py
…ironment

- Obtain additional information from the environment variable EXTRA_INFO and store it in the test data
@Potterluo Potterluo force-pushed the develop_testResults_capture branch from e979963 to e1f197d Compare March 3, 2026 03:07
@Wwwzff Wwwzff merged commit 167a3c3 into ModelEngine-Group:develop Mar 13, 2026
15 of 16 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.

3 participants