-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-router.sh
More file actions
executable file
·102 lines (91 loc) · 3.08 KB
/
test-router.sh
File metadata and controls
executable file
·102 lines (91 loc) · 3.08 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
#!/bin/bash
set -e
# Source shared utilities
if [ -z "$SCRIPT_DIR" ]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
fi
# If SCRIPT_DIR is the root directory, we need to source from scripts subdirectory
if [ "$(basename "$SCRIPT_DIR")" = "scripts" ]; then
source "$SCRIPT_DIR/utils.sh"
source "$SCRIPT_DIR/test-utils.sh"
source "$SCRIPT_DIR/port-forward-utils.sh"
else
source "$SCRIPT_DIR/scripts/utils.sh"
source "$SCRIPT_DIR/scripts/test-utils.sh"
source "$SCRIPT_DIR/scripts/port-forward-utils.sh"
fi
# Function to show usage
show_usage() {
echo "Usage: $0 [OPTIONS] [TEST_NAME]"
echo ""
echo "Options:"
echo " -h, --help Show this help message"
echo ""
echo "Test Names:"
echo " basic Test basic infrastructure (scripts, health)"
echo " health Test router health endpoint"
echo " introspection Test GraphQL introspection"
echo " queries Test available queries"
echo " products Test searchProducts query"
echo " product-schema Test product schema"
echo " user Test user query"
echo " users Test allUsers query"
echo " port Test if port 4000 is listening"
echo " status Show router status"
echo " all (default) Run all tests"
echo ""
echo "Examples:"
echo " $0 # Run all tests"
echo " $0 basic # Test basic infrastructure"
echo " $0 products # Test only searchProducts query"
echo " $0 status # Show router status"
echo " $0 --help # Show this help message"
}
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_usage
exit 0
;;
-*)
print_error "Unknown option: $1"
show_usage
exit 1
;;
*)
TEST_NAME="$1"
shift
;;
esac
done
show_script_header "Apollo Router Testing" "Testing Apollo Router functionality"
# Check if minikube is running
if ! minikube_is_running; then
print_error "Minikube is not running. Please start minikube first:"
echo " minikube start"
echo " or run: ./setup-minikube.sh"
exit 1
fi
print_success "Minikube is running"
# Check and setup port forwarding if needed
print_status "Checking port forwarding..."
if ! is_port_forward_running "apollo-router"; then
print_status "Port forwarding not running. Setting up automatically..."
if start_router_port_forward; then
print_success "Port forwarding setup complete"
else
print_error "Failed to setup port forwarding. Please run manually:"
echo " source scripts/port-forward-utils.sh && start_router_port_forward"
exit 1
fi
else
print_success "Port forwarding already running"
fi
# Run the specified test or all tests
if [ -n "$TEST_NAME" ]; then
run_test "$TEST_NAME"
else
run_test "all"
fi
show_script_footer "Apollo Router Testing"