tree: 5903ceb96f7035f1badcd74be18869058bd695f9 [path history] [tgz]
  1. README.md
  2. test_cbmcp.py
  3. test_database_tools.py
mcp-server/tests/README.md

Apache Cloudberry MCP Testing Guide

Test Structure

This project uses the pytest framework for testing, supporting both asynchronous testing and parameterized testing.

Test Files

  • test_cbmcp.py - Main test file containing all MCP client functionality tests

Test Categories

  • Unit Tests - Test individual features independently
  • Integration Tests - Test overall system functionality
  • Parameterized Tests - Test both stdio and http modes simultaneously

Running Tests

Install Test Dependencies

pip install -e ".[dev]"

Run All Tests

pytest tests/

Run Specific Tests

# Run specific test file
pytest tests/test_cbmcp.py

# Run specific test class
pytest tests/test_cbmcp.py::TestCloudberryMCPClient

# Run specific test method
pytest tests/test_cbmcp.py::TestCloudberryMCPClient::test_list_capabilities

# Run tests for specific mode
pytest tests/test_cbmcp.py -k "stdio"

Verbose Output

pytest tests/ -v

Coverage Testing

pytest tests/ --cov=src.cbmcp --cov-report=html --cov-report=term

Test Features

1. Server Capabilities Tests

  • test_list_capabilities - Test tool, resource, and prompt listings

2. Resource Tests

  • test_get_schemas_resource - Get database schemas
  • test_get_tables_resource - Get table listings
  • test_get_database_info_resource - Get database information
  • test_get_database_summary_resource - Get database summary

3. Tool Tests

  • test_tools - Parameterized testing of all tool calls
    • list_tables
    • list_views
    • list_columns
    • list_indexes
    • execute_query
    • list_large_tables
    • get_table_stats
    • explain_query

4. Prompt Tests

  • test_analyze_query_performance_prompt - Query performance analysis prompts
  • test_suggest_indexes_prompt - Index suggestion prompts
  • test_database_health_check_prompt - Database health check prompts

Test Modes

Tests support two modes:

  • stdio - Standard input/output mode
  • http - HTTP mode

Notes

  1. Tests will skip inaccessible features (e.g., when database is not connected)
  2. Ensure Apache Cloudberry service is started and configured correctly
  3. Check database connection configuration in .env file

Using Scripts to Run

You can use the provided script to run tests:

./run_tests.sh