|
|
3 ماه پیش | |
|---|---|---|
| .. | ||
| config | 3 ماه پیش | |
| .dockerignore | 3 ماه پیش | |
| Dockerfile.client | 3 ماه پیش | |
| Dockerfile.producer | 3 ماه پیش | |
| Dockerfile.seaweedfs | 3 ماه پیش | |
| Makefile | 3 ماه پیش | |
| README.md | 3 ماه پیش | |
| SETUP_OVERVIEW.md | 3 ماه پیش | |
| client.go | 3 ماه پیش | |
| docker-compose.yml | 3 ماه پیش | |
| producer.go | 3 ماه پیش | |
| run-tests.sh | 3 ماه پیش | |
| validate-setup.sh | 3 ماه پیش | |
This directory contains a comprehensive Docker Compose test setup for the SeaweedFS PostgreSQL wire protocol implementation.
The test suite includes:
./run-tests.sh all
This will automatically:
# Start the services
./run-tests.sh start
# Create test data
./run-tests.sh produce
# Run automated tests
./run-tests.sh test
# Connect with psql for interactive testing
./run-tests.sh psql
# Connect with psql
./run-tests.sh psql
# Inside psql session:
postgres=> SHOW DATABASES;
postgres=> \c analytics;
postgres=> SHOW TABLES;
postgres=> SELECT COUNT(*) FROM user_events;
postgres=> SELECT COUNT(*) FROM user_events;
postgres=> \q
The producer creates realistic test data across multiple namespaces:
user_events (1000 records): User interaction events
system_logs (500 records): System operation logs
metrics (800 records): System metrics
product_views (1200 records): Product interaction data
user_events (600 records): E-commerce specific user events
application_logs (2000 records): Application logserror_logs (300 records): Error-specific logs with 4xx/5xx error codes┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ PostgreSQL │ │ PostgreSQL │ │ SeaweedFS │
│ Clients │◄──►│ Wire Protocol │◄──►│ SQL Engine │
│ (psql, Go) │ │ Server │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌─────────────────┐
│ Session │ │ MQ Broker │
│ Management │ │ & Topics │
└──────────────────┘ └─────────────────┘
lib/pq PostgreSQL driver./run-tests.sh start # Start services
./run-tests.sh produce # Create test data
./run-tests.sh test # Run client tests
./run-tests.sh psql # Interactive psql
./run-tests.sh logs # Show service logs
./run-tests.sh status # Service status
./run-tests.sh stop # Stop services
./run-tests.sh clean # Complete cleanup
./run-tests.sh all # Full automated test
SHOW DATABASES - List MQ namespacesSHOW TABLES - List topics in current namespaceSELECT * FROM table queriesCOUNT(*), SUM(), AVG(), MIN(), MAX()USE database commands_timestamp_ns, _key, _source accessWHERE clauses with comparisonsLIMITAfter running the complete test suite, you should see:
=== Test Results ===
✅ Test PASSED: System Information
✅ Test PASSED: Database Discovery
✅ Test PASSED: Table Discovery
✅ Test PASSED: Data Queries
✅ Test PASSED: Aggregation Queries
✅ Test PASSED: Database Context Switching
✅ Test PASSED: System Columns
✅ Test PASSED: Complex Queries
Test Results: 8/8 tests passed
🎉 All tests passed!
./run-tests.sh psql
-- Check system information
SELECT version();
SELECT current_user, current_database();
-- Discover data structure
SHOW DATABASES;
\c analytics;
SHOW TABLES;
DESCRIBE user_events;
-- Basic queries
SELECT COUNT(*) FROM user_events;
SELECT * FROM user_events LIMIT 5;
-- Aggregations
SELECT
COUNT(*) as events,
AVG(amount) as avg_amount
FROM user_events
WHERE amount IS NOT NULL;
-- Time-based analysis
SELECT
COUNT(*) as count
FROM user_events
WHERE status = 'active';
-- Switch between namespaces
USE ecommerce;
SELECT COUNT(*) FROM product_views;
USE logs;
SELECT COUNT(*) FROM application_logs;
# Check service status
./run-tests.sh status
# View logs
./run-tests.sh logs seaweedfs
./run-tests.sh logs postgres-server
# Recreate test data
./run-tests.sh produce
# Check producer logs
./run-tests.sh logs mq-producer
# Test PostgreSQL server health
docker-compose exec postgres-server nc -z localhost 5432
# Test SeaweedFS health
curl http://localhost:9333/cluster/status
# Complete cleanup and restart
./run-tests.sh clean
./run-tests.sh all
Edit producer.go to change:
Edit client.go to add new test functions:
func testNewFeature(db *sql.DB) error {
// Your test implementation
return nil
}
// Add to tests slice in main()
{"New Feature", testNewFeature},
Use the interactive psql session:
./run-tests.sh psql
This test setup demonstrates:
The test validates that SeaweedFS can serve as a drop-in PostgreSQL replacement for read-only analytics workloads on MQ data.