From 22c8d5d8978adcf39626ec954f5ae241c6b9232a Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Mon, 27 Jun 2016 13:45:15 +0200 Subject: [PATCH] Initial import Imported from https://github.com/owncloud/administration/tree/612f25c5337f1aeb561172535a54304ab7867bce/travis-ci --- before_install.sh | 62 +++++++++++++ before_install_oracle.sh | 139 +++++++++++++++++++++++++++++ core_install.sh | 183 +++++++++++++++++++++++++++++++++++++++ custom.ini | 5 ++ setup_databases.sh | 25 ++++++ 5 files changed, 414 insertions(+) create mode 100755 before_install.sh create mode 100755 before_install_oracle.sh create mode 100755 core_install.sh create mode 100644 custom.ini create mode 100755 setup_databases.sh diff --git a/before_install.sh b/before_install.sh new file mode 100755 index 0000000..6586cfa --- /dev/null +++ b/before_install.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# +# ownCloud +# +# @author Thomas Müller +# @copyright 2014 Thomas Müller thomas.mueller@tmit.eu +# + +set -e + +WORKDIR=$PWD +APP_NAME=$1 +CORE_BRANCH=$2 +DB=$3 +echo "Work directory: $WORKDIR" +echo "Database: $DB" +cd .. +git clone --depth 1 -b $CORE_BRANCH https://github.com/nextcloud/server +cd core +git submodule update --init + +cd apps +cp -R ../../$APP_NAME/ . +cd $WORKDIR + +if [ "$DB" == "mysql" ] ; then + echo "Setting up mysql ..." + mysql -e 'create database oc_autotest;' + mysql -u root -e "CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY 'owncloud'"; + mysql -u root -e "grant all on oc_autotest.* to 'oc_autotest'@'localhost'"; + mysql -e "SELECT User FROM mysql.user;" +fi + +if [ "$DB" == "pgsql" ] ; then + createuser -U travis -s oc_autotest +fi + +if [ "$DB" == "oracle" ] ; then + if [ ! -f before_install_oracle.sh ]; then + wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install_oracle.sh + fi + bash ./before_install_oracle.sh +fi + +# +# copy custom php.ini settings +# +wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/custom.ini +if [ $(phpenv version-name) != 'hhvm' ]; then + phpenv config-add custom.ini +fi + + +# +# copy install script +# +cd ../core +if [ ! -f core_install.sh ]; then + wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/core_install.sh +fi + +bash ./core_install.sh $DB diff --git a/before_install_oracle.sh b/before_install_oracle.sh new file mode 100755 index 0000000..3647b86 --- /dev/null +++ b/before_install_oracle.sh @@ -0,0 +1,139 @@ +#!/bin/bash +# Script performs non-interactive installation of Oracle XE 10g on Debian +# +# Based on oracle10g-update.sh from HTSQL project: +# https://bitbucket.org/prometheus/htsql +# +# Modified by Mateusz Loskot +# Changes: +# - Add fake swap support (backup /usr/bin/free manually anyway!) +# +# Modified by Peter Butkovic to enable i386 install on amd64 architecture (precise 64) +# based on: http://www.ubuntugeek.com/how-to-install-oracle-10g-xe-in-64-bit-ubuntu.html +# +# set -ex + +# +# Utilities +# +function free_backup() +{ + # Multiple copies to be on safe side + sudo cp /usr/bin/free /root + sudo mv /usr/bin/free /usr/bin/free.original +} + +function free_restore() +{ + sudo cp /usr/bin/free.original /usr/bin/free +} + +# Install fake free +# http://www.axelog.de/2010/02/7-oracle-ee-refused-to-install-into-openvz/ +free_backup + +sudo tee /usr/bin/free < /dev/null +#!/bin/sh +cat <<__eof + total used free shared buffers cached +Mem: 1048576 327264 721312 0 0 0 +-/+ buffers/cache: 327264 721312 +Swap: 2000000 0 2000000 +__eof +exit +EOF + +sudo chmod 755 /usr/bin/free + +# +# ok, bc, is the dependency that is required by DB2 as well => let's remove it from oracle xe dependencies and provide 64bit one only +# +sudo apt-get update +#sudo apt-get -qq --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade + +# Install the Oracle 10g dependant packages +sudo apt-get install -qq --force-yes libc6:i386 +# travis needs the "apt-transport-https" to enable https transport +sudo apt-get install -qq bc apt-transport-https + +# add Oracle repo + key (please note https is a must here, otherwise "apt-get update" fails for this repo with the "Undetermined error") +sudo bash -c 'echo "deb https://oss.oracle.com/debian/ unstable main non-free" >/etc/apt/sources.list.d/oracle.list' +wget -q https://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | sudo apt-key add - +sudo apt-get --allow-unauthenticated update -qq + +# only download the package, to manually install afterwards +sudo apt-get install -qq --force-yes -d oracle-xe-universal:i386 +sudo apt-get install -qq --force-yes libaio:i386 + +# remove key + repo (to prevent failures on next updates) +sudo apt-key del B38A8516 +sudo bash -c 'rm -rf /etc/apt/sources.list.d/oracle.list' +sudo apt-get update -qq +sudo apt-get autoremove -qq + +# remove bc from the dependencies of the oracle-xe-universal package (to keep 64bit one installed) +mkdir /tmp/oracle_unpack +dpkg-deb -x /var/cache/apt/archives/oracle-xe-universal_10.2.0.1-1.1_i386.deb /tmp/oracle_unpack +cd /tmp/oracle_unpack +dpkg-deb --control /var/cache/apt/archives/oracle-xe-universal_10.2.0.1-1.1_i386.deb +sed -i "s/,\ bc//g" /tmp/oracle_unpack/DEBIAN/control +mkdir /tmp/oracle_repack +dpkg -b /tmp/oracle_unpack /tmp/oracle_repack/oracle-xe-universal_fixed_10.2.0.1-1.1_i386.deb + +# install Oracle 10g with the fixed dependencies, to prevent i386/amd64 conflicts on bc package +sudo dpkg -i --force-architecture /tmp/oracle_repack/oracle-xe-universal_fixed_10.2.0.1-1.1_i386.deb + +# Fix the problem when the configuration script eats the last +# character of the password if it is 'n': replace IFS="\n" with IFS=$'\n'. +sudo sed -i -e s/IFS=\"\\\\n\"/IFS=\$\'\\\\n\'/ /etc/init.d/oracle-xe + +# change shebang of nls_lang.sh +sudo sed -i 's/#!\/bin\/sh/#!\/bin\/bash/' /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh + +# Configure the server; provide the answers for the following questions: +# The HTTP port for Oracle Application Express: 8080 +# A port for the database listener: 1521 +# The password for the SYS and SYSTEM database accounts: admin +# Start the server on boot: yes +sudo /etc/init.d/oracle-xe configure <>~/.bashrc + +. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh +END + +free_restore + +# build php module +git clone https://github.com/DeepDiver1975/oracle_instant_client_for_ubuntu_64bit.git instantclient +cd instantclient +sudo bash -c 'printf "\n" | python system_setup.py' + +sudo mkdir -p /usr/lib/oracle/11.2/client64/rdbms/ +sudo ln -s /usr/include/oracle/11.2/client64/ /usr/lib/oracle/11.2/client64/rdbms/public + +sudo apt-get install -qq --force-yes libaio1 +if [ "$TRAVIS_PHP_VERSION" == "7" ] ; then + printf "/usr/lib/oracle/11.2/client64\n" | pecl install oci8 +else + printf "/usr/lib/oracle/11.2/client64\n" | pecl install oci8-2.0.10 +fi + +cat ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + +# add travis user to oracle user group - necessary for execution of sqlplus +sudo adduser travis dba diff --git a/core_install.sh b/core_install.sh new file mode 100755 index 0000000..5e10f22 --- /dev/null +++ b/core_install.sh @@ -0,0 +1,183 @@ +#!/bin/bash +# +# ownCloud +# +# @author Thomas Müller +# @copyright 2014 Thomas Müller thomas.mueller@tmit.eu +# + +set -e + +DATABASENAME=oc_autotest +DATABASEUSER=oc_autotest +ADMINLOGIN=admin +BASEDIR=$PWD + +DBCONFIGS="sqlite mysql pgsql oracle" +PHPUNIT=$(which phpunit) + +# set oracle home if it is not set +TRAVIS_ORACLE_HOME="/usr/lib/oracle/xe/app/oracle/product/10.2.0/server" +[ -z "$ORACLE_HOME" ] && ORACLE_HOME=$TRAVIS_ORACLE_HOME + +if [ $1 ]; then + FOUND=0 + for DBCONFIG in $DBCONFIGS; do + if [ $1 = $DBCONFIG ]; then + FOUND=1 + break + fi + done + if [ $FOUND = 0 ]; then + echo -e "Unknown database config name \"$1\"\n" >&2 + print_syntax + exit 2 + fi +fi + +# use tmpfs for datadir - should speedup unit test execution +DATADIR=$BASEDIR/data-autotest + +echo "Using database $DATABASENAME" + +# create autoconfig for sqlite, mysql and postgresql +cat > ./tests/autoconfig-sqlite.php < false, + 'dbtype' => 'sqlite', + 'dbtableprefix' => 'oc_', + 'adminlogin' => '$ADMINLOGIN', + 'adminpass' => 'admin', + 'directory' => '$DATADIR', +); +DELIM + +cat > ./tests/autoconfig-mysql.php < false, + 'dbtype' => 'mysql', + 'dbtableprefix' => 'oc_', + 'adminlogin' => '$ADMINLOGIN', + 'adminpass' => 'admin', + 'directory' => '$DATADIR', + 'dbuser' => '$DATABASEUSER', + 'dbname' => '$DATABASENAME', + 'dbhost' => 'localhost', + 'dbpass' => 'owncloud', +); +DELIM + +cat > ./tests/autoconfig-pgsql.php < false, + 'dbtype' => 'pgsql', + 'dbtableprefix' => 'oc_', + 'adminlogin' => '$ADMINLOGIN', + 'adminpass' => 'admin', + 'directory' => '$DATADIR', + 'dbuser' => '$DATABASEUSER', + 'dbname' => '$DATABASENAME', + 'dbhost' => 'localhost', + 'dbpass' => '', +); +DELIM + +cat > ./tests/autoconfig-oracle.php < false, + 'dbtype' => 'oci', + 'dbtableprefix' => 'oc_', + 'adminlogin' => '$ADMINLOGIN', + 'adminpass' => 'admin', + 'directory' => '$DATADIR', + 'dbuser' => '$DATABASENAME', + 'dbname' => 'XE', + 'dbhost' => 'localhost', + 'dbpass' => 'owncloud', + 'loglevel' => 0, +); +DELIM + +function execute_tests { + echo "Setup environment for $1 testing ..." + # back to root folder + cd $BASEDIR + + # revert changes to tests/data + git checkout tests/data/* + + # reset data directory + rm -rf $DATADIR + mkdir $DATADIR + + cp tests/preseed-config.php config/config.php + + if [ "$1" == "oracle" ] ; then + echo "Load Oracle environment variables so that we can run 'sqlplus'." + . $ORACLE_HOME/bin/oracle_env.sh + + echo "create the database" + sqlplus -s -l / as sysdba <