-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp3_index_test
executable file
·105 lines (86 loc) · 2.39 KB
/
p3_index_test
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
#!/bin/bash
GRADING_DIR=$HOME/grading
TMP_DIR=/tmp/p3a-grading
REQUIRED_FILES="team.txt buildSQLIndex.sql dropSQLIndex.sql build.xml README.txt"
# usage
if [ $# -ne 1 ]
then
echo "Usage: $0 project3-indexer.zip" 1>&2
exit 1
fi
ZIP_FILE=$1
# make sure that the script runs on VM
if [ `hostname` != "class-vm" ]; then
echo "ERROR: You need to run this script within the class virtual machine" 1>&2
exit 1
fi
# clean any existing files
rm -rf ${TMP_DIR}
# create temporary directory used for grading
mkdir ${TMP_DIR}
#
# check Part A submission
#
# unzip the parta zip file
if [ ! -f ${ZIP_FILE} ]; then
echo "ERROR: Cannot find $ZIP_FILE" 1>&2
rm -rf ${TMP_DIR}
exit 1
fi
unzip -q -d ${TMP_DIR} ${ZIP_FILE}
if [ "$?" -ne "0" ]; then
echo "ERROR: Cannot unzip ${ZIP_FILE} to ${TMP_DIR}"
rm -rf ${TMP_DIR}
exit 1
fi
# change directory to the parta folder
cd ${TMP_DIR}
# check the existence of the required files
for FILE in ${REQUIRED_FILES}
do
if [ ! -f ${FILE} ]; then
echo "ERROR: Cannot find ${FILE} in the root folder of ${ZIP_FILE}" 1>&2
rm -rf ${TMP_DIR}
exit 1
fi
done
JAVA_FILES=`find src -name '*.java' -print`
if [ -z "${JAVA_FILES}" ]; then
echo "ERROR: No java file is included in src folder of ${ZIP_FILE}" 1>&2
rm -rf ${TMP_DIR}
exit 1
fi
# drop existing SQL index
echo "Dropping existing SQL index from dropSQLIndex.sql..."
mysql CS144 < dropSQLIndex.sql
# create SQL index
echo "Creating SQL index from buildSQLIndex.sql..."
mysql CS144 < buildSQLIndex.sql
# remove existing lucene index
echo "Removing existing lucene index..."
rm -rf /var/lib/lucene/*
# run ant script to build lucene index(ex)
echo "Running 'ant compile' to compile your indexer..."
ant compile
# run ant script to build lucene index(ex)
echo "Running 'ant run' to create lucene index(ex)..."
ant run
# print out status message
echo "Finished creating lucene index"
# check the content of /var/lib/lucene directory
if [[ -n $(ls) ]]; then
echo "This is the current content of the lucene index directory:"
ls /var/lib/lucene
else
echo "ERROR: /var/lib/lucene/ directory does not contain any index!!!!!"
rm -rf ${TMP_DIR}
exit 1
fi
# print out status message
echo
echo
echo "Finished checking Project 3A submission"
echo "Please check the output of this script to ensure a proper submission"
# clean temporary files used for grading
rm -rf ${TMP_DIR}
exit 0