It appears that travis drastically increased the amount of available CPUs
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 10_before_install.bash
1 #!/bin/bash
2
3 source maint/travis-ci_scripts/common.bash
4 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
5
6 # .travis.yml already restricts branches to master, topic/* and smoke/*
7 # do some extra short-circuiting here
8
9 # when smoking master do not attempt bleadperl (not release-critical)
10 if [[ "$TRAVIS_BRANCH" = "master" ]] && [[ "$BREWVER" = "blead" ]]; then
11   echo_err "$(tstamp) master branch is not smoked with bleadperl - bailing out"
12   export SHORT_CIRCUIT_SMOKE=1
13 fi
14
15 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
16
17 # Different boxes we run on may have different amount of hw threads
18 # Hence why we need to query
19 # Originally we used to read /sys/devices/system/cpu/online
20 # but it is not available these days (odd). Thus we fall to
21 # the alwas-present /proc/cpuinfo
22 # The oneliner is a tad convoluted - basicaly what we do is
23 # slurp the entire file and get the index off the last
24 # `processor    : XX` line
25 export NUMTHREADS=$(( $(perl -0777 -n -e 'print (/ (?: .+ ^ processor \s+ : \s+ (\d+) ) (?! ^ processor ) /smx)' < /proc/cpuinfo) + 1 ))
26
27 if [[ "$CLEANTEST" != "true" ]]; then
28 ### apt-get invocation - faster to grab everything at once
29   #
30   # FIXME these debconf lines should automate the firebird config but do not :(((
31   sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/enabled\tboolean\ttrue" | debconf-set-selections'
32   sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/sysdba_password/new_password\tpassword\t123" | debconf-set-selections'
33
34   APT_PACKAGES="memcached firebird2.5-super firebird2.5-dev expect"
35   run_or_err "Installing packages ($APT_PACKAGES)" "sudo apt-get install --allow-unauthenticated -y $APT_PACKAGES"
36
37 ### config memcached
38   export DBICTEST_MEMCACHED=127.0.0.1:11211
39
40 ### config mysql
41   run_or_err "Creating MySQL TestDB" "mysql -e 'create database dbic_test;'"
42   export DBICTEST_MYSQL_DSN='dbi:mysql:database=dbic_test;host=127.0.0.1'
43   export DBICTEST_MYSQL_USER=root
44
45 ### config pg
46   run_or_err "Creating PostgreSQL TestDB" "psql -c 'create database dbic_test;' -U postgres"
47   export DBICTEST_PG_DSN='dbi:Pg:database=dbic_test;host=127.0.0.1'
48   export DBICTEST_PG_USER=postgres
49
50 ### conig firebird
51   # poor man's deb config
52   EXPECT_FB_SCRIPT='
53     spawn dpkg-reconfigure --frontend=text firebird2.5-super
54     expect "Enable Firebird server?"
55     send "\177\177\177\177yes\r"
56     expect "Password for SYSDBA"
57     send "123\r"
58     sleep 1
59     wait
60     sleep 1
61   '
62   # creating testdb
63   # FIXME - this step still fails from time to time >:(((
64   # has to do with the FB reconfiguration I suppose
65   # for now if it fails twice - simply skip FB testing
66   for i in 1 2 ; do
67
68     run_or_err "Re-configuring Firebird" "
69       sync
70       DEBIAN_FRONTEND=text sudo expect -c '$EXPECT_FB_SCRIPT'
71       sleep 1
72       sync
73       # restart the server for good measure
74       sudo /etc/init.d/firebird2.5-super stop || true
75       sleep 1
76       sync
77       sudo /etc/init.d/firebird2.5-super start
78       sleep 1
79       sync
80     "
81
82     if run_or_err "Creating Firebird TestDB" \
83       "echo \"CREATE DATABASE '/var/lib/firebird/2.5/data/dbic_test.fdb';\" | sudo isql-fb -u sysdba -p 123"
84     then
85       export DBICTEST_FIREBIRD_DSN=dbi:Firebird:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
86       export DBICTEST_FIREBIRD_USER=SYSDBA
87       export DBICTEST_FIREBIRD_PASS=123
88
89       export DBICTEST_FIREBIRD_INTERBASE_DSN=dbi:InterBase:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
90       export DBICTEST_FIREBIRD_INTERBASE_USER=SYSDBA
91       export DBICTEST_FIREBIRD_INTERBASE_PASS=123
92
93       break
94     fi
95
96   done
97
98 ### oracle
99   # FIXME: todo
100   #DBICTEST_ORA_DSN=dbi:Oracle:host=localhost;sid=XE
101   #DBICTEST_ORA_USER=dbic_test
102   #DBICTEST_ORA_PASS=123
103   #DBICTEST_ORA_EXTRAUSER_DSN=dbi:Oracle:host=localhost;sid=XE
104   #DBICTEST_ORA_EXTRAUSER_USER=dbic_test_extra
105   #DBICTEST_ORA_EXTRAUSER_PASS=123
106   #ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client
107 fi