-
Notifications
You must be signed in to change notification settings - Fork 16
/
run_cc_unit_tests
executable file
·92 lines (73 loc) · 2.31 KB
/
run_cc_unit_tests
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
#!/usr/bin/env bash
set -e
: ${DB:?}
start_db() {
if [ "${DB}" = "mysql" ]; then
# HACK: change access time on mysql files to copy them into the writable layer
# Context: https://github.com/moby/moby/issues/34390
find /var/lib/mysql/mysql -exec touch -c -a {} +
service mysql stop
mkdir -p /var/lib/ramdisk
# HACK: not really sure what a good size for the mount is
mount -t tmpfs -o size=8192m ramdisk /var/lib/ramdisk
cp -R /var/lib/mysql/* /var/lib/ramdisk/
chown -R mysql /var/lib/ramdisk
chgrp -R mysql /var/lib/ramdisk
chmod 700 /var/lib/ramdisk
# HACKish: update mysql config to use ramdisk mount to back its disk storage
echo -e "\n[mysqld]\ndatadir = /var/lib/ramdisk" >> /etc/mysql/my.cnf
service mysql restart
trap stop_mysql EXIT
elif [ "${DB}" = "postgres" ]; then
service postgresql stop
mkdir -p /var/lib/ramdisk
# HACK: not really sure what a good size for the mount is
mount -t tmpfs -o size=8192m ramdisk /var/lib/ramdisk
cp -R /var/lib/postgresql/9.6/main/* /var/lib/ramdisk/
chown -R postgres /var/lib/ramdisk
chgrp -R postgres /var/lib/ramdisk
chmod 700 /var/lib/ramdisk
# HACKish: update postgres config to use ramdisk mount to back its disk storage
sed -i -E "s#data_directory = (.*)#data_directory = '/var/lib/ramdisk'#g" /etc/postgresql/9.6/main/postgresql.conf
service postgresql restart
trap stop_postgres EXIT
elif [ "${DB}" = "mssql" ]; then
service docker start
sleep 5
service docker stop
dockerd --data-root /scratch/docker ${server_args} >/tmp/docker.log 2>&1 &
echo $! > /tmp/docker.pid
trap stop_docker EXIT
sleep 5
LOG_FILE="/tmp/mssql.log" ./scripts/run-ms-sql-background.sh
else
echo "Unknown DB type '${DB}', this script only supports 'mysql', 'postgres', and 'mssql'"
exit 1
fi
}
stop_mysql() {
service mysql stop
}
stop_postgres() {
service postgresql stop
}
stop_docker() {
local pid=$(cat /tmp/docker.pid)
if [ -z "$pid" ]; then
return 0
fi
kill -TERM $pid
wait $pid
}
pushd cloud_controller_ng > /dev/null
start_db
export BUNDLE_GEMFILE=Gemfile
bundle install
if [ -n "${RUN_IN_PARALLEL}" ]; then
rubocop --parallel
bundle exec rake spec:all
else
rubocop
bundle exec rake spec:serial
fi
popd > /dev/null