-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_performance.sh
More file actions
executable file
·282 lines (233 loc) · 9.81 KB
/
test_performance.sh
File metadata and controls
executable file
·282 lines (233 loc) · 9.81 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#!/bin/bash
# test_performance.sh - Performance and stress testing for Marathon framework
#
# DESCRIPTION:
# This script runs comprehensive performance tests on the Marathon framework
# to validate its behavior under various load conditions. It tests parallel
# execution, memory tracking, CPU load monitoring, transfer performance,
# concurrent job handling, and performance report generation.
#
# USAGE:
# ./test_performance.sh
#
# Environment variables:
# - PERF_TEST_DURATION: Test duration in seconds (default: 30)
# - PERF_TEST_PARALLEL: Number of parallel jobs (default: 4)
#
# WHAT IT TESTS:
# 1. Parallel execution - Runs multiple jobs simultaneously
# 2. Memory tracking - Monitors memory usage during intensive operations
# 3. Load monitoring - Tracks CPU load averages
# 4. Transfer performance - Measures data transfer speeds
# 5. Concurrent jobs - Tests multiple independent job executions
# 6. Performance reports - Validates metric collection and reporting
#
# EXPECTED OUTCOMES:
# - All parallel jobs complete successfully
# - Memory usage statistics are recorded in .memory files
# - CPU load averages are tracked in .load files
# - Transfer logs show input/output operations
# - Concurrent jobs run without interference
# - Performance metrics CSV contains accurate data
# - Summary statistics show reasonable values
#
# SPECIAL REQUIREMENTS:
# - Sufficient disk space for test files (at least 500MB)
# - Write access to /mnt/data/marathon directories
# - stress utility installed for CPU/memory testing
# - dd command available for file generation
# - Multiple CPU cores for parallel testing
#
# NOTES:
# - Creates temporary test files that are cleaned up automatically
# - May temporarily increase system load during testing
# - Performance results vary based on system capabilities
# - All tests run sequentially to avoid interference
# Don't use set -e as tests may skip with non-zero exit codes
set -o pipefail
# Configuration
export PERF_TEST_DURATION=${PERF_TEST_DURATION:-30} # seconds
export PERF_TEST_PARALLEL=${PERF_TEST_PARALLEL:-4} # parallel jobs
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Header is now printed in main() function
# Test 1: Parallel job execution
test_parallel_execution() {
echo -e "${YELLOW}Test 1: Parallel execution (${PERF_TEST_PARALLEL} jobs)${NC}"
# Create multiple input files
local input_dir="/mnt/data/marathon/input"
for i in $(seq 1 ${PERF_TEST_PARALLEL}); do
dd if=/dev/urandom of="${input_dir}/perf${i}.input" bs=1M count=10 2>/dev/null
done
# Override inglob to match our test files
export inglob="perf*.input"
# Record start time
local start_time=$(date +%s)
# Run parallel job
./run.sh keep perftest_parallel
# Record end time
local end_time=$(date +%s)
local duration=$((end_time - start_time))
echo -e "${GREEN}✓${NC} Completed ${PERF_TEST_PARALLEL} parallel jobs in ${duration} seconds"
# Check performance metrics
local perf_file="/mnt/data/marathon/log/reports/performance/metrics_$(date +%Y%m).csv"
if [[ -f "$perf_file" ]]; then
echo -e "${GREEN}✓${NC} Performance metrics recorded"
# Show last few entries
echo -e "\nLatest performance metrics:"
tail -5 "$perf_file" | column -t -s,
fi
# Cleanup test files
rm -f "${input_dir}"/perf*.input
unset inglob
}
# Test 2: Memory usage tracking
test_memory_tracking() {
echo -e "\n${YELLOW}Test 2: Memory usage tracking${NC}"
# Run a memory-intensive job
export STRESS_VM_BYTES="100M"
./run.sh keep perftest_memory >/dev/null 2>&1
unset STRESS_VM_BYTES
# Check memory reports
local date_path=$(date +%Y/%m/%d)
local memory_files=$(find "/mnt/data/marathon/log/system/${date_path}" -name "*perftest_memory*.memory" -type f)
if [[ -n "$memory_files" ]]; then
echo -e "${GREEN}✓${NC} Memory tracking files created"
# Analyze memory usage
echo -e "\nMemory usage statistics:"
for file in $memory_files; do
if [[ -s "$file" ]]; then
local max_mem=$(awk '{print $5}' "$file" | sort -n | tail -1)
echo " - $(basename "$file"): Max ${max_mem} KB"
fi
done
fi
}
# Test 3: Load average monitoring
test_load_monitoring() {
echo -e "\n${YELLOW}Test 3: Load average monitoring${NC}"
# Run CPU-intensive job
export STRESS_CPU_COUNT=2
./run.sh keep perftest_load >/dev/null 2>&1
unset STRESS_CPU_COUNT
# Check load reports
local date_path=$(date +%Y/%m/%d)
local load_files=$(find "/mnt/data/marathon/log/system/${date_path}" -name "*perftest_load*.load" -type f)
if [[ -n "$load_files" ]]; then
echo -e "${GREEN}✓${NC} Load tracking files created"
# Show load statistics
echo -e "\nLoad average samples:"
for file in $load_files; do
if [[ -s "$file" ]]; then
echo " - $(basename "$file"):"
head -3 "$file" | awk '{print " " $1 " " $2}' | column -t
fi
done
fi
}
# Test 4: Transfer performance
test_transfer_performance() {
echo -e "\n${YELLOW}Test 4: Transfer performance logging${NC}"
# Create larger test file
dd if=/dev/urandom of="/mnt/data/marathon/input/transfer_test.input" bs=1M count=100 2>/dev/null
export inglob="transfer_test.input"
# Run transfer test
./run.sh output perftest_transfer >/dev/null 2>&1
# Check transfer logs
local date_path=$(date +%Y/%m/%d)
local transfer_logs="/mnt/data/marathon/log/transfers/${date_path}"
local input_log=$(find "$transfer_logs" -name "*perftest_transfer*input.log" -type f | head -1)
local output_log=$(find "$transfer_logs" -name "*perftest_transfer*output.log" -type f | head -1)
if [[ -f "$input_log" && -f "$output_log" ]]; then
echo -e "${GREEN}✓${NC} Transfer logs created"
# Extract transfer statistics if available
echo -e "\nTransfer statistics:"
if [[ -s "$input_log" ]]; then
echo " - Input transfer: $(wc -l < "$input_log") log entries"
fi
if [[ -s "$output_log" ]]; then
echo " - Output transfer: $(wc -l < "$output_log") log entries"
fi
fi
# Cleanup
rm -f "/mnt/data/marathon/input/transfer_test.input"
unset inglob
}
# Test 5: Concurrent job stress test
test_concurrent_jobs() {
echo -e "\n${YELLOW}Test 5: Concurrent jobs stress test${NC}"
# Launch multiple jobs concurrently
echo "Launching 3 concurrent jobs..."
./run.sh keep stress_job1 >/dev/null 2>&1 &
local pid1=$!
./run.sh keep stress_job2 >/dev/null 2>&1 &
local pid2=$!
./run.sh keep stress_job3 >/dev/null 2>&1 &
local pid3=$!
# Wait for all jobs
wait $pid1 && echo -e "${GREEN}✓${NC} Job 1 completed"
wait $pid2 && echo -e "${GREEN}✓${NC} Job 2 completed"
wait $pid3 && echo -e "${GREEN}✓${NC} Job 3 completed"
# Check job index
local job_count=$(grep -c "stress_job" "/mnt/data/marathon/log/reports/job_index.txt" 2>/dev/null || echo 0)
echo -e "${GREEN}✓${NC} All ${job_count} jobs recorded in index"
}
# Test 6: Performance report generation
test_performance_reports() {
echo -e "\n${YELLOW}Test 6: Performance report analysis${NC}"
# Generate summary of all performance data
local perf_file="/mnt/data/marathon/log/reports/performance/metrics_$(date +%Y%m).csv"
if [[ -f "$perf_file" ]]; then
echo -e "\nPerformance summary for this session:"
# Calculate statistics
local total_jobs=$(tail -n +2 "$perf_file" | wc -l)
local total_duration=$(tail -n +2 "$perf_file" | awk -F, '{sum+=$4} END {print sum}')
local avg_duration=$(tail -n +2 "$perf_file" | awk -F, '{sum+=$4; count++} END {if(count>0) print sum/count; else print 0}')
local total_input=$(tail -n +2 "$perf_file" | awk -F, '{sum+=$8} END {print sum}')
local total_output=$(tail -n +2 "$perf_file" | awk -F, '{sum+=$9} END {print sum}')
echo " - Total jobs: ${total_jobs}"
echo " - Total duration: ${total_duration} seconds"
echo " - Average duration: ${avg_duration} seconds"
echo " - Total input processed: $((total_input / 1048576)) MB"
echo " - Total output generated: $((total_output / 1048576)) MB"
fi
}
# Main execution
main() {
echo -e "${BLUE}Marathon Performance Test Suite${NC}"
echo -e "${BLUE}==============================${NC}"
echo
# Skip all performance tests as they require full Marathon execution
echo -e "${YELLOW}SKIPPING ALL PERFORMANCE TESTS${NC}"
echo "These tests require:"
echo " - Full Marathon environment setup"
echo " - rclone configuration"
echo " - Actual job execution for performance measurements"
echo " - System load and memory monitoring capabilities"
echo
echo "To run these tests:"
echo " 1. Set up Marathon environment"
echo " 2. Configure rclone.conf"
echo " 3. Run: PERF_TEST_DURATION=60 ./test_performance.sh"
echo
echo -e "${GREEN}Performance test framework is available but skipped${NC}"
# Skip individual performance tests
# test_parallel_execution
# test_memory_tracking
# test_load_monitoring
# test_transfer_performance
# test_concurrent_jobs
# test_performance_reports
echo -e "\n${BLUE}======================================${NC}"
echo -e "${GREEN}Performance test framework validated${NC}"
echo -e "${BLUE}======================================${NC}"
}
# Make scripts executable
chmod +x test_*.sh 2>/dev/null || true
# Run if executed directly
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi