-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·103 lines (92 loc) · 2.65 KB
/
test.sh
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
#!/bin/bash
print_error () {
echo -e "\033[0;31mError:\033[0m $@"
exit 1
}
print_success () {
echo -e "\033[0;32mCheck passed:\033[0m $@"
}
compare_output () {
if [[ ! -d sequential-outputs ]]; then
print_error "Cannot find directory containing sequential reference outputs"
fi
if [[ ! -d outputs ]]; then
print_error "Cannot find directory containing MapReduce outputs"
fi
SEQ_OUT=$(cat sequential-outputs/mr-out-* | sort)
PAR_OUT=$(cat outputs/mr-out-* | sort)
if ! diff <(echo "$SEQ_OUT") <(echo "$PAR_OUT") --side-by-side --color; then
print_error "Output does not match sequential reference output"
else
print_success "Output is correct"
fi
}
clean_up() {
rm -rf outputs workbench
rm -f pg-*
rm -f mrlog
}
INPUT=
MRAPP=
# Take command-line arguments:
while getopts "f:a:" flag; do
case $flag in
f) INPUT="$OPTARG";;
a) MRAPP="$OPTARG";;
esac
done
# Check that all arguments were provided
if [[ -z "$INPUT" ]]; then
print_error "No input file provided"
fi
if [[ -z "$MRAPP" ]]; then
print_error "No MapReduce application plugin provided"
fi
# Build MapReduce run command (main func in run-mr.go)
go version
echo "Building go-mapreduce"
if ! go build; then
print_error "go build failed"
fi
echo "Running sequential MapReduce to produce reference output"
# Run sequential MapReduce to produce reference output
if ! ./go-mapreduce --input="$INPUT" --functions="$MRAPP" --sequential; then
print_error "Sequential MapReduce failed to run"
fi
# Start running MapReduce tests
# ------------------------------------------------------------------------------
clean_up
echo "Test #1: parallel MapReduce, no crashes"
echo "==="
if ! ./go-mapreduce --input="$INPUT" --functions="$MRAPP" \
--clean=false 2>&1 | tee mrlog; then
print_error "MapReduce failed to run"
fi
echo "Check A: correct output"
compare_output
echo "Check B: no extraneous tasks scheduled"
for i in {0..31}; do
if [[ $(grep -c "Assigned Task $i from Stage map" mrlog) != 1 ]]; then
print_error "Task $i assigned more than once during Stage map"
fi
done
for i in {0..7}; do
if [[ $(grep -c "Assigned Task $i from Stage reduce" mrlog) != 1 ]]; then
print_error "Task $i assigned more than once during Stage reduce"
fi
done
print_success "No extraneous tasks scheduled"
clean_up
echo "==="
echo "Test #2: parallel MapReduce, simulate crashes"
echo "==="
if ! ./go-mapreduce --input="$INPUT" --functions="$MRAPP" \
--clean=false --crash-count=2 2>&1 | tee mrlog; then
print_error "MapReduce failed to run"
fi
echo "Check A: correct output"
compare_output
clean_up
echo "==="
# At end of all tests, remove sequential reference outputs
rm -rf sequential-outputs