mirror of
https://github.com/SOCI/soci.git
synced 2026-01-04 12:10:39 -06:00
Switch to using Oracle 11g Docker container
This should be simpler than installing it every time and seems to work more reliably in local testing.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Sets up environment for p6psy backend Oracle in CI builds
|
||||
#!/bin/bash -e
|
||||
# Configures Oracle database for SOCI Oracle backend CI builds.
|
||||
#
|
||||
# Copyright (c) 2013 Peter Butkovic <butkovic@gmail.com>
|
||||
#
|
||||
@@ -7,35 +7,32 @@
|
||||
# Changes:
|
||||
# - Check connection as user for testing
|
||||
#
|
||||
# Copyright (c) 2021 Vadim Zeitlin <vz-soci@zeitlins.org>
|
||||
# - Rewrote to work with Docker Oracle container
|
||||
|
||||
source ${SOCI_SOURCE_DIR}/scripts/ci/common.sh
|
||||
echo "ORACLE_HOME=${ORACLE_HOME}"
|
||||
echo "ORACLE_SID=${ORACLE_SID}"
|
||||
|
||||
# travis-oracle installer created travis user w/o password
|
||||
echo "ALTER USER travis IDENTIFIED BY travis;" | \
|
||||
$ORACLE_HOME/bin/sqlplus -S -L sys/travis AS SYSDBA
|
||||
|
||||
echo "grant connect, resource to travis;" | \
|
||||
$ORACLE_HOME/bin/sqlplus -S -L sys/travis AS SYSDBA
|
||||
|
||||
echo "grant create session, alter any procedure to travis;" | \
|
||||
$ORACLE_HOME/bin/sqlplus -S -L sys/travis AS SYSDBA
|
||||
|
||||
# to enable xa recovery, see: https://community.oracle.com/thread/378954
|
||||
echo "grant select on sys.dba_pending_transactions to travis;" | \
|
||||
$ORACLE_HOME/bin/sqlplus -S -L sys/travis AS SYSDBA
|
||||
echo "grant select on sys.pending_trans$ to travis;" | \
|
||||
$ORACLE_HOME/bin/sqlplus -S -L sys/travis AS SYSDBA
|
||||
echo "grant select on sys.dba_2pc_pending to travis;" | \
|
||||
$ORACLE_HOME/bin/sqlplus -S -L sys/travis AS SYSDBA
|
||||
echo "grant execute on sys.dbms_system to travis;" | \
|
||||
$ORACLE_HOME/bin/sqlplus -S -L sys/travis AS SYSDBA
|
||||
# create the user for the tests
|
||||
oracle_sqlplus sys/oracle AS SYSDBA <<SQL
|
||||
create user travis identified by travis;
|
||||
grant connect, resource to travis;
|
||||
grant execute on sys.dbms_lock to travis;
|
||||
grant create session, alter any procedure to travis;
|
||||
SQL
|
||||
|
||||
# increase default=40 value of processes to prevent ORA-12520 failures while testing
|
||||
echo "alter system set processes=100 scope=spfile;" | \
|
||||
$ORACLE_HOME/bin/sqlplus -S -L sys/travis AS SYSDBA
|
||||
echo "alter system set processes=300 scope=spfile;" | \
|
||||
oracle_sqlplus sys/oracle AS SYSDBA
|
||||
|
||||
# restart the database for the parameter change above to be taken into account
|
||||
echo "Restarting the database..."
|
||||
oracle_exec /etc/init.d/oracle-xe restart
|
||||
|
||||
# confirm the parameter modification was taken into account
|
||||
echo "show parameter processes;" | \
|
||||
oracle_sqlplus sys/oracle AS SYSDBA
|
||||
|
||||
# check connection as user for testing
|
||||
echo "Connecting using travis/travis@XE"
|
||||
echo "SELECT * FROM product_component_version;" | \
|
||||
$ORACLE_HOME/bin/sqlplus -S -L travis/travis@XE
|
||||
oracle_sqlplus travis/travis@XE
|
||||
|
||||
@@ -1,10 +1,41 @@
|
||||
#!/bin/bash
|
||||
# Script performs non-interactive installation of Oracle XE on Linux
|
||||
#!/bin/bash -e
|
||||
# Sets up Oracle database for SOCI Oracle backend CI builds.
|
||||
#
|
||||
# Uses Oracle downloader and installer from https://github.com/cbandy/travis-oracle
|
||||
#
|
||||
# set -ex
|
||||
source ${SOCI_SOURCE_DIR}/scripts/ci/common.sh
|
||||
|
||||
wget https://raw.githubusercontent.com/Vincit/travis-oracledb-xe/master/accept_the_license_agreement_for_oracledb_xe_11g_and_install.sh
|
||||
bash ./accept_the_license_agreement_for_oracledb_xe_11g_and_install.sh
|
||||
docker run --name ${ORACLE_CONTAINER} --detach --publish 1521:1521 -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g-r2
|
||||
|
||||
echo 'Waiting for Oracle startup...'
|
||||
num_tries=1
|
||||
wait_time=6 # seconds
|
||||
while true; do
|
||||
if oracle_exec /etc/init.d/oracle-xe status | grep -q 'Instance "XE", status READY'; then
|
||||
if echo "SELECT STATUS, DATABASE_STATUS FROM V\$INSTANCE WHERE INSTANCE_NAME='XE';" | \
|
||||
oracle_sqlplus sys/oracle AS SYSDBA | grep -q 'OPEN'; then
|
||||
echo 'Oracle database is available now'
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $num_tries -gt 50 ]]; then
|
||||
echo 'Timed out waiting for Oracle startup'
|
||||
break
|
||||
fi
|
||||
|
||||
echo "Waiting $wait_time more seconds (attempt #$num_tries)"
|
||||
sleep $wait_time
|
||||
((num_tries++))
|
||||
done
|
||||
|
||||
echo 'Oracle log:'
|
||||
docker logs --timestamps ${ORACLE_CONTAINER}
|
||||
echo 'Oracle global status:'
|
||||
oracle_exec /etc/init.d/oracle-xe status
|
||||
echo 'Oracle instance status:'
|
||||
echo 'SELECT INSTANCE_NAME, STATUS, DATABASE_STATUS FROM V$INSTANCE;' | \
|
||||
oracle_sqlplus sys/oracle AS SYSDBA
|
||||
|
||||
# Copy Oracle directory, notably containing the headers and the libraries
|
||||
# needed for the compilation, from the container.
|
||||
sudo mkdir -p ${ORACLE_HOME}
|
||||
sudo docker cp ${ORACLE_CONTAINER}:${ORACLE_HOME} ${ORACLE_HOME}/..
|
||||
|
||||
@@ -8,7 +8,7 @@ source ${SOCI_SOURCE_DIR}/scripts/ci/common.sh
|
||||
cmake ${SOCI_DEFAULT_CMAKE_OPTIONS} \
|
||||
-DWITH_BOOST=OFF \
|
||||
-DSOCI_ORACLE=ON \
|
||||
-DSOCI_ORACLE_TEST_CONNSTR:STRING="service=XE user=travis password=travis" \
|
||||
-DSOCI_ORACLE_TEST_CONNSTR:STRING="service=localhost/XE user=travis password=travis" \
|
||||
..
|
||||
|
||||
run_make
|
||||
|
||||
@@ -5,6 +5,23 @@
|
||||
# Notice that this file is not executable, it is supposed to be sourced from
|
||||
# the other files.
|
||||
|
||||
# Oracle environment required by https://github.com/Vincit/travis-oracledb-xe
|
||||
# This is arbitrary.
|
||||
export ORACLE_CONTAINER=oracle-11g
|
||||
|
||||
# We use the same name for the path inside and outside the container.
|
||||
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
|
||||
export ORACLE_SID=XE
|
||||
|
||||
# Execute any command in the Oracle container: pass the command with its
|
||||
# arguments directly to the function.
|
||||
oracle_exec()
|
||||
{
|
||||
docker exec ${ORACLE_CONTAINER} "$@"
|
||||
}
|
||||
|
||||
# Execute SQLPlus in the Oracle container: pass the extra arguments to the
|
||||
# command to this function and its input on stdin.
|
||||
oracle_sqlplus()
|
||||
{
|
||||
docker exec --interactive --env ORACLE_HOME=${ORACLE_HOME} --env ORACLE_SID=${ORACLE_SID} ${ORACLE_CONTAINER} "$ORACLE_HOME/bin/sqlplus" -S -L "$@"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user