Skip to content

Commit

Permalink
oracle support
Browse files Browse the repository at this point in the history
  • Loading branch information
deusaquilus committed Jan 11, 2019
1 parent 70cd9d6 commit 6fb113e
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 6 deletions.
46 changes: 46 additions & 0 deletions build/oracle_maven_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Maven settings file needed to configure wagon that will allow pulling jdbc driver to docker host -->
<settings>
<servers>
<server>
<id>maven.oracle.com</id>
<username>${OTN_USERNAME}</username>
<password>${OTN_PASSWORD}</password>
<configuration>
<basicAuthScope>
<host>ANY</host>
<port>ANY</port>
<realm>OAM 11g</realm>
</basicAuthScope>
<httpConfiguration>
<all>
<params>
<property>
<name>http.protocol.allow-circular-redirects</name>
<value>%b,true</value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
</servers>
<profiles>
<profile>
<id>main</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>maven.oracle.com</id>
<url>https://maven.oracle.com</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
</settings>
3 changes: 3 additions & 0 deletions build/oracle_setup/create_quill_test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alter session set "_ORACLE_SCRIPT"=true;
CREATE USER quill_test IDENTIFIED BY "QuillRocks!" QUOTA 50M ON system;
GRANT DBA TO quill_test;
14 changes: 14 additions & 0 deletions build/oracle_setup/external_check_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

echo "Setting up Oracle"

until sqlplus 'sys/Oradoc_db1@ORCLCDB as sysdba' < /home/oracle/setup/external_match_script.sql | grep "match_this_test_to_pass"; do
echo "Trying Again"
sleep 5;
done

until sqlplus 'sys/Oradoc_db1@ORCLCDB as sysdba' < /home/oracle/setup/external_match_script.sql

echo "Succeeded"
1 change: 1 addition & 0 deletions build/oracle_setup/external_match_script.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select 'match_this_test_to_pass' from DUAL;
31 changes: 31 additions & 0 deletions build/oracle_setup/external_setup_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

echo "Running Global Oracle Init"

# Start the oracle database
nohup ./dockerInit.sh &

# Save the pid which we need to wait for (otherwise container will exit)
pid=$!

echo "Waiting for Oracle Setup to Complete"

until source /home/oracle/.bashrc; sqlplus 'sys/Oradoc_db1@ORCLCDB as sysdba' < /oracle_setup/external_match_script.sql | grep "match_this_test_to_pass"; do
echo "Trying Again"
sleep 5;
done

echo "Sourcing In Main Body"
source /home/oracle/.bashrc
env

echo "Now Running Test script"
sqlplus 'sys/Oradoc_db1@ORCLCDB as sysdba' < /oracle_setup/create_quill_test.sql

#echo "Now Running Schema Setup"
#sqlplus 'quill_test/QuillRocks!@ORCLCDB as sysdba' < /quill_setup/oracle-schema.sql

echo "Oracle Setup Complete"

# Wait until oracle DB externally closed
wait $pid
20 changes: 19 additions & 1 deletion build/setup_db_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export SQLITE_SCRIPT=quill-jdbc/src/test/resources/sql/sqlite-schema.sql
export MYSQL_SCRIPT=quill-sql/src/test/sql/mysql-schema.sql
export POSTGRES_SCRIPT=quill-sql/src/test/sql/postgres-schema.sql
export SQL_SERVER_SCRIPT=quill-sql/src/test/sql/sqlserver-schema.sql
export ORACLE_SCRIPT=quill-sql/src/test/sql/oracle-schema.sql
export CASSANDRA_SCRIPT=quill-cassandra/src/test/cql/cassandra-schema.cql


Expand Down Expand Up @@ -88,8 +89,25 @@ function setup_sqlserver() {
/opt/mssql-tools/bin/sqlcmd -S $2 -U SA -P "QuillRocks!" -d quill_test -i $1
}

# Do a simple necat poll to make sure the oracle database is ready.
# All internal database creation and schema setup scripts are handled
# by the container and docker-compose setps.

function setup_oracle() {

while ! nc -z $2 1521; do
echo "Waiting for Oracle"
sleep 5;
done;
sleep 5;

echo "Connected to Oracle"
sleep 5
}

export -f setup_sqlite
export -f setup_mysql
export -f setup_postgres
export -f setup_cassandra
export -f setup_sqlserver
export -f setup_sqlserver
export -f setup_oracle
11 changes: 6 additions & 5 deletions build/setup_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ set -e
# import setup functions
. /app/build/setup_db_scripts.sh

time setup_sqlite $SQLITE_SCRIPT
time setup_mysql $MYSQL_SCRIPT mysql
time setup_postgres $POSTGRES_SCRIPT postgres
time setup_cassandra $CASSANDRA_SCRIPT cassandra
time setup_sqlserver $SQL_SERVER_SCRIPT sqlserver
#time setup_sqlite $SQLITE_SCRIPT
#time setup_mysql $MYSQL_SCRIPT mysql
#time setup_postgres $POSTGRES_SCRIPT postgres
#time setup_cassandra $CASSANDRA_SCRIPT cassandra
#time setup_sqlserver $SQL_SERVER_SCRIPT sqlserver
time setup_oracle $ORACLE_SCRIPT oracle

echo "Databases are ready!"
6 changes: 6 additions & 0 deletions build/setup_travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

time docker-compose up -d cassandra sqlserver orientdb

# import setup functions
Expand All @@ -22,6 +24,10 @@ send_script sqlserver $SQL_SERVER_SCRIPT sqlserver-schema.sql
send_script sqlserver ./build/setup_db_scripts.sh setup_db_scripts.sh
time docker-compose exec -T sqlserver bash -c ". setup_db_scripts.sh && setup_sqlserver sqlserver-schema.sql 127.0.0.1"

# setup oracle in docker (oracle scripts are setup by the oracle container directly)
send_script oracle ./build/setup_db_scripts.sh setup_db_scripts.sh
time docker-compose exec -T oracle bash -c ". setup_db_scripts.sh && setup_oracle unused_arg 127.0.0.1"

# setup cassandra in docker
send_script cassandra $CASSANDRA_SCRIPT cassandra-schema.cql
send_script cassandra ./build/setup_db_scripts.sh setup_db_scripts.sh
Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,42 @@ services:
- ACCEPT_EULA=Y
- SA_PASSWORD=QuillRocks!

oracle:
image: store/oracle/database-enterprise:12.2.0.1-slim
ports:
- "11521:1521"
volumes:
- ./build/oracle_setup:/oracle_setup
- ./quill-sql/src/test/sql/:/quill_setup
command: bash -c "cp /oracle_setup/* /home/oracle/setup && cd /home/oracle/setup && ./external_setup_script.sh"

#healthchecks:
# test: ["CMD", "bash", "-c", "/build/external_setup_script.sh"]
# retries: 100
# interval: 30s
# start_period: 120s:

# These 2 are only kept for local development

setup:
build:
context: .
dockerfile: ./build/Dockerfile-setup
depends_on:
- oracle
links:
- postgres:postgres
- mysql:mysql
- cassandra:cassandra
- orientdb:orientdb
- sqlserver:sqlserver
- oracle:oracle
volumes:
- ./:/app
command:
- ./build/setup_local.sh


sbt:
build:
context: .
Expand All @@ -69,6 +88,7 @@ services:
- cassandra:cassandra
- orientdb:orientdb
- sqlserver:sqlserver
- oracle:oracle
volumes:
- ./:/app
- ~/.ivy2:/root/.ivy2
Expand All @@ -82,6 +102,8 @@ services:
- MYSQL_PORT=3306
- SQL_SERVER_HOST=sqlserver
- SQL_SERVER_PORT=1433
- ORACLE_HOST=oracle
- ORACLE_PORT=1521
- CASSANDRA_HOST=cassandra
- CASSANDRA_PORT=9042
- ORIENTDB_HOST=orientdb
Expand Down
106 changes: 106 additions & 0 deletions quill-sql/src/test/sql/oracle-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
CREATE TABLE Person(
name VARCHAR(255),
age int
);

CREATE TABLE Couple(
her VARCHAR(255),
him VARCHAR(255)
);

CREATE TABLE Department(
dpt VARCHAR(255)
);

CREATE TABLE Employee(
emp VARCHAR(255),
dpt VARCHAR(255),
salary int
);

CREATE TABLE Task(
emp VARCHAR(255),
tsk VARCHAR(255)
);

CREATE TABLE EncodingTestEntity(
v1 VARCHAR(255),
v2 DECIMAL(5,2),
v3 SMALLINT,
v4 SMALLINT,
v5 SMALLINT,
v6 INTEGER,
v7 NUMBER,
v8 FLOAT,
v9 DOUBLE PRECISION,
v10 BLOB,
v11 TIMESTAMP,
v12 VARCHAR(255),
v13 DATE,
v14 VARCHAR(36),
o1 VARCHAR(255),
o2 DECIMAL(5,2),
o3 SMALLINT,
o4 SMALLINT,
o5 SMALLINT,
o6 INTEGER,
o7 NUMBER,
o8 FLOAT,
o9 DOUBLE PRECISION,
o10 BLOB,
o11 TIMESTAMP,
o12 VARCHAR(255),
o13 DATE,
o14 VARCHAR(36)
);


CREATE TABLE TestEntity(
s VARCHAR(255),
i INTEGER primary key,
l NUMBER,
o INTEGER
);

CREATE TABLE TestEntity2(
s VARCHAR(255),
i INTEGER,
l NUMBER
);

CREATE TABLE TestEntity3(
s VARCHAR(255),
i INTEGER,
l NUMBER
);

CREATE TABLE TestEntity4(
i INTEGER PRIMARY KEY
);

CREATE TABLE Product(
description VARCHAR(255),
id INTEGER PRIMARY KEY,
sku NUMBER
);

CREATE TABLE DateEncodingTestEntity (
v1 DATE,
v2 TIMESTAMP,
v3 TIMESTAMP WITH TIME ZONE
);

CREATE TABLE Contact(
firstName VARCHAR(255),
lastName VARCHAR(255),
age int,
addressFk int,
extraInfo VARCHAR(255)
);

CREATE TABLE Address(
id int,
street VARCHAR(255),
zip int,
otherExtraInfo VARCHAR(255)
);

0 comments on commit 6fb113e

Please sign in to comment.