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 879982b
Show file tree
Hide file tree
Showing 10 changed files with 198 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
include:
stage: release
if: type != pull_request
script:
script:
- travis_retry ./build/release.sh
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;
29 changes: 29 additions & 0 deletions build/oracle_setup/external_setup_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

echo "Running Global Oracle Init"

# Start the oracle database
nohup /entrypoint.sh &

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

echo "Waiting for Oracle Setup to Complete"

until source /root/.bashrc; sqlplus system/oracle@//localhost:1521/xe < /oracle_setup/external_match_script.sql | grep "match_this_test_to_pass"; do
echo "Trying Again"
sleep 5;
done

#source /root/.bashrc

echo "Setting Up Test Database"
sqlplus system/oracle@//localhost:1521/xe < /oracle_setup/create_quill_test.sql

echo "Setting Up Test Database Schema"
sqlplus system/oracle@//localhost:1521/xe < /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 steps.

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!"
4 changes: 4 additions & 0 deletions build/setup_travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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 oracle-schema.sql 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
16 changes: 15 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,34 @@ services:
- ACCEPT_EULA=Y
- SA_PASSWORD=QuillRocks!

# These 2 are only kept for local development
oracle:
image: sath89/oracle-12c
ports:
- "11521:1521"
volumes:
- ./build/oracle_setup:/oracle_setup
- ./quill-sql/src/test/sql/:/quill_setup
command: bash -c "mkdir /oracle_setup_local; cp /oracle_setup/* /oracle_setup_local && cd /oracle_setup_local && ./external_setup_script.sh"

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 +80,7 @@ services:
- cassandra:cassandra
- orientdb:orientdb
- sqlserver:sqlserver
- oracle:oracle
volumes:
- ./:/app
- ~/.ivy2:/root/.ivy2
Expand All @@ -82,6 +94,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 879982b

Please sign in to comment.