-
Notifications
You must be signed in to change notification settings - Fork 1
/
ce-qa.sh
executable file
·164 lines (130 loc) · 4.43 KB
/
ce-qa.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
#!/bin/bash
#
# Copyright (c) OrientDB LTD (http://www.orientdb.com)
#
export ORIENTDB_ROOT_PASSWORD="root"
export SLEEP_TIME=3
# resolve links - $0 may be a softlink
gzFile=$1
# extract dist name
old_IFS=$IFS # save the field separator
IFS='/' read -r -a items <<< "$gzFile"
distributionName=""
for element in "${items[@]}"
do
distributionName=$element
done
IFS=$old_IFS # restore default field separator
distNameLength="${#distributionName}"-7
distributionName=${distributionName:0:$distNameLength}
cd console-routines
export ROUTINES_HOME=$(pwd)
routineTestNames=($(ls -d */))
cd ..
echo -e "\n\n"
echo "***************************************************"
echo "Preparing QA Test Environment"
echo "***************************************************"
#copy and unzip the file
rm -rf test_ce
mkdir test_ce
#echo $gzFile
cp $gzFile test_ce
cd test_ce
export TESTCE_PATH=$(pwd)
tar -xvf $gzFile
rm *.tar.gz
cd $distributionName
export ORIENTDB_HOME=$(pwd)
# Downloading Tolkien-Arda from cloud
cd databases
mkdir Tolkien-Arda
cd Tolkien-Arda
curl -O http://orientdb.com/public-databases/Tolkien-Arda.zip
unzip Tolkien-Arda.zip
rm Tolkien-Arda.zip
echo -e "\n\n"
echo -e "***************************************************\n"
echo -e "INFO\n"
echo "Distribution: " $distributionName
echo "ORIENTDB_HOME: " $ORIENTDB_HOME
echo "Test Routines: " $routineTestNames
echo "ROUTINES_HOME: " $ROUTINES_HOME
echo -e "Tests output dir:" $TESTCE_PATH "\n"
echo -e "***************************************************"
echo -e "\n\n"
echo "***************************************************"
echo -e "Server Startup/Shutdown tests"
echo "***************************************************"
### TEST SHUTDOWN
cd $ORIENTDB_HOME/bin
./server.sh > $TESTCE_PATH/server.log &
sleep $SLEEP_TIME
shutdownOutput=$(jps | grep OServerMain)
if [ ${#shutdownOutput} -lt "11" ]
then
echo "FAIL on startup - step 1"
exit 1;
fi
./shutdown.sh
sleep $SLEEP_TIME
shutdownOutput=$(jps | grep OServerMain)
echo ""
echo "JPS: ${shutdownOutput}"
if [ ${#shutdownOutput} -gt "2" ]
then
echo "FAIL on shutdown - step 2"
exit 1;
fi
### TEST SHUTDOWN WITH CREDENTIALS
./server.sh > $TESTCE_PATH/server.log &
sleep $SLEEP_TIME
./shutdown.sh -u root -p root
sleep $SLEEP_TIME
shutdownOutput=$(jps | grep OServerMain)
echo ""
echo "JPS: ${shutdownOutput}"
if [ ${#shutdownOutput} -gt "2" ]
then
echo "FAIL on shutdown - step 3"
exit 1;
fi
echo -e "\n\n"
echo "***************************************************"
echo -e "Executing console-routines tests"
echo "***************************************************"
old_IFS=$IFS # save the field separator
IFS=$'\n'
### TEST CONSOLE SCRIPTS
echo ""
for i in "${routineTestNames[@]}"
do
# start server
./server.sh > $TESTCE_PATH/server.log &
sleep $SLEEP_TIME
ilength=${#i}
ilength=`expr ${ilength} - 1`
routineName=${i:0:ilength}
echo "Executing '"$routineName"' routine"
if [ ${ilength} -gt "1" ]
then
mkdir $TESTCE_PATH/${routineName}_result
# Splitting output-commands.txt
awk 'BEGIN {RS = "(^|\n)<OUT-COMM-[0-9]*>\n"} ; { if (NR>1) print $0 >> "'$ROUTINES_HOME/$routineName/'expected-command-output-"(NR-1)".txt"}' $ROUTINES_HOME/$routineName/output-commands.txt
echo "doing ./console.sh $ROUTINES_HOME/$routineName/input-commands.txt > $TESTCE_PATH/${routineName}_result/console_${routineName}_result.log"
./console.sh $ROUTINES_HOME/$routineName/input-commands.txt > $TESTCE_PATH/${routineName}_result/console_${routineName}_result.log
cat $TESTCE_PATH/${routineName}_result/console_${routineName}_result.log
# Splitting console_${routineName}_result.log into 'actual-command-output' files
sed -e 's/orientdb.*>.*/<OUT-COMM>/' $TESTCE_PATH/${routineName}_result/console_basic_routine_result.log |
awk 'BEGIN {RS = "(^|\n)<OUT-COMM>\n"} ; { if (NR>1) print $0 >> "'$TESTCE_PATH/${routineName}_result/'actual-command-ouput-"(NR-1)".txt"}'
#Comparing actual command outputs with the expected command outputs
# Removing expected and actual commands' outputs chunks
#rm $ROUTINES_HOME/$routineName/expected-command-output-*
#rm $TESTCE_PATH/${routineName}_result/actual-command-ouput-*
fi
# shutdown server
./shutdown.sh
done
IFS=$old_IFS # restore default field separator
echo "********* SUCCESS ************"
exit 0