This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-all.sh
193 lines (167 loc) · 6.81 KB
/
test-all.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
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
#!/bin/bash
# test_hdfs.sh
function test_hdfs_q1() {
docker-compose -f cs511p1-compose.yaml exec main hdfs dfsadmin -report >&2
}
function test_hdfs_q2() {
docker compose -f cs511p1-compose.yaml cp resources/fox.txt main:/test_fox.txt
docker-compose -f cs511p1-compose.yaml exec main bash -x -c '\
hdfs dfs -mkdir -p /test; \
hdfs dfs -put -f /test_fox.txt /test/fox.txt; \
hdfs dfs -cat /test/fox.txt'
}
function test_hdfs_q3() {
docker-compose -f cs511p1-compose.yaml exec main bash -x -c '\
hadoop org.apache.hadoop.hdfs.server.namenode.NNThroughputBenchmark -fs hdfs://main:9000 -op create -threads 100 -files 10000; \
hadoop org.apache.hadoop.hdfs.server.namenode.NNThroughputBenchmark -fs hdfs://main:9000 -op open -threads 100 -files 10000; \
hadoop org.apache.hadoop.hdfs.server.namenode.NNThroughputBenchmark -fs hdfs://main:9000 -op delete -threads 100 -files 10000; \
hadoop org.apache.hadoop.hdfs.server.namenode.NNThroughputBenchmark -fs hdfs://main:9000 -op rename -threads 100 -files 10000'
}
function test_hdfs_q4() {
docker compose -f cs511p1-compose.yaml cp resources/hadoop-terasort-3.3.6.jar \
main:/hadoop-terasort-3.3.6.jar
docker-compose -f cs511p1-compose.yaml exec main bash -x -c '\
hdfs dfs -rm -r -f tera-in tera-out tera-val; \
hadoop jar /hadoop-terasort-3.3.6.jar teragen 1000000 tera-in; \
hadoop jar /hadoop-terasort-3.3.6.jar terasort tera-in tera-out; \
hadoop jar /hadoop-terasort-3.3.6.jar teravalidate tera-out tera-val; \
hdfs dfs -cat tera-val/*;'
}
# test_spark.sh
function test_spark_q1() {
docker compose -f cs511p1-compose.yaml cp resources/active_executors.scala \
main:/active_executors.scala
docker-compose -f cs511p1-compose.yaml exec main bash -x -c '\
cat /active_executors.scala | spark-shell --master spark://main:7077'
}
function test_spark_q2() {
docker compose -f cs511p1-compose.yaml cp resources/pi.scala main:/pi.scala
docker-compose -f cs511p1-compose.yaml exec main bash -x -c '\
cat /pi.scala | spark-shell --master spark://main:7077'
}
function test_spark_q3() {
docker compose -f cs511p1-compose.yaml cp resources/fox.txt main:/test_fox.txt
docker-compose -f cs511p1-compose.yaml exec main bash -x -c '\
hdfs dfs -mkdir -p /test; \
hdfs dfs -put -f /test_fox.txt /test/fox.txt; \
hdfs dfs -cat /test/fox.txt'
docker-compose -f cs511p1-compose.yaml exec main bash -x -c '\
echo "sc.textFile(\"hdfs://main:9000/test/fox.txt\").collect()" | \
spark-shell --master spark://main:7077'
}
function test_spark_q4() {
docker compose -f cs511p1-compose.yaml cp resources/spark-terasort-1.2.jar \
main:/spark-terasort-1.2.jar
docker-compose -f cs511p1-compose.yaml exec main spark-submit \
--master spark://main:7077 \
--class com.github.ehiggs.spark.terasort.TeraGen local:///spark-terasort-1.2.jar \
100m hdfs://main:9000/spark/tera-in
docker-compose -f cs511p1-compose.yaml exec main spark-submit \
--master spark://main:7077 \
--class com.github.ehiggs.spark.terasort.TeraSort local:///spark-terasort-1.2.jar \
hdfs://main:9000/spark/tera-in hdfs://main:9000/spark/tera-out
docker-compose -f cs511p1-compose.yaml exec main spark-submit \
--master spark://main:7077 \
--class com.github.ehiggs.spark.terasort.TeraValidate local:///spark-terasort-1.2.jar \
hdfs://main:9000/spark/tera-out hdfs://main:9000/spark/tera-val
}
function test_terasorting() {
# call your program here
# make sure your program outputs only the result on screen
echo "please rewrite this function";
}
function test_pagerank() {
# extra credit
# make sure your program outputs only the result on screen
echo "please rewrite this function";
}
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
mkdir -p out
total_score=0;
echo -n "Testing HDFS Q1 ..."
test_hdfs_q1 > out/test_hdfs_q1.out 2>&1
if grep -q "Live datanodes (3)" out/test_hdfs_q1.out; then
echo -e " ${GREEN}PASS${NC}"
(( total_score+=10 ));
else
echo -e " ${RED}FAIL${NC}"
fi
echo -n "Testing HDFS Q2 ..."
test_hdfs_q2 > out/test_hdfs_q2.out 2>&1
if grep -E -q '^The quick brown fox jumps over the lazy dog[[:space:]]*$' out/test_hdfs_q2.out; then
echo -e " ${GREEN}PASS${NC}"
(( total_score+=10 ));
else
echo -e " ${RED}FAIL${NC}"
fi
echo -n "Testing HDFS Q3 ..."
test_hdfs_q3 > out/test_hdfs_q3.out 2>&1
if [ "$(grep -E '# operations: 10000[[:space:]]*$' out/test_hdfs_q3.out | wc -l)" -eq 4 ]; then
echo -e " ${GREEN}PASS${NC}"
(( total_score+=10 ));
else
echo -e " ${RED}FAIL${NC}"
fi
echo -n "Testing HDFS Q4 ..."
test_hdfs_q4 > out/test_hdfs_q4.out 2>&1
if [ "$(grep -E 'Job ([[:alnum:]]|_)+ completed successfully[[:space:]]*$' out/test_hdfs_q4.out | wc -l)" -eq 3 ] && grep -q "7a27e2d0d55de" out/test_hdfs_q4.out; then
echo -e " ${GREEN}PASS${NC}";
(( total_score+=10 ));
else
echo -e " ${RED}FAIL${NC}"
fi
echo -n "Testing Spark Q1 ..."
test_spark_q1 > out/test_spark_q1.out 2>&1
if grep -E -q "Seq\[String\] = List\([0-9\.:]*, [0-9\.:]*, [0-9\.:]*\)" out/test_spark_q1.out; then
echo -e " ${GREEN}PASS${NC}"
(( total_score+=10 ));
else
echo -e " ${RED}FAIL${NC}"
fi
echo -n "Testing Spark Q2 ..."
test_spark_q2 > out/test_spark_q2.out 2>&1
if grep -E -q '^Pi is roughly 3.14[0-9]*' out/test_spark_q2.out; then
echo -e " ${GREEN}PASS${NC}"
(( total_score+=10 ));
else
echo -e " ${RED}FAIL${NC}"
fi
echo -n "Testing Spark Q3 ..."
test_spark_q3 > out/test_spark_q3.out 2>&1
if grep -q 'Array(The quick brown fox jumps over the lazy dog)' out/test_spark_q3.out; then
echo -e " ${GREEN}PASS${NC}"
(( total_score+=10 ));
else
echo -e " ${RED}FAIL${NC}"
fi
echo -n "Testing Spark Q4 ..."
test_spark_q4 > out/test_spark_q4.out 2>&1
if grep -E -q "^Number of records written: 1000000[[:space:]]*$" out/test_spark_q4.out && \
grep -q "==== TeraSort took .* ====" out/test_spark_q4.out && \
grep -q "7a30469d6f066" out/test_spark_q4.out && \
grep -q "partitions are properly sorted" out/test_spark_q4.out; then
echo -e " ${GREEN}PASS${NC}"
(( total_score+=10 ));
else
echo -e " ${RED}FAIL${NC}"
fi
echo -n "Testing Tera Sorting ..."
test_terasorting > out/test_terasorting.out 2>&1
if diff --strip-trailing-cr resources/example-terasorting.truth <(test_terasorting); then
echo -e " ${GREEN}PASS${NC}"
(( total_score+=20 ));
else
echo -e " ${RED}FAIL${NC}"
fi
echo -n "Testing PageRank (extra credit) ..."
test_pagerank > out/test_pagerank.out 2>&1
if diff --strip-trailing-cr resources/example-pagerank.truth <(test_pagerank); then
echo -e " ${GREEN}PASS${NC}"
(( total_score+=20 ));
else
echo -e " ${RED}FAIL${NC}"
fi
echo "-----------------------------------";
echo "Total Points/Full Points: ${total_score}/120";