cleanup and ui change
This commit is contained in:
55
scripts/test-mongodb-connectivity.sh
Executable file
55
scripts/test-mongodb-connectivity.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "=========================================="
|
||||
echo "MongoDB Connectivity Test"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Test 1: MongoDB not accessible from host
|
||||
echo "Test 1: MongoDB port not exposed to host"
|
||||
if nc -z -w 2 localhost 27017 2>&1 | grep -q "succeeded\|open"; then
|
||||
echo "❌ FAIL: Port 27017 is accessible from host"
|
||||
else
|
||||
echo "✅ PASS: Port 27017 is not accessible from host (internal only)"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Test 2: Backend can connect
|
||||
echo "Test 2: Backend can connect to MongoDB"
|
||||
if docker-compose exec -T backend python -c "from database import articles_collection; articles_collection.count_documents({})" &> /dev/null; then
|
||||
echo "✅ PASS: Backend can connect to MongoDB"
|
||||
else
|
||||
echo "❌ FAIL: Backend cannot connect to MongoDB"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Test 3: Crawler can connect
|
||||
echo "Test 3: Crawler can connect to MongoDB"
|
||||
if docker-compose exec -T crawler python -c "from pymongo import MongoClient; from config import Config; MongoClient(Config.MONGODB_URI).server_info()" &> /dev/null; then
|
||||
echo "✅ PASS: Crawler can connect to MongoDB"
|
||||
else
|
||||
echo "❌ FAIL: Crawler cannot connect to MongoDB"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Test 4: Sender can connect
|
||||
echo "Test 4: Sender can connect to MongoDB"
|
||||
if docker-compose exec -T sender python -c "from pymongo import MongoClient; import os; MongoClient(os.getenv('MONGODB_URI')).server_info()" &> /dev/null; then
|
||||
echo "✅ PASS: Sender can connect to MongoDB"
|
||||
else
|
||||
echo "❌ FAIL: Sender cannot connect to MongoDB"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Test 5: Backend API accessible
|
||||
echo "Test 5: Backend API accessible from host"
|
||||
if curl -s http://localhost:5001/health | grep -q "healthy"; then
|
||||
echo "✅ PASS: Backend API is accessible"
|
||||
else
|
||||
echo "❌ FAIL: Backend API is not accessible"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo "Test Complete"
|
||||
echo "=========================================="
|
||||
Reference in New Issue
Block a user