114 lines
3.0 KiB
Python
114 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Run All RabbitMQ Tests
|
|
This script runs all individual test files in sequence.
|
|
"""
|
|
|
|
import asyncio
|
|
import sys
|
|
import os
|
|
import subprocess
|
|
|
|
# Add current directory to Python path
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
def run_test_file(test_file):
|
|
"""Run a test file and return success status"""
|
|
try:
|
|
print(f"\n{'='*60}")
|
|
print(f"Running {test_file}")
|
|
print(f"{'='*60}")
|
|
|
|
result = subprocess.run([sys.executable, test_file],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=30)
|
|
|
|
if result.returncode == 0:
|
|
print(f"✅ {test_file} completed successfully")
|
|
if result.stdout:
|
|
print("Output:")
|
|
print(result.stdout)
|
|
return True
|
|
else:
|
|
print(f"❌ {test_file} failed with return code {result.returncode}")
|
|
if result.stderr:
|
|
print("Error:")
|
|
print(result.stderr)
|
|
return False
|
|
|
|
except subprocess.TimeoutExpired:
|
|
print(f"⏰ {test_file} timed out after 30 seconds")
|
|
return False
|
|
except Exception as e:
|
|
print(f"💥 {test_file} failed with exception: {e}")
|
|
return False
|
|
|
|
|
|
def main():
|
|
"""Main function to run all tests"""
|
|
print("🚀 Starting RabbitMQ Test Suite")
|
|
print("This will run all individual test files in sequence.")
|
|
|
|
# List of test files to run
|
|
test_files = [
|
|
"run_fanout_test.py",
|
|
"run_direct_test.py",
|
|
"run_topic_test.py",
|
|
"run_multi_queue_test.py"
|
|
]
|
|
|
|
# Check if test files exist
|
|
missing_files = []
|
|
for test_file in test_files:
|
|
if not os.path.exists(test_file):
|
|
missing_files.append(test_file)
|
|
|
|
if missing_files:
|
|
print(f"❌ Missing test files: {missing_files}")
|
|
sys.exit(1)
|
|
|
|
# Run all tests
|
|
results = []
|
|
for test_file in test_files:
|
|
success = run_test_file(test_file)
|
|
results.append((test_file, success))
|
|
|
|
# Wait between tests
|
|
if test_file != test_files[-1]: # Don't wait after last test
|
|
print("\n⏳ Waiting 2 seconds before next test...")
|
|
import time
|
|
time.sleep(2)
|
|
|
|
# Print summary
|
|
print(f"\n{'='*60}")
|
|
print("TEST SUMMARY")
|
|
print(f"{'='*60}")
|
|
|
|
passed = 0
|
|
failed = 0
|
|
|
|
for test_file, success in results:
|
|
status = "✅ PASSED" if success else "❌ FAILED"
|
|
print(f"{test_file:<25} {status}")
|
|
if success:
|
|
passed += 1
|
|
else:
|
|
failed += 1
|
|
|
|
print(f"\nTotal: {len(results)} tests")
|
|
print(f"Passed: {passed}")
|
|
print(f"Failed: {failed}")
|
|
|
|
if failed == 0:
|
|
print("\n🎉 All tests passed!")
|
|
sys.exit(0)
|
|
else:
|
|
print(f"\n💥 {failed} test(s) failed!")
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|