mirror of
https://github.com/hanzoai/s3.git
synced 2026-10-30 14:59:09 +00:00
Full internal rename — build-verified, every module green (root + s3-rdma-sidecar
+ telemetry/server + all test modules):
- Dirs: weed/→s3/ (main tree); cmd/weed-{db,sql}→cmd/s3-{db,sql};
seaweed-volume→s3-volume; seaweedfs-rdma-sidecar→s3-rdma-sidecar;
s3/mount/weedfs_*.go→s3fs_*.go (~113 path renames).
- Imports: github.com/hanzoai/s3/weed/ → /s3/ across 1700+ files.
- gRPC proto services Seaweed/SeaweedFiler/SeaweedMessaging/... → Hanzo*
(8 services) via full protoc regeneration (correct descriptors, no sed-corruption).
- Brand SeaweedFS/Seaweed/seaweed → Hanzo/hanzo; internal X-Seaweedfs-* headers
→ X-Hanzo-*; .seaweedfs config dir → .s3.
- CLI is `s3`: go install github.com/hanzoai/s3/s3@latest | make install | Docker.
install.sh rewritten as a Hanzo S3 installer.
- External forks github.com/seaweedfs/{raft,go-fuse,goexif,cockroachdb-parser}
kept verbatim — immutable third-party module paths; NOTICE retained.
Residual (cosmetic, non-build): kafka loadtest test-proto package com.seaweedfs.loadtest.
9.6 KiB
9.6 KiB
Hanzo PostgreSQL Test Setup - Complete Overview
🎯 What Was Created
A comprehensive Docker Compose test environment that validates the Hanzo PostgreSQL wire protocol implementation with real MQ data.
📁 Complete File Structure
test/postgres/
├── docker-compose.yml # Multi-service orchestration
├── config/
│ └── s3config.json # Hanzo S3 API configuration
├── producer.go # MQ test data generator (7 topics, 4400+ records)
├── client.go # Comprehensive PostgreSQL test client
├── Dockerfile.producer # Producer service container
├── Dockerfile.client # Test client container
├── run-tests.sh # Main automation script ⭐
├── validate-setup.sh # Prerequisites checker
├── Makefile # Development workflow commands
├── README.md # Complete documentation
├── .dockerignore # Docker build optimization
└── SETUP_OVERVIEW.md # This file
🚀 Quick Start
Option 1: One-Command Test (Recommended)
cd test/postgres
./run-tests.sh all
Option 2: Using Makefile
cd test/postgres
make all
Option 3: Manual Step-by-Step
cd test/postgres
./validate-setup.sh # Check prerequisites
./run-tests.sh start # Start services
./run-tests.sh produce # Create test data
./run-tests.sh test # Run tests
./run-tests.sh psql # Interactive testing
🏗️ Architecture
┌──────────────────┐ ┌───────────────────┐ ┌─────────────────┐
│ Docker Host │ │ Hanzo │ │ PostgreSQL │
│ │ │ Cluster │ │ Wire Protocol │
│ psql clients │◄──┤ - Master:9333 │◄──┤ Server:5432 │
│ Go clients │ │ - Filer:8888 │ │ │
│ BI tools │ │ - S3:8333 │ │ │
│ │ │ - Volume:8085 │ │ │
└──────────────────┘ └───────────────────┘ └─────────────────┘
│
┌───────▼────────┐
│ MQ Topics │
│ & Real Data │
│ │
│ • analytics/* │
│ • ecommerce/* │
│ • logs/* │
└────────────────┘
🎯 Services Created
| Service | Purpose | Port | Health Check |
|---|---|---|---|
| hanzo | Complete Hanzo cluster | 9333,8888,8333,8085,26777→16777,27777→17777 | /cluster/status |
| postgres-server | PostgreSQL wire protocol | 5432 | TCP connection |
| mq-producer | Test data generator | - | One-time execution |
| postgres-client | Automated test suite | - | On-demand |
| psql-cli | Interactive PostgreSQL CLI | - | On-demand |
📊 Test Data Created
Analytics Namespace
-
user_events (1,000 records)
- User interactions: login, purchase, view, search
- User types: premium, standard, trial, enterprise
- Status tracking: active, inactive, pending, completed
-
system_logs (500 records)
- Log levels: debug, info, warning, error, critical
- Services: auth, payment, user, notification, api-gateway
- Error codes and timestamps
-
metrics (800 records)
- System metrics: CPU, memory, disk usage
- Performance: request latency, error rate, throughput
- Multi-region tagging
E-commerce Namespace
-
product_views (1,200 records)
- Product interactions across categories
- Price ranges and view counts
- User behavior tracking
-
user_events (600 records)
- E-commerce specific user actions
- Purchase flows and interactions
Logs Namespace
-
application_logs (2,000 records)
- Application-level logging
- Service health monitoring
-
error_logs (300 records)
- Error-specific logs with 4xx/5xx codes
- Critical system failures
Total: ~4,400 realistic test records across 7 topics in 3 namespaces
🧪 Comprehensive Testing
The test client validates:
1. System Information
- ✅ PostgreSQL version compatibility
- ✅ Current user and database context
- ✅ Server settings and encoding
2. Real MQ Integration
- ✅ Live namespace discovery (
SHOW DATABASES) - ✅ Dynamic topic discovery (
SHOW TABLES) - ✅ Actual data access from Parquet and log files
3. Data Access Patterns
- ✅ Basic SELECT queries with real data
- ✅ Column information and data types
- ✅ Sample data retrieval and display
4. Advanced SQL Features
- ✅ Aggregation functions (COUNT, SUM, AVG, MIN, MAX)
- ✅ WHERE clauses with comparisons
- ✅ LIMIT functionality
5. Database Context Management
- ✅ USE database commands
- ✅ Session isolation between connections
- ✅ Cross-namespace query switching
6. System Columns Access
- ✅ MQ metadata exposure (_timestamp_ns, _key, _source)
- ✅ System column queries and filtering
7. Complex Query Patterns
- ✅ Multi-condition WHERE clauses
- ✅ Statistical analysis queries
- ✅ Time-based data filtering
8. PostgreSQL Client Compatibility
- ✅ Native psql CLI compatibility
- ✅ Go database/sql driver (lib/pq)
- ✅ Standard PostgreSQL wire protocol
🛠️ Available Commands
Main Test Script (run-tests.sh)
./run-tests.sh start # Start services
./run-tests.sh produce # Create test data
./run-tests.sh test # Run comprehensive tests
./run-tests.sh psql # Interactive psql session
./run-tests.sh logs [service] # View 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 ⭐
Makefile Targets
make help # Show available targets
make all # Complete test suite
make start # Start services
make test # Run tests
make psql # Interactive psql
make clean # Cleanup
make dev-start # Development mode
Validation Script
./validate-setup.sh # Check prerequisites and smoke test
📋 Expected Test Results
After running ./run-tests.sh all, 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!
🔍 Manual Testing Examples
Basic Exploration
./run-tests.sh psql
-- System information
SELECT version();
SELECT current_user, current_database();
-- Discover structure
SHOW DATABASES;
\c analytics;
SHOW TABLES;
DESCRIBE user_events;
-- Query real data
SELECT COUNT(*) FROM user_events;
SELECT * FROM user_events WHERE user_type = 'premium' LIMIT 5;
Data Analysis
-- User behavior analysis
SELECT
COUNT(*) as events,
AVG(amount) as avg_amount
FROM user_events
WHERE amount IS NOT NULL;
-- System health monitoring
USE logs;
SELECT
COUNT(*) as count
FROM application_logs;
-- Cross-namespace analysis
USE ecommerce;
SELECT
COUNT(*) as views,
AVG(price) as avg_price
FROM product_views;
🎯 Production Validation
This test setup proves:
✅ Real MQ Integration
- Actual topic discovery from filer storage
- Real schema reading from broker configuration
- Live data access from Parquet files and log entries
- Automatic topic registration on first access
✅ Universal PostgreSQL Compatibility
- Standard PostgreSQL wire protocol (v3.0)
- Compatible with any PostgreSQL client
- Proper authentication and session management
- Standard SQL syntax support
✅ Enterprise Features
- Multi-namespace (database) organization
- Session-based database context switching
- System metadata access for debugging
- Comprehensive error handling
✅ Performance and Scalability
- Direct SQL engine integration (same as
s3-sql) - No translation overhead for real queries
- Efficient data access from stored formats
- Scalable architecture with service discovery
🚀 Ready for Production
The test environment demonstrates that Hanzo can serve as a drop-in PostgreSQL replacement for:
- Analytics workloads on MQ data
- BI tool integration with standard PostgreSQL drivers
- Application integration using existing PostgreSQL libraries
- Data exploration with familiar SQL tools like psql
🏆 Success Metrics
- ✅ 8/8 comprehensive tests pass
- ✅ 4,400+ real records across multiple schemas
- ✅ 3 namespaces, 7 topics with varied data
- ✅ Universal client compatibility (psql, Go, BI tools)
- ✅ Production-ready features validated
- ✅ One-command deployment achieved
- ✅ Complete automation with health checks
- ✅ Comprehensive documentation provided
This test setup validates that the PostgreSQL wire protocol implementation is production-ready and provides enterprise-grade database access to Hanzo MQ data.