Start known issues changelog section - place it on top for clarity
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 10_before_install.bash
CommitLineData
b58ecb01 1#!/bin/bash
2
01fd95b6 3export SHORT_CIRCUIT_SMOKE
4
36372426 5if have_sudo ; then
6
7 # Stop pre-started RDBMS, move their data back to disk (save RAM)
8 # sync for some settle time (not available on all platforms)
9 for d in mysql postgresql ; do
10 # maybe not even running
11 run_or_err "Stopping $d" "sudo /etc/init.d/$d stop || /bin/true"
12
13 # no longer available on newer build systems
14 if [[ -d /var/ramfs/$d ]] ; then
15 sudo rm -rf /var/lib/$d
16 sudo mv /var/ramfs/$d /var/lib/
17 sudo ln -s /var/lib/$d /var/ramfs/$d
18 fi
19 done
20 /bin/sync
21fi
06278456 22
fcdd56ca 23# Sanity check VM before continuing
24echo "
25=============================================================================
26
27= Startup Meminfo
28$(free -m -t)
29
30============================================================================="
31
32CI_VM_MIN_FREE_MB=2000
33if [[ "$(free -m | grep 'buffers/cache:' | perl -p -e '$_ = (split /\s+/, $_)[3]')" -lt "$CI_VM_MIN_FREE_MB" ]]; then
34 SHORT_CIRCUIT_SMOKE=1
35 echo_err "
36=============================================================================
37
38CI virtual machine stuck in a state with a lot of memory locked for no reason.
39Under Travis this state usually results in a failed build.
40Short-circuiting buildjob to avoid false negatives, please restart it manually.
41
42============================================================================="
01fd95b6 43
44# pull requests are always scrutinized after the fact anyway - run a
45# a simpler matrix
46elif [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
47 if [[ -n "$BREWVER" ]]; then
48 # just don't brew anything
49 SHORT_CIRCUIT_SMOKE=1
50 else
51 # running PRs with 1 thread is non-sensical
52 VCPU_USE=""
53 fi
fcdd56ca 54fi
55
b58ecb01 56if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
57
36372426 58# Previously we were going off the OpenVZ vcpu count and dividing by 3
59# With the new infrastructure, somply go with "something high"
60export VCPU_AVAILABLE=10
5ac4a96d 61
62if [[ -z "$VCPU_USE" ]] ; then
63 export VCPU_USE="$VCPU_AVAILABLE"
2a89732d 64fi
003e97c5 65
003e97c5 66
36372426 67if [[ "$CLEANTEST" != "true" ]]; then
b58ecb01 68
36372426 69 if [[ -z "$(tail -n +2 /proc/swaps)" ]] ; then
70 run_or_err "Configuring swap (for Oracle)" \
71 "sudo bash -c 'dd if=/dev/zero of=/swap.img bs=256M count=5 && chmod 600 /swap.img && mkswap /swap.img && swapon /swap.img'"
72 fi
e861e4f0 73
36372426 74 export CACHE_DIR="/tmp/poormanscache"
1e735709 75
b58ecb01 76 #
77 # FIXME these debconf lines should automate the firebird config but do not :(((
78 sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/enabled\tboolean\ttrue" | debconf-set-selections'
79 sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/sysdba_password/new_password\tpassword\t123" | debconf-set-selections'
80
d50f2fe1 81 # these APT sources do not mean anything to us anyway
82 sudo rm -rf /etc/apt/sources.list.d/*
83
7a96e0d6 84 # the actual package is built for lucid, installs fine on both precise and trusty
85 sudo bash -c 'echo "deb http://archive.canonical.com/ubuntu precise partner" >> /etc/apt/sources.list'
86
36372426 87 # never installed, this looks like trusty
88 if [[ ! -d /var/lib/mysql ]] ; then
89 sudo dpkg --add-architecture i386
7a96e0d6 90 extra_debs="$extra_debs postgresql mysql-server"
91 fi
92
93 # FIXME - by default db2 eats too much memory, we won't be able to test on legacy infra
94 # someone needs to add a minimizing configuration akin to 9367d187
95 if [[ "$(free -m | grep 'Mem:' | perl -p -e '$_ = (split /\s+/, $_)[1]')" -gt 4000 ]] ; then
96 extra_debs="$extra_debs db2exc"
36372426 97 fi
98
94464be8 99 run_or_err "Updating APT sources" "sudo apt-get update"
003e97c5 100
7a96e0d6 101 apt_install $extra_debs libmysqlclient-dev memcached firebird2.5-super firebird2.5-dev expect
36372426 102
7a96e0d6 103 # needs to happen separately and *after* db2exc, as the former shits all over /usr/include (wtf?!)
104 # for more info look at /opt/ibm/db2/V9.7/instance/db2iutil :: create_links()
105 apt_install unixodbc-dev
106
107 # need to stop them again, in case we installed them above (trusty)
108 for d in mysql postgresql ; do
109 run_or_err "Stopping $d" "sudo /etc/init.d/$d stop || /bin/true"
110 done
36372426 111
112 run_or_err "Cloning poor man's cache from github" "git clone --depth=1 --single-branch --branch=oracle/10.2.0 https://github.com/poormanscache/poormanscache.git $CACHE_DIR && $CACHE_DIR/reassemble"
113 run_or_err "Installing OracleXE manually from deb" \
114 "sudo dpkg -i $CACHE_DIR/apt_cache/bc-multiarch-travis_1.0_all.deb $CACHE_DIR/apt_cache/oracle-xe_10.2.0.1-1.1_i386.deb || sudo bash -c 'source maint/travis-ci_scripts/common.bash && apt_install -f'"
b58ecb01 115
116### config memcached
106c81a5 117 run_or_err "Starting memcached" "sudo /etc/init.d/memcached start"
b58ecb01 118 export DBICTEST_MEMCACHED=127.0.0.1:11211
119
120### config mysql
3c26d329 121 run_or_err "Installing minimizing MySQL config" "\
122 sudo bash -c 'rm /var/lib/mysql/ib*' \
123 && sudo cp maint/travis-ci_scripts/configs/minimal_mysql_travis.cnf /etc/mysql/conf.d/ \
124 && sudo chmod 644 /etc/mysql/conf.d/*.cnf \
125 "
126
fcdd56ca 127 run_or_err "Starting MySQL" "sudo /etc/init.d/mysql start"
36372426 128 run_or_err "Creating MySQL TestDB" "mysql -u root -e 'create database dbic_test;'"
b58ecb01 129 export DBICTEST_MYSQL_DSN='dbi:mysql:database=dbic_test;host=127.0.0.1'
130 export DBICTEST_MYSQL_USER=root
131
132### config pg
fcdd56ca 133 run_or_err "Starting PostgreSQL" "sudo /etc/init.d/postgresql start"
b58ecb01 134 run_or_err "Creating PostgreSQL TestDB" "psql -c 'create database dbic_test;' -U postgres"
135 export DBICTEST_PG_DSN='dbi:Pg:database=dbic_test;host=127.0.0.1'
136 export DBICTEST_PG_USER=postgres
137
138### conig firebird
139 # poor man's deb config
140 EXPECT_FB_SCRIPT='
141 spawn dpkg-reconfigure --frontend=text firebird2.5-super
142 expect "Enable Firebird server?"
143 send "\177\177\177\177yes\r"
144 expect "Password for SYSDBA"
145 send "123\r"
2c649faf 146 sleep 2
003e97c5 147 expect eof
b58ecb01 148 '
b58ecb01 149 # creating testdb
150 # FIXME - this step still fails from time to time >:(((
151 # has to do with the FB reconfiguration I suppose
906c0355 152 # for now if it fails twice - simply skip FB testing
2c649faf 153 for i in 1 2 3 ; do
906c0355 154
155 run_or_err "Re-configuring Firebird" "
156 sync
2c649faf 157 sleep 5
906c0355 158 DEBIAN_FRONTEND=text sudo expect -c '$EXPECT_FB_SCRIPT'
906c0355 159 "
160
161 if run_or_err "Creating Firebird TestDB" \
162 "echo \"CREATE DATABASE '/var/lib/firebird/2.5/data/dbic_test.fdb';\" | sudo isql-fb -u sysdba -p 123"
163 then
da59679a 164
137dca08 165 run_or_err "Fetching and building Firebird ODBC driver" '
166 cd "$(mktemp -d)"
167 wget -qO- http://sourceforge.net/projects/firebird/files/firebird-ODBC-driver/2.0.2-Release/OdbcFb-Source-2.0.2.153.gz/download | tar -zx
168 cd Builds/Gcc.lin
169 perl -p -i -e "s|/usr/lib64|/usr/lib/x86_64-linux-gnu|g" ../makefile.environ
170 make -f makefile.linux
171 sudo make -f makefile.linux install
172 '
173
174 sudo bash -c 'cat >> /etc/odbcinst.ini' <<< "
175[Firebird]
176Description = InterBase/Firebird ODBC Driver
177Driver = /usr/lib/x86_64-linux-gnu/libOdbcFb.so
178Setup = /usr/lib/x86_64-linux-gnu/libOdbcFb.so
179Threading = 1
180FileUsage = 1
181"
182
906c0355 183 export DBICTEST_FIREBIRD_DSN=dbi:Firebird:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
184 export DBICTEST_FIREBIRD_USER=SYSDBA
185 export DBICTEST_FIREBIRD_PASS=123
186
187 export DBICTEST_FIREBIRD_INTERBASE_DSN=dbi:InterBase:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
188 export DBICTEST_FIREBIRD_INTERBASE_USER=SYSDBA
189 export DBICTEST_FIREBIRD_INTERBASE_PASS=123
190
137dca08 191 export DBICTEST_FIREBIRD_ODBC_DSN="dbi:ODBC:Driver=Firebird;Dbname=/var/lib/firebird/2.5/data/dbic_test.fdb"
192 export DBICTEST_FIREBIRD_ODBC_USER=SYSDBA
193 export DBICTEST_FIREBIRD_ODBC_PASS=123
194
906c0355 195 break
196 fi
197
198 done
b58ecb01 199
003e97c5 200### config oracle
fa7907b0 201 SRV_ORA_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
202
203 # without this some of the more zealous tests can exhaust the amount
204 # of listeners and oracle is too slow to spin extras up :(
205 sudo bash -c "echo -e '\nprocesses=150' >> $SRV_ORA_HOME/config/scripts/init.ora"
206
003e97c5 207 EXPECT_ORA_SCRIPT='
208 spawn /etc/init.d/oracle-xe configure
209
210 sleep 1
211 set send_slow {1 .005}
212
213 expect "Specify the HTTP port that will be used for Oracle Application Express"
214 sleep 0.5
215 send -s "8021\r"
216
217 expect "Specify a port that will be used for the database listener"
218 sleep 0.5
219 send -s "1521\r"
220
221 expect "Specify a password to be used for database accounts"
222 sleep 0.5
223 send -s "adminpass\r"
224
225 expect "Confirm the password"
226 sleep 0.5
227 send -s "adminpass\r"
228
229 expect "Do you want Oracle Database 10g Express Edition to be started on boot"
230 sleep 0.5
231 send -s "n\r"
232
233 sleep 0.5
234 expect "Configuring Database"
235
236 sleep 1
237 expect eof
238 wait
239 '
240
241 # if we do not redirect to some random file, but instead try to capture
242 # into a var the way run_or_err does - everything hangs
243 # FIXME: I couldn't figure it out after 3 hours of headdesking,
244 # would be nice to know the reason eventually
245 run_or_err "Configuring OracleXE" "sudo $(which expect) -c '$EXPECT_ORA_SCRIPT' &>/tmp/ora_configure_10.2.log"
003e97c5 246
247 export DBICTEST_ORA_DSN=dbi:Oracle://localhost:1521/XE
248 export DBICTEST_ORA_USER=dbic_test
249 export DBICTEST_ORA_PASS=abc123456
fa7907b0 250 export DBICTEST_ORA_EXTRAUSER_DSN="$DBICTEST_ORA_DSN"
003e97c5 251 export DBICTEST_ORA_EXTRAUSER_USER=dbic_test_extra
252 export DBICTEST_ORA_EXTRAUSER_PASS=abc123456
253
254 run_or_err "Create Oracle users" "ORACLE_SID=XE ORACLE_HOME=$SRV_ORA_HOME $SRV_ORA_HOME/bin/sqlplus -L -S system/adminpass @/dev/stdin <<< '
255 CREATE USER $DBICTEST_ORA_USER IDENTIFIED BY $DBICTEST_ORA_PASS;
256 GRANT connect,resource TO $DBICTEST_ORA_USER;
257 CREATE USER $DBICTEST_ORA_EXTRAUSER_USER IDENTIFIED BY $DBICTEST_ORA_EXTRAUSER_PASS;
258 GRANT connect,resource TO $DBICTEST_ORA_EXTRAUSER_USER;
259 '"
260
261 export ORACLE_HOME="$CACHE_DIR/ora_instaclient/x86-64/oracle_instaclient_10.2.0.5.0"
7a96e0d6 262
263### config db2exc
264 # we may have skipped installation due to low memory
265 if dpkg -l db2exc &>/dev/null ; then
266 # WTF is this world-writable?
267 # Strip the write bit so it doesn't trip Ubuntu's symlink-in-/tmp attack mitigation
268 sudo chmod -R o-w ~dasusr1/das
269
270 export DB2_HOME=/opt/ibm/db2/V9.7
271 export DBICTEST_DB2_DSN=dbi:DB2:DATABASE=dbictest
272 export DBICTEST_DB2_USER=db2inst1
273 export DBICTEST_DB2_PASS=abc123456
274
275 run_or_err "Set up DB2 users" \
276 "echo -e '$DBICTEST_DB2_PASS\n$DBICTEST_DB2_PASS' | sudo passwd $DBICTEST_DB2_USER"
277
278 run_or_err "Create DB2 database" \
279 "sudo -u $DBICTEST_DB2_USER -i db2 'CREATE DATABASE dbictest' && sudo -u $DBICTEST_DB2_USER -i db2 'ACTIVATE DATABASE dbictest'"
280 fi
281
b58ecb01 282fi