-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathrun-all-tests.sh
More file actions
executable file
·174 lines (151 loc) · 4.44 KB
/
run-all-tests.sh
File metadata and controls
executable file
·174 lines (151 loc) · 4.44 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
# Sentinel Platform - Complete Test Suite Runner
# This script runs all tests (backend + frontend + E2E) in Docker containers
set -e
# 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"
}
# Function to show usage
show_usage() {
echo "Sentinel Platform Test Suite Runner"
echo ""
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -b, --backend-only Run backend tests only"
echo " -f, --frontend-only Run frontend tests only"
echo " -e, --e2e-only Run E2E tests only"
echo " -t, --type TYPE Test type: unit, integration, performance, etc."
echo " -v, --verbose Enable verbose output"
echo " -n, --no-cleanup Skip cleanup after tests"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Run complete test suite"
echo " $0 -b # Run backend tests only"
echo " $0 -f # Run frontend tests only"
echo " $0 -e # Run E2E tests only"
echo " $0 -t unit -v # Run unit tests with verbose output"
echo ""
echo "All tests run in Docker containers for consistency and isolation."
}
# Default values
BACKEND_ONLY=false
FRONTEND_ONLY=false
E2E_ONLY=false
TEST_TYPE=""
VERBOSE=false
NO_CLEANUP=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-b|--backend-only)
BACKEND_ONLY=true
shift
;;
-f|--frontend-only)
FRONTEND_ONLY=true
shift
;;
-e|--e2e-only)
E2E_ONLY=true
shift
;;
-t|--type)
TEST_TYPE="$2"
shift 2
;;
-v|--verbose)
VERBOSE=true
shift
;;
-n|--no-cleanup)
NO_CLEANUP=true
shift
;;
-h|--help)
show_usage
exit 0
;;
*)
print_error "Unknown option: $1"
show_usage
exit 1
;;
esac
done
# Validate that only one test type is selected
selected_count=0
if [ "$BACKEND_ONLY" = true ]; then ((selected_count++)); fi
if [ "$FRONTEND_ONLY" = true ]; then ((selected_count++)); fi
if [ "$E2E_ONLY" = true ]; then ((selected_count++)); fi
if [ $selected_count -gt 1 ]; then
print_error "Cannot specify multiple test type flags simultaneously"
exit 1
fi
print_status "Sentinel Platform Test Suite Runner"
print_status "================================="
# Check if Docker is available
if ! command -v docker &> /dev/null; then
print_error "Docker is not installed or not running"
exit 1
fi
if ! command -v docker-compose &> /dev/null; then
print_error "docker-compose is not installed"
exit 1
fi
# Change to backend directory where docker-compose.test.yml is located
cd sentinel_backend
# Build test runner arguments
TEST_ARGS=""
if [ "$VERBOSE" = true ]; then
TEST_ARGS="$TEST_ARGS -v"
fi
if [ "$NO_CLEANUP" = true ]; then
TEST_ARGS="$TEST_ARGS -n"
fi
if [ -n "$TEST_TYPE" ]; then
TEST_ARGS="$TEST_ARGS -t $TEST_TYPE"
fi
# Always use Docker mode
TEST_ARGS="$TEST_ARGS -d"
# Add specific test type flags
if [ "$BACKEND_ONLY" = true ]; then
TEST_ARGS="$TEST_ARGS -b"
elif [ "$FRONTEND_ONLY" = true ]; then
TEST_ARGS="$TEST_ARGS -f"
elif [ "$E2E_ONLY" = true ]; then
TEST_ARGS="$TEST_ARGS -t e2e"
fi
print_status "Running tests with arguments: $TEST_ARGS"
# Execute the test runner
if ./run_tests.sh $TEST_ARGS; then
print_success "All tests completed successfully!"
# Show coverage reports information
print_status ""
print_status "Test Reports Available:"
print_status "- Backend Coverage: ./sentinel_backend/test_reports/htmlcov/index.html"
print_status "- Frontend Coverage: ./sentinel_frontend/coverage/lcov-report/index.html"
print_status "- E2E Results: ./sentinel_frontend/test-results/"
print_status "- Playwright Report: ./sentinel_frontend/playwright-report/index.html"
else
print_error "Tests failed!"
exit 1
fi
print_success "Test execution completed!"