-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·98 lines (74 loc) · 2.25 KB
/
run-tests.sh
File metadata and controls
executable file
·98 lines (74 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
set -e
echo "🚀 Starting HTTP Runner Test Environment..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Clean up function
cleanup() {
print_status "Cleaning up containers..."
docker-compose down -v 2>/dev/null || true
docker system prune -f 2>/dev/null || true
}
# Set trap to cleanup on script exit
trap cleanup EXIT
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
print_error "Docker is not running. Please start Docker and try again."
exit 1
fi
# Check if Docker Compose is available
if ! command -v docker compose > /dev/null 2>&1; then
print_error "docker compose is not installed. Please install docker-compose and try again."
exit 1
fi
print_status "Building and starting services..."
# Build and start services
docker compose up --wait --wait-timeout 300 --build --remove-orphans -d testapi toxiproxy
print_status "Waiting for services to be healthy..."
print_status "Services status:"
docker ps
# Create reports directory if it doesn't exist
mkdir -p reports
print_status "Starting comprehensive tests..."
# Run the HTTP Runner tests
if docker compose up --build httprunner; then
print_success "✅ All tests completed successfully!"
print_status "Test results are available in the reports/ directory:"
print_status "Container logs:"
echo "=== Test API Logs ==="
docker logs testapi
echo ""
echo "=== HTTP Runner Logs ==="
docker logs httprunner
else
print_error "❌ Tests failed!"
print_status "Container logs for debugging:"
echo "=== Test API Logs ==="
docker logs testapi
echo ""
echo "=== Toxiproxy Logs ==="
docker logs toxiproxy
echo ""
echo "=== HTTP Runner Logs ==="
docker logs httprunner
exit 1
fi
print_success "🎉 Test environment completed successfully!"
print_status "You can view the HTML report by opening reports/test-results.html in your browser"