-
Notifications
You must be signed in to change notification settings - Fork 8
/
BATS_TSE.sh
executable file
·179 lines (151 loc) · 3.54 KB
/
BATS_TSE.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
#!/bin/bash
# Name: BATS_TSE.sh
#
# Description: This script will build, test and run the search engine
#
# Input: None.
# Output: Built search engine with command line processing ready
#
# Command Line Options: None.
# Pseudocode:
#
# 1. Build Crawler with make
# 2. Test crawler with BATS.sh script
# 3. Run the crawler
#
# 4. Build the indexer with make
# 5. Test the indexer with BATS.sh script
# 6. Run the indexer
# 7. Test the indexer reloading with diff
# 8. Build the query engine
# 9. Build query engine unit tests
# 10. Run query engine unit tests
# 11. Run query engine
CRAWLER_DIR="data/"
CRAWL_SITE="www.cs.dartmouth.edu"
DEPTH=2
INDEX_FILE="index.dat"
NEW_INDEX_FILE="index_new.dat"
###### CRAWLER ######
# Build the crawler
echo -e "\n (1) Building crawler"
cd ./crawler_dir/
make
# Test the crawler
if [ $? -eq 0 ]; then
#############
#############
############# ENABLE CRAWLER #####
echo -e "\n (2) Testing crawler"
./BATS.sh
else
echo "Building crawler failed (make [crawler])"
make clean
exit 1
fi
# Run the crawler
if [ $? -eq 0 ]; then
#############
#############
############# ENABLE SLEEP #####
echo -e "\n (3) Running the crawler"
#############
#############
############# ENABLE CRAWLER #####
./crawler $CRAWL_SITE ./$CRAWLER_DIR $DEPTH
else
echo "Testing crawler failed (BATS.sh)"
make clean
exit 1
fi
###### INDEXER ######
# Build the indexer
if [ $? -eq 0 ]; then
make clean
echo -e "\n (4) Building the indexer"
cd ../indexer_dir
make
else
echo "Running crawler failed (./crawler)"
exit 1
fi
# Test the indexer
if [ $? -eq 0 ]; then
echo -e "\n (5) Testing indexer"
./BATS.sh
else
echo "Building indexer failed (make [indexer])"
make clean
exit 1
fi
# Run the indexer
if [ $? -eq 0 ]; then
echo -e "\n (6) Running the indexer and testing Reload"
./indexer ../crawler_dir/data/ $INDEX_FILE $INDEX_FILE $NEW_INDEX_FILE
else
echo "Testing indexer failed (BATS.sh)"
fi
# Testing reloaded File via diff
if [ $? -eq 0 ]; then
make clean
echo -e "\n (7) Testing reloaded indexer diff"
if [[ -e "$INDEX_FILE" && -e "$NEW_INDEX_FILE" ]]; then
# make sure sorting is the same
sort -o $INDEX_FILE $INDEX_FILE
sort -o $NEW_INDEX_FILE $NEW_INDEX_FILE
#diff -q $INDEX_FILE $NEW_INDEX_FILE > /dev/null
diff $INDEX_FILE $NEW_INDEX_FILE
# check the integrity of the files
if [ $? -eq 0 ]; then
echo "Index storage passed test!"
else
echo "Index storage didn't pass test!"
fi
debugFlag=0;
else
echo "Index files $INDEX_FILE and $NEW_INDEX_FILE do not exist. Not testing."
fi
else
echo "Running indexer failed (./indexer)"
make clean
exit 1
fi
###### QUERY ENGINE ######
# Build the search engine
echo -e "\n (8) Building query engine"
cd ../queryengine_dir/
make
# Build query engine unit tests
if [ $? -eq 0 ]; then
echo -e "\n (9) Building query engine unit tests"
make unit
else
echo "Building query engine failed (make [queryengine])"
make clean
exit 1
fi
# Run query engine unit tests
if [ $? -eq 0 ]; then
echo -e "\n (10) Running query engine unit tests"
./queryengine_test
else
echo "Building query engine unit tests failed (make unit)"
make clean
exit 1
fi
# Launch the query engine
if [ $? -eq 0 ]; then
echo -e "\n (11) Running query engine (type !exit as query to exit"
./queryengine ../indexer_dir/$INDEX_FILE ../crawler_dir/$CRAWLER_DIR
else
echo "Running unit tests failed (./queryengine_test)"
make clean
exit 1
fi
# cleanup
make clean
cd ../utils
rm -f *.gch
rm -f *.o
cd ..
exit 0