-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe2e-test.sh
More file actions
executable file
Β·136 lines (121 loc) Β· 3.78 KB
/
Copy pathe2e-test.sh
File metadata and controls
executable file
Β·136 lines (121 loc) Β· 3.78 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
#!/bin/bash
# End-to-end test suite for fastn-p2p
# Runs all integration tests to verify P2P functionality
# Usage: ./e2e-test.sh [--quiet] [--retry]
# --quiet: Minimal output (only show results and performance)
# --retry: Enable retry on discovery failures
set -e # Exit on error
# Parse command line arguments
QUIET_FLAG=""
RETRY_FLAG=""
for arg in "$@"; do
case $arg in
--quiet|-q)
QUIET_FLAG="--quiet"
;;
--retry)
RETRY_FLAG="--retry"
;;
--help|-h)
echo "Usage: $0 [--quiet|-q] [--retry]"
echo " --quiet, -q Minimal output (only show results and performance)"
echo " --retry Enable retry on discovery failures"
echo " --help, -h Show this help message"
exit 0
;;
-*)
echo "Error: Unknown option $arg"
echo "Usage: $0 [--quiet|-q] [--retry]"
exit 1
;;
*)
echo "Error: Unexpected argument $arg"
echo "Usage: $0 [--quiet|-q] [--retry]"
exit 1
;;
esac
done
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
BOLD='\033[1m'
if [ -z "$QUIET_FLAG" ]; then
echo -e "${BOLD}${YELLOW}π§ͺ fastn-p2p End-to-End Test Suite${NC}"
echo "========================================"
echo ""
fi
# Track test results
TESTS_PASSED=0
TESTS_FAILED=0
# Function to run a test script
run_test() {
local test_name=$1
local test_script=$2
if [ -z "$QUIET_FLAG" ]; then
echo -e "${YELLOW}π¦ Running ${test_name}...${NC}"
echo "----------------------------------------"
fi
if bash "$test_script" $QUIET_FLAG $RETRY_FLAG; then
if [ -z "$QUIET_FLAG" ]; then
echo -e "${GREEN}β
${test_name} PASSED${NC}"
fi
((TESTS_PASSED++))
else
echo -e "${RED}β ${test_name} FAILED${NC}"
((TESTS_FAILED++))
fi
if [ -z "$QUIET_FLAG" ]; then
echo ""
fi
}
# Pre-build everything once to save time
if [ -z "$QUIET_FLAG" ]; then
echo -e "${YELLOW}π¦ Pre-building all binaries...${NC}"
cargo build --release --all 2>&1 | tail -5
echo -e "${GREEN}β
Build complete${NC}"
echo ""
else
cargo build --release --all >/dev/null 2>&1
fi
# Run all test suites
run_test "Request-Response Pattern" "./scripts/test-request-response.sh"
run_test "File Transfer (Streaming)" "./scripts/test-file-transfer.sh"
if [ -f "./scripts/test-shell-simple.sh" ]; then
run_test "Remote Shell (Simple)" "./scripts/test-shell-simple.sh"
fi
if [ -f "./scripts/test-media-stream.sh" ]; then
run_test "Media Stream (Audio)" "./scripts/test-media-stream.sh"
fi
# Summary
if [ -n "$QUIET_FLAG" ]; then
# Quiet mode - just show pass/fail
if [ $TESTS_FAILED -eq 0 ]; then
echo -e "${GREEN}β
All tests passed (${TESTS_PASSED}/${TESTS_PASSED})${NC}"
else
echo -e "${RED}β Tests failed (${TESTS_PASSED} passed, ${TESTS_FAILED} failed)${NC}"
fi
else
echo "========================================"
echo -e "${BOLD}π Test Summary${NC}"
echo "----------------------------------------"
echo -e "Passed: ${GREEN}${TESTS_PASSED}${NC}"
echo -e "Failed: ${RED}${TESTS_FAILED}${NC}"
fi
if [ $TESTS_FAILED -eq 0 ]; then
if [ -z "$QUIET_FLAG" ]; then
echo ""
echo -e "${GREEN}${BOLD}π All tests passed!${NC}"
echo ""
echo -e "${YELLOW}${BOLD}Note:${NC} Each test includes detailed performance metrics at the end."
echo "Look for the π Performance Metrics section in each test output above."
fi
exit 0
else
if [ -z "$QUIET_FLAG" ]; then
echo ""
fi
echo -e "${RED}${BOLD}β οΈ Some tests failed${NC}"
exit 1
fi