- Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Test Execution Problems in MCP Codebase Insight
Issue Description
The test suite in MCP Codebase Insight is experiencing several critical issues that prevent proper test execution and coverage reporting.
Current Problems
-
Environment Setup Issues
- Virtual environment activation problems
- Environment variables not properly loaded from
.envfile - PYTHONPATH configuration issues affecting module imports
-
Test Execution Failures
- Module import errors for
mcp_codebase_insightpackage - Event loop conflicts in async tests
- Test isolation problems between components
- Coverage reporting not working as expected
- Module import errors for
-
Integration Test Challenges
- Conflicts between different test categories (component vs integration)
- Async test execution causing race conditions
- SSE (Server-Sent Events) tests failing intermittently
-
Configuration and Infrastructure
- Qdrant collection naming conflicts in parallel test runs
- Docker container access issues for certain tests
- Git repository detection problems in CI/CD environment
Expected Behavior
-
All test categories should execute successfully:
- Component tests
- Integration tests
- Configuration tests
- API endpoint tests
- SSE endpoint tests
-
Test isolation should work properly:
- Each test module should run in isolation when needed
- No cross-contamination between test environments
- Clean test cache between runs
-
Coverage reporting should:
- Generate accurate reports
- Include all relevant code paths
- Produce both console and HTML output
Current Workarounds
- Using
--fully-isolatedflag to run tests in separate processes - Manual sourcing of
.envfile before test execution - Sequential test execution with
--sequentialflag to avoid event loop issues - Custom component test runner for better isolation
Technical Details
Test Runner Configuration
# Key environment variables needed MCP_TEST_MODE=1 MCP_HOST=localhost MCP_PORT=8000 QDRANT_URL=http://localhost:6333 MCP_COLLECTION_NAME=test_collection_{unique_id}Test Categories
-
Component Tests (
tests/components/)- Require strict asyncio mode
- Need isolated event loops
- Database dependencies
-
Integration Tests (
tests/integration/)- API endpoint tests
- SSE functionality
- External service interactions
-
Configuration Tests (
tests/config/)- Environment validation
- Configuration loading
- Default settings
Steps to Reproduce
- Clone the repository
- Set up virtual environment and install dependencies
- Copy
.env.exampleto.envand configure - Run test suite:
python run_tests.py --all
Error Messages
- Module Import Errors:
ModuleNotFoundError: No module named 'mcp_codebase_insight' - Event Loop Errors:
RuntimeError: Event loop is closed - Coverage Reporting Issues:
Coverage.py warning: No data was collected Proposed Solutions
-
Environment Management
- Implement robust virtual environment handling
- Automate
.envfile loading - Standardize PYTHONPATH configuration
-
Test Isolation
- Enhance the component test runner
- Implement better cleanup between tests
- Add transaction rollback for database tests
-
Async Testing
- Improve event loop management
- Add better error handling for async operations
- Implement proper test timeouts
-
Infrastructure
- Add Docker compose for test dependencies
- Implement better Qdrant collection management
- Add CI/CD specific configurations
Additional Context
- Project uses pytest for testing
- Coverage reporting through pytest-cov
- Async operations with asyncio
- Docker containers for isolation
- Qdrant for vector storage
- SSE for real-time updates
Related Files
run_tests.pycomponent_test_runner.pypytest.ini.env.exampletests/conftest.py
Labels
- bug
- testing
- high-priority
- needs-triage
- infrastructure
Metadata
Metadata
Assignees
Labels
No labels