forked from tiborsimko/invenio-devscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvenio-retest-demo-site
executable file
·109 lines (95 loc) · 3.9 KB
/
invenio-retest-demo-site
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
#!/bin/sh
#
# A helper devscript to retest Invenio demo site. For more
# information, see <https://github.com/tiborsimko/invenio-devscripts>.
#
# Tibor Simko <[email protected]>
#
# Copyright (C) 2011, 2012 CERN.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
# config section:
CFG_INVENIO_PREFIX=${CFG_INVENIO_PREFIX:=/opt/invenio}
CFG_INVENIO_USER=${CFG_INVENIO_USER:=www-data}
CFG_INVENIO_HOSTNAME=${CFG_INVENIO_HOSTNAME:=pcuds07}
# sanity check: CLI confirmation
if [ "$1" != "--yes-i-know" ]; then
echo "[ERROR] You did not use --yes-i-know. Not going to test the site."
exit
fi
# quit on potentially unbound symbols:
set -o nounset
# sanity check: hostname
if [ "`hostname`" != "$CFG_INVENIO_HOSTNAME" ]; then
echo "[ERROR] This hostname is not whitelisted for recreating the demo site."
exit
fi
# give user a chance to quit:
echo "[INFO] GOING TO RUN DESTRUCTIVE TESTS ON YOUR INVENIO DEMO SITE IN 5 SECONDS!"
echo -n "[INFO] THIS IS YOUR LAST CHANCE TO INTERRUPT BY PRESSING Ctrl-C! "
for i in 0 1 2 3 4; do
echo -n "."
sleep 1
done
echo
# set up temporary files:
yyyymmddhhmmss=$(date +"%Y-%m-%d-%H-%M-%S")
unittestresults=/tmp/$(basename $0)-unit-$yyyymmddhhmmss
regressiontestresults=/tmp/$(basename $0)-regression-$yyyymmddhhmmss
webtestresults=/tmp/$(basename $0)-web-$yyyymmddhhmmss
savedir=$HOME/.invenio-devscripts.d
saveunittestresults=$savedir/$(basename $0)-unit-lastrun
saveregressiontestresults=$savedir/$(basename $0)-regression-lastrun
savewebtestresults=$savedir/$(basename $0)-web-lastrun
# run unit tests:
echo "[INFO] Running unit test suite..."
sudo -u ${CFG_INVENIO_USER} ${CFG_INVENIO_PREFIX}/bin/inveniocfg --run-unit-tests > $unittestresults 2>&1
sed -n '/^Ran [0-9]/,$p' $unittestresults
# compare unit test results against last run:
if [ -f $saveunittestresults ]; then
echo "[INFO] Unit test results compared against last run:"
colordiff -u $saveunittestresults $unittestresults
fi
# run regression tests:
echo "[INFO] Running regression test suite..."
sudo -u ${CFG_INVENIO_USER} ${CFG_INVENIO_PREFIX}/bin/inveniocfg --run-regression-tests --yes-i-know > $regressiontestresults 2>&1
sed -n '/^Ran [0-9]/,$p' $regressiontestresults
# compare regression test results against last run:
if [ -f $saveregressiontestresults ]; then
echo "[INFO] Regression test results compared against last run:"
colordiff -u $saveregressiontestresults $regressiontestresults
fi
# run web tests:
echo "[INFO] Running web test suite..."
${CFG_INVENIO_PREFIX}/bin/inveniocfg --run-web-tests --yes-i-know > $webtestresults 2>&1
sed -n '/^Ran [0-9]/,$p' $webtestresults
# compare web test results against last run:
if [ -f $savewebtestresults ]; then
echo "[INFO] Web test results compared against last run:"
colordiff -u $savewebtestresults $webtestresults
fi
# save results:
read -p "[QUESTION] Do you wish to save these results? (y/n) [n] " answer
if [ "$answer" = "y" ]; then
mkdir -p $savedir
mv -f $unittestresults $saveunittestresults
mv -f $regressiontestresults $saveregressiontestresults
mv -f $webtestresults $savewebtestresults
echo "[INFO] Results saved as ${saveunittestresults}, " \
"${saveregressiontestresults} and ${savewebtestresults}."
else
echo "[INFO] Left results at ${unittestresults}, " \
"${regressiontestresults} and ${webtestresults}."
fi
echo "[INFO] Done."