# MCP Testing Suite
This directory contains all testing files organized by category and purpose.
## Directory Structure
```
testing/
├── 📁 api/ # API endpoint testing
├── 📁 core/ # Core functionality testing
├── 📁 integration/ # Integration testing
├── 📁 phase_tests/ # Phase-based development testing
├── 📁 legacy/ # Legacy/deprecated tests
├── 📄 README.md # This file
└── 📄 run_tests.py # Test runner script
```
## Test Categories
### 🌐 API Tests (`api/`)
Tests for HTTP endpoints and API functionality:
- **`test_all_endpoints_simple.py`** ⭐ **PRIMARY TESTER**
- Comprehensive endpoint testing for both servers
- 94.4% success rate validation
- Performance monitoring and error detection
- **Usage**: `py testing/api/test_all_endpoints_simple.py`
- **`test_all_endpoints.py`**
- Advanced endpoint tester (has Unicode issues on Windows)
- More detailed reporting features
- **`test_streaming.py`**
- Tests streaming chat endpoints
- Server-sent events validation
- **`test_conversation_chat.py`**
- Conversation memory and context testing
- Multi-turn dialogue validation
### 🧠 Core Tests (`core/`)
Tests for core smart search functionality:
- **`test_core_smart_search.py`** ⭐ **CORE FUNCTIONALITY**
- Direct testing of smart search answer() method
- Multiple question scenarios
- Strategy validation (SQL, semantic, schema, hybrid)
- **Usage**: `py testing/core/test_core_smart_search.py`
- **`test_smart_search_simple.py`**
- Basic smart search validation
- Single question testing
- Database connection verification
- **`simple_answer_test.py`**
- Legacy smart search testing
- Basic answer API validation
### 🔗 Integration Tests (`integration/`)
Tests for complete system integration:
- **`test_complete_server.py`**
- Full server stack testing
- End-to-end workflow validation
- Multi-service interaction testing
- **`test_mcp.py`**
- MCP protocol compliance testing
- Tool registration and execution
- Client-server communication
### 🏗️ Phase Tests (`phase_tests/`)
Development phase validation tests:
- **`test_phase1.py`** - Repository layer testing
- **`test_phase2.py`** - Service layer and smart search testing
- **`test_phase3.py`** - Production features testing
- **`test_phase4.py`** - Enterprise features testing
### 📚 Legacy Tests (`legacy/`)
Older tests kept for reference:
- **`simple_test.py`** - Basic functionality tests
- **`test_ollama.py`** - Ollama integration tests
- **`test_ollama_mistral.py`** - Mistral model testing
- **`test_llm_chat_tool.py`** - LLM chat tool testing
## Quick Testing Guide
### ⚡ Quick Health Check
```bash
# Test all API endpoints (recommended)
py testing/api/test_all_endpoints_simple.py
# Test core smart search functionality
py testing/core/test_core_smart_search.py
```
### 🔍 Comprehensive Testing
```bash
# Run the test suite (future implementation)
py testing/run_tests.py
# Test specific categories
py testing/run_tests.py --category api
py testing/run_tests.py --category core
py testing/run_tests.py --category integration
```
### 🎯 Targeted Testing
```bash
# Test specific functionality
py testing/core/test_smart_search_simple.py # Basic search
py testing/api/test_streaming.py # Streaming
py testing/api/test_conversation_chat.py # Conversations
py testing/integration/test_complete_server.py # Full stack
```
## Test Requirements
### Prerequisites
- **Python 3.8+**
- **Running services**:
- HTTP Bridge on port 8000
- Smart Search API on port 8002
- Ollama running on port 11434
- **Database access**: PostgreSQL connections configured
- **Required packages**: `requests`, `sqlalchemy`, etc.
### Service Startup
```bash
# Terminal 1: Start HTTP Bridge
py http_bridge.py
# Terminal 2: Start Smart Search API
py smart_search_api.py
# Terminal 3: Run tests
py testing/api/test_all_endpoints_simple.py
```
## Test Results Interpretation
### ✅ Success Indicators
- **Green [PASS]** status for critical endpoints
- **Response times** under 3 seconds
- **Real models detected** from Ollama
- **Database connections** working
- **Memory system** operational
### ⚠️ Warning Signs
- **[WARN]** HTTP status codes (404, 500)
- **Timeout errors** on requests
- **Connection failures** to services
- **Missing models** or empty responses
### ❌ Failure Cases
- **[FAIL]** Critical endpoint failures
- **Service unavailable** errors
- **Database connection** failures
- **Authentication/authorization** errors
## Current Test Status
### Last Test Results (from comprehensive testing):
- **Overall Success Rate**: 94.4% (17/18 endpoints)
- **HTTP Bridge**: 12/13 endpoints working
- **Smart Search API**: 5/5 endpoints working
- **Known Issues**: 1 legacy endpoint (/api/answer) has HTTP 500
- **Performance**: Average 0.44s response time
### Service Health:
- ✅ HTTP Bridge (8000): ONLINE
- ✅ Smart Search API (8002): ONLINE
- ✅ Ollama Models: 5 detected
- ✅ Database Connections: db1, db2, db3 configured
- ✅ Memory System: Operational
- ✅ Smart Search: All strategies working
## Adding New Tests
### Test File Naming Convention
- `test_<feature>.py` for specific features
- `test_<service>_<functionality>.py` for service tests
- `integration_test_<scenario>.py` for integration tests
### Test Organization
Place new tests in appropriate directories:
- **API changes** → `api/`
- **Core logic** → `core/`
- **Service integration** → `integration/`
- **Legacy/experimental** → `legacy/`
### Test Template
```python
#!/usr/bin/env python3
"""
Test description
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
def test_feature():
"""Test specific feature"""
# Test implementation
assert True, "Test passed"
if __name__ == "__main__":
test_feature()
print("✅ Test completed successfully")
```
## Troubleshooting
### Common Issues
1. **Service not running**: Check port availability
2. **Database connection**: Verify config.py settings
3. **Import errors**: Check Python path and dependencies
4. **Timeout errors**: Increase timeout values or check service performance
### Debug Commands
```bash
# Check service status
curl http://localhost:8000/health
curl http://localhost:8002/health
# Check running processes
netstat -an | findstr :8000
netstat -an | findstr :8002
# Test database connection
py -c "from config import Config; print(Config.SQLALCHEMY_BINDS)"
```
---
*For detailed API documentation, see `APP_STRUCTURE.md` in the root directory.*