/
obs_testsuite_common.sh
81 lines (62 loc) · 2.03 KB
/
obs_testsuite_common.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
#!/bin/sh
#
# This script prepares the API test database for both the API and the WEBUI test suites
#
setup_git() {
echo "Checking status"
git status
echo "Setup git submodules"
git submodule init
git submodule update
echo "Setup backend configuration template"
sed -i -e "s|my \$hostname = .*$|my \$hostname = 'localhost';|" \
-e "s|our \$bsuser = 'obsrun';|our \$bsuser = 'jenkins';|" \
-e "s|our \$bsgroup = 'obsrun';|our \$bsgroup = 'jenkins';|" src/backend/BSConfig.pm.template
cp src/backend/BSConfig.pm.template src/backend/BSConfig.pm
echo "Set environment variables"
export RAILS_ENV=test
ret=0
}
setup_api() {
echo "Enter API rails root"
cd src/api
echo "Setup database configuration"
cp config/database.yml.example config/database.yml
sed -i "s|database: api|database: ci_api|" config/database.yml
echo "Setup additional configuration"
cp config/options.yml.example config/options.yml
cp config/thinking_sphinx.yml.example config/thinking_sphinx.yml
chmod a+x script/start_test_backend
echo "Initialize test database, load seed data"
bundle exec rake db:drop db:create db:setup --trace
cd ../..
}
setup_webui() {
echo "Enter Webui rails root"
cd src/webui
echo "Setup database configuration"
cp config/database.yml.example config/database.yml
echo "Setup additional configuration"
cp config/options.yml.example config/options.yml
chmod +x script/start_test_api
echo "Initialize test database, load seed data"
bundle exec rake db:drop db:create db:setup --trace
cd ../..
cd docs/api
make
cd ../..
}
cleanup() {
echo "Killing backend processes"
if fuser -v $PWD | egrep 'perl|ruby'; then
list=`fuser -v $PWD 2>&1 | egrep 'perl|ruby' | sed -e "s,^ *$USER *,,;" | cut '-d ' -f1`
for p in $list; do
echo "Kill $p"
# the process might have gone away on its own, so use || true
kill $p || true
done
fi
echo "Remove log/tmp files to save disc space"
rm -rf src/api/{log,tmp}/* \
src/webui/{log,tmp}/* || true
}