This commit completes the Rust implementation of mail2couch with full feature parity to the Go version, including: - Complete IMAP client with TLS support and retry logic - Advanced email parsing with MIME multipart support using mail-parser - Email attachment extraction and CouchDB storage - Sync mode implementation with deleted message handling - Enhanced error handling and retry mechanisms - Identical command-line interface with bash completion - Test configurations for both implementations The Rust implementation now provides: - Memory safety and type safety guarantees - Modern async/await patterns with tokio/async-std - Comprehensive error handling with anyhow/thiserror - Structured logging and progress reporting - Performance optimizations and retry logic Test configurations created: - rust/config-test-rust.json - Rust implementation test config - go/config-test-go.json - Go implementation test config - test-config-comparison.md - Detailed comparison documentation - test-both-implementations.sh - Automated testing script Both implementations can now be tested side-by-side with identical configurations to validate feature parity and performance. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
122 lines
No EOL
3.9 KiB
Bash
Executable file
122 lines
No EOL
3.9 KiB
Bash
Executable file
#!/bin/bash
|
|
# Test script to run both Rust and Go implementations with their respective configs
|
|
# This demonstrates feature parity between the implementations
|
|
|
|
set -e
|
|
|
|
echo "🧪 Testing both Rust and Go implementations with identical configurations"
|
|
echo "=================================================="
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Check if test environment is running
|
|
check_test_env() {
|
|
echo -e "${BLUE}📡 Checking test environment...${NC}"
|
|
|
|
if ! curl -s http://localhost:5984 >/dev/null; then
|
|
echo -e "${YELLOW}⚠️ Test environment not running. Starting it...${NC}"
|
|
cd test
|
|
./start-test-env.sh
|
|
cd ..
|
|
echo -e "${GREEN}✅ Test environment started${NC}"
|
|
else
|
|
echo -e "${GREEN}✅ Test environment is running${NC}"
|
|
fi
|
|
}
|
|
|
|
# Build both implementations
|
|
build_implementations() {
|
|
echo -e "${BLUE}🔨 Building implementations...${NC}"
|
|
|
|
# Build Go implementation
|
|
echo -e "${BLUE} Building Go implementation...${NC}"
|
|
cd go
|
|
go build -o mail2couch .
|
|
cd ..
|
|
echo -e "${GREEN} ✅ Go implementation built${NC}"
|
|
|
|
# Build Rust implementation
|
|
echo -e "${BLUE} Building Rust implementation...${NC}"
|
|
cd rust
|
|
cargo build --release
|
|
cd ..
|
|
echo -e "${GREEN} ✅ Rust implementation built${NC}"
|
|
}
|
|
|
|
# Run Go implementation
|
|
run_go() {
|
|
echo -e "${BLUE}🦬 Running Go implementation...${NC}"
|
|
cd go
|
|
echo -e "${BLUE} Using config: config-test-go.json${NC}"
|
|
./mail2couch -c config-test-go.json
|
|
cd ..
|
|
echo -e "${GREEN}✅ Go implementation completed${NC}"
|
|
}
|
|
|
|
# Run Rust implementation
|
|
run_rust() {
|
|
echo -e "${BLUE}🦀 Running Rust implementation...${NC}"
|
|
cd rust
|
|
echo -e "${BLUE} Using config: config-test-rust.json${NC}"
|
|
./target/release/mail2couch -c config-test-rust.json
|
|
cd ..
|
|
echo -e "${GREEN}✅ Rust implementation completed${NC}"
|
|
}
|
|
|
|
# Check results
|
|
check_results() {
|
|
echo -e "${BLUE}🔍 Checking results...${NC}"
|
|
|
|
echo -e "${BLUE} Listing all databases:${NC}"
|
|
curl -s http://localhost:5984/_all_dbs | python3 -m json.tool
|
|
|
|
echo -e "\n${BLUE} Go implementation databases:${NC}"
|
|
for db in go_wildcard_all_folders_test go_work_pattern_test go_specific_folders_only; do
|
|
db_name="m2c_${db}"
|
|
if curl -s "http://localhost:5984/${db_name}" >/dev/null 2>&1; then
|
|
doc_count=$(curl -s "http://localhost:5984/${db_name}" | python3 -c "import sys, json; print(json.load(sys.stdin).get('doc_count', 0))")
|
|
echo -e "${GREEN} ✅ ${db_name}: ${doc_count} documents${NC}"
|
|
else
|
|
echo -e "${RED} ❌ ${db_name}: not found${NC}"
|
|
fi
|
|
done
|
|
|
|
echo -e "\n${BLUE} Rust implementation databases:${NC}"
|
|
for db in rust_wildcard_all_folders_test rust_work_pattern_test rust_specific_folders_only; do
|
|
db_name="m2c_${db}"
|
|
if curl -s "http://localhost:5984/${db_name}" >/dev/null 2>&1; then
|
|
doc_count=$(curl -s "http://localhost:5984/${db_name}" | python3 -c "import sys, json; print(json.load(sys.stdin).get('doc_count', 0))")
|
|
echo -e "${GREEN} ✅ ${db_name}: ${doc_count} documents${NC}"
|
|
else
|
|
echo -e "${RED} ❌ ${db_name}: not found${NC}"
|
|
fi
|
|
done
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
echo -e "${YELLOW}🚀 Starting feature parity test...${NC}"
|
|
|
|
check_test_env
|
|
build_implementations
|
|
|
|
echo -e "\n${YELLOW}📊 Running implementations with identical configurations...${NC}"
|
|
run_go
|
|
echo ""
|
|
run_rust
|
|
|
|
echo -e "\n${YELLOW}📈 Checking results...${NC}"
|
|
check_results
|
|
|
|
echo -e "\n${GREEN}🎉 Feature parity test completed!${NC}"
|
|
echo -e "${BLUE}💡 Both implementations should have created similar databases with identical message counts.${NC}"
|
|
echo -e "${BLUE}🔗 View results at: http://localhost:5984/_utils${NC}"
|
|
}
|
|
|
|
# Execute main function
|
|
main "$@" |