3 export SHORT_CIRCUIT_SMOKE
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"
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
23 # Sanity check VM before continuing
25 =============================================================================
30 ============================================================================="
32 CI_VM_MIN_FREE_MB=2000
33 if [[ "$(free -m | grep 'buffers/cache:' | perl -p -e '$_ = (split /\s+/, $_)[3]')" -lt "$CI_VM_MIN_FREE_MB" ]]; then
36 =============================================================================
38 CI virtual machine stuck in a state with a lot of memory locked for no reason.
39 Under Travis this state usually results in a failed build.
40 Short-circuiting buildjob to avoid false negatives, please restart it manually.
42 ============================================================================="
44 # pull requests are always scrutinized after the fact anyway - run a
46 elif [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
47 if [[ -n "$BREWVER" ]]; then
48 # just don't brew anything
51 # running PRs with 1 thread is non-sensical
56 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
58 # Previously we were going off the OpenVZ vcpu count and dividing by 3
59 # With the new infrastructure, somply go with "something high"
60 export VCPU_AVAILABLE=10
62 if [[ -z "$VCPU_USE" ]] ; then
63 export VCPU_USE="$VCPU_AVAILABLE"
67 if [[ "$CLEANTEST" != "true" ]]; then
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'"
75 # never installed, this looks like trusty
76 if [[ ! -d /var/lib/mysql ]] ; then
77 sudo dpkg --add-architecture i386
78 extra_debs+=( postgresql mysql-server )
82 # these APT sources do not mean anything to us anyway
83 sudo rm -rf /etc/apt/sources.list.d/*
86 # FIXME these debconf lines should automate the firebird config but seem not to :(((
87 sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/enabled\tboolean\ttrue" | debconf-set-selections'
88 sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/sysdba_password/new_password\tpassword\t123" | debconf-set-selections'
90 run_or_err "Updating APT sources" "sudo apt-get update"
91 apt_install ${extra_debs[@]} libmysqlclient-dev memcached firebird2.5-super firebird2.5-dev expect
94 # need to stop them again, in case we installed them above (trusty)
95 for d in mysql postgresql ; do
96 run_or_err "Stopping $d" "sudo /etc/init.d/$d stop || /bin/true"
100 export CACHE_DIR="/tmp/poormanscache"
103 # FIXME - by default db2 eats too much memory, we won't be able to test on legacy infra
104 # someone needs to add a minimizing configuration akin to 9367d187
105 if [[ "$(free -m | grep 'Mem:' | perl -p -e '$_ = (split /\s+/, $_)[1]')" -gt 4000 ]] ; then
106 run_or_err "Getting DB2 from poor man's cache github" '
107 wget -qO- https://github.com/poormanscache/poormanscache/archive/DB2_ExC/9.7.5_deb_x86-64.tar.gz \
108 | tar -C "$CACHE_DIR" -zx'
110 # the actual package is built for lucid, installs fine on both precise and trusty
111 manual_debs+=( "db2exc_9.7.5-0lucid0_amd64.deb" )
114 run_or_err "Getting Oracle from poor man's cache github" '
115 wget -qO- https://github.com/poormanscache/poormanscache/archive/OracleXE/10.2.0_deb_mixed.tar.gz \
116 | tar -C "$CACHE_DIR" -zx'
117 manual_debs+=( "bc-multiarch-travis_1.0_all.deb" "oracle-xe_10.2.0.1-1.1_i386.deb" )
120 # reassemble chunked pieces ( working around github's filesize limit )
121 for reass in $CACHE_DIR/*/reassemble ; do /bin/bash "$reass" ; done
123 run_or_err "Installing RDBMS debs manually: $( echo ${manual_debs[@]/#/$CACHE_DIR/*/*/} )" \
124 "sudo dpkg -i $( echo ${manual_debs[@]/#/$CACHE_DIR/*/*/} ) || sudo bash -c 'source maint/travis-ci_scripts/common.bash && apt_install -f'"
127 # Needs to happen separately and *after* db2exc, as the former shits all over /usr/include (wtf?!)
128 # For more info look at /opt/ibm/db2/V9.7/instance/db2iutil :: create_links()
129 # The --reinstall is there in case it was already in place and got destroyed
130 # (this is the case on newer trusty images)
131 apt_install --reinstall unixodbc-dev
135 run_or_err "Starting memcached" "sudo /etc/init.d/memcached start"
136 export DBICTEST_MEMCACHED=127.0.0.1:11211
139 run_or_err "Installing minimizing MySQL config" "\
140 sudo bash -c 'rm /var/lib/mysql/ib*' \
141 && sudo cp maint/travis-ci_scripts/configs/minimal_mysql_travis.cnf /etc/mysql/conf.d/ \
142 && sudo chmod 644 /etc/mysql/conf.d/*.cnf \
145 run_or_err "Starting MySQL" "sudo /etc/init.d/mysql start"
146 run_or_err "Creating MySQL TestDB" "mysql -u root -e 'create database dbic_test;'"
147 export DBICTEST_MYSQL_DSN='dbi:mysql:database=dbic_test;host=127.0.0.1'
148 export DBICTEST_MYSQL_USER=root
151 run_or_err "Starting PostgreSQL" "sudo /etc/init.d/postgresql start"
152 run_or_err "Creating PostgreSQL TestDB" "psql -c 'create database dbic_test;' -U postgres"
153 export DBICTEST_PG_DSN='dbi:Pg:database=dbic_test;host=127.0.0.1'
154 export DBICTEST_PG_USER=postgres
157 # poor man's deb config
159 spawn dpkg-reconfigure --frontend=text firebird2.5-super
160 expect "Enable Firebird server?"
161 send "\177\177\177\177yes\r"
162 expect "Password for SYSDBA"
168 # FIXME - this step still fails from time to time >:(((
169 # has to do with the FB reconfiguration I suppose
170 # for now if it fails twice - simply skip FB testing
173 run_or_err "Re-configuring Firebird" "
176 DEBIAN_FRONTEND=text sudo expect -c '$EXPECT_FB_SCRIPT'
179 if run_or_err "Creating Firebird TestDB" \
180 "echo \"CREATE DATABASE '/var/lib/firebird/2.5/data/dbic_test.fdb';\" | sudo isql-fb -u sysdba -p 123"
184 # Do not upgrade to a newer ODBC driver - smoking on an old
185 # and buggy POS is much more valuable
187 run_or_err "Fetching and building Firebird ODBC driver" '
189 wget -qO- https://github.com/dbsrgits/Firebird-ODBC-driver/archive/2.0.2.153.tar.gz | tar -zx --strip-components 1
191 make -f makefile.linux
192 sudo make -f makefile.linux install
195 sudo bash -c 'cat >> /etc/odbcinst.ini' <<< "
197 Description = InterBase/Firebird ODBC Driver
198 Driver = /usr/lib/x86_64-linux-gnu/libOdbcFb.so
199 Setup = /usr/lib/x86_64-linux-gnu/libOdbcFb.so
204 export DBICTEST_FIREBIRD_DSN=dbi:Firebird:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
205 export DBICTEST_FIREBIRD_USER=SYSDBA
206 export DBICTEST_FIREBIRD_PASS=123
208 export DBICTEST_FIREBIRD_INTERBASE_DSN=dbi:InterBase:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
209 export DBICTEST_FIREBIRD_INTERBASE_USER=SYSDBA
210 export DBICTEST_FIREBIRD_INTERBASE_PASS=123
212 export DBICTEST_FIREBIRD_ODBC_DSN="dbi:ODBC:Driver=Firebird;Dbname=/var/lib/firebird/2.5/data/dbic_test.fdb"
213 export DBICTEST_FIREBIRD_ODBC_USER=SYSDBA
214 export DBICTEST_FIREBIRD_ODBC_PASS=123
222 SRV_ORA_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
224 # without this some of the more zealous tests can exhaust the amount
225 # of listeners and oracle is too slow to spin extras up :(
226 sudo bash -c "echo -e '\nprocesses=150' >> $SRV_ORA_HOME/config/scripts/init.ora"
229 spawn /etc/init.d/oracle-xe configure
232 set send_slow {1 .005}
234 expect "Specify the HTTP port that will be used for Oracle Application Express"
238 expect "Specify a port that will be used for the database listener"
242 expect "Specify a password to be used for database accounts"
244 send -s "adminpass\r"
246 expect "Confirm the password"
248 send -s "adminpass\r"
250 expect "Do you want Oracle Database 10g Express Edition to be started on boot"
255 expect "Configuring Database"
262 # if we do not redirect to some random file, but instead try to capture
263 # into a var the way run_or_err does - everything hangs
264 # FIXME: I couldn't figure it out after 3 hours of headdesking,
265 # would be nice to know the reason eventually
266 run_or_err "Configuring OracleXE" "sudo $(which expect) -c '$EXPECT_ORA_SCRIPT' &>/tmp/ora_configure_10.2.log"
268 export DBICTEST_ORA_DSN=dbi:Oracle://localhost:1521/XE
269 export DBICTEST_ORA_USER=dbic_test
270 export DBICTEST_ORA_PASS=abc123456
271 export DBICTEST_ORA_EXTRAUSER_DSN="$DBICTEST_ORA_DSN"
272 export DBICTEST_ORA_EXTRAUSER_USER=dbic_test_extra
273 export DBICTEST_ORA_EXTRAUSER_PASS=abc123456
275 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 <<< '
276 CREATE USER $DBICTEST_ORA_USER IDENTIFIED BY $DBICTEST_ORA_PASS;
277 GRANT connect,resource TO $DBICTEST_ORA_USER;
278 CREATE USER $DBICTEST_ORA_EXTRAUSER_USER IDENTIFIED BY $DBICTEST_ORA_EXTRAUSER_PASS;
279 GRANT connect,resource TO $DBICTEST_ORA_EXTRAUSER_USER;
282 export ORACLE_HOME="$CACHE_DIR/poormanscache-OracleXE-10.2.0_deb_mixed/ora_instaclient/x86-64/oracle_instaclient_10.2.0.5.0"
285 # we may have skipped installation due to low memory
286 if dpkg -l db2exc &>/dev/null ; then
287 # WTF is this world-writable?
288 # Strip the write bit so it doesn't trip Ubuntu's symlink-in-/tmp attack mitigation
289 sudo chmod -R o-w ~dasusr1/das
291 export DB2_HOME=/opt/ibm/db2/V9.7
292 export DBICTEST_DB2_DSN=dbi:DB2:DATABASE=dbictest
293 export DBICTEST_DB2_USER=db2inst1
294 export DBICTEST_DB2_PASS=abc123456
296 run_or_err "Set up DB2 users" \
297 "echo -e '$DBICTEST_DB2_PASS\n$DBICTEST_DB2_PASS' | sudo passwd $DBICTEST_DB2_USER"
299 run_or_err "Create DB2 database" \
300 "sudo -u $DBICTEST_DB2_USER -i db2 'CREATE DATABASE dbictest' && sudo -u $DBICTEST_DB2_USER -i db2 'ACTIVATE DATABASE dbictest'"