Skip to content

Commit

Permalink
Implement oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
chaseWillden committed Oct 23, 2024
1 parent 8630a3a commit b338798
Show file tree
Hide file tree
Showing 26 changed files with 2,967 additions and 9 deletions.
43 changes: 42 additions & 1 deletion .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ jobs:
MYSQL_USER: njord_user
MYSQL_PASSWORD: njord_password

oracle:
image: gvenzl/oracle-free:latest
options: >-
--health-cmd="healthcheck.sh"
--health-interval=10s
--health-timeout=5s
--health-retries=10
ports:
- 1521:1521
- 5500:5500
env:
ORACLE_PASSWORD: njord_password
APP_USER: test
APP_USER_PASSWORD: test

steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -65,6 +80,7 @@ jobs:
- name: Running Integration Tests for SQLite
run: cargo test --test sqlite_tests

# MySQL related steps
- name: Wait for MySQL to be ready
run: |
until mysqladmin ping -h 127.0.0.1 --silent; do
Expand All @@ -74,7 +90,7 @@ jobs:
- name: Set up MySQL schema
env:
MYSQL_PWD: rootpassword
MYSQL_PWD: njord_rootpwd
run: |
echo "Injecting schema and data into MySQL..."
mysql -h 127.0.0.1 -u njord_user -pnjord_password njord_db < njord/db/test/mysql.sql
Expand All @@ -89,3 +105,28 @@ jobs:
MYSQL_PASSWORD: njord_password
MYSQL_HOST: 127.0.0.1
run: cargo test --test mysql_tests

# Oracle related steps
- name: Wait for Oracle to be ready
run: |
echo "Waiting for Oracle to be ready..."
until echo "exit" | sqlplus test/test@//127.0.0.1:1521/XEPDB1; do
echo "Waiting for Oracle to be ready..."
sleep 10
done
- name: Set up Oracle schema
run: |
echo "Injecting schema and data into Oracle..."
sqlplus test/test@//127.0.0.1:1521/XEPDB1 @njord/db/test/oracle/tests.sql
- name: Running Unit Tests for Oracle
run: cargo test oracle

- name: Running Integration Tests for Oracle
env:
ORACLE_DATABASE: XEPDB1
APP_USER: test
APP_USER_PASSWORD: test
ORACLE_HOST: 127.0.0.1
run: cargo test --test oracle_tests
161 changes: 156 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"njord_derive",
"njord_examples/sqlite",
"njord_examples/mysql",
"njord_examples/oracle",
]

resolver = "2"
24 changes: 22 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

services:
mysql:
image: mysql:8.0
Expand All @@ -16,5 +14,27 @@ services:
- ./njord_examples/mysql/init.sql:/docker-entrypoint-initdb.d/init.sql
- ./njord/db/test/mysql.sql:/docker-entrypoint-initdb.d/tests.sql

oracle:
image: gvenzl/oracle-free:latest
container_name: njord_oracle
environment:
ORACLE_PASSWORD: njord_password
APP_USER: test
APP_USER_PASSWORD: test
ports:
- "1521:1521"
- "5500:5500"
volumes:
- ./njord_examples/oracle/init_scripts:/container-entrypoint-initdb.d
- ./njord/db/test/oracle:/container-entrypoint-initdb.d
healthcheck:
test: ["CMD", "healthcheck.sh"]
interval: 10s
timeout: 5s
retries: 10
start_period: 5s
start_interval: 5s

volumes:
mysql_data:
oracle_data:
6 changes: 6 additions & 0 deletions njord/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ log = "0.4.22"
rand = "0.8.4"
serde = { version = "1.0.210", features = ["derive"] }
mysql = "25.0.1"
oracle = { version = "0.6.2", features = ["chrono"] }

[dev-dependencies]
njord_derive = { version = "0.4.0", path = "../njord_derive" }
Expand All @@ -35,6 +36,7 @@ njord_derive = { version = "0.4.0", path = "../njord_derive" }
default = ["sqlite"]
sqlite = []
mysql = []
oracle = []

[[test]]
name = "sqlite_tests"
Expand All @@ -43,3 +45,7 @@ path = "tests/sqlite/mod.rs"
[[test]]
name = "mysql_tests"
path = "tests/mysql/mod.rs"

[[test]]
name = "oracle_tests"
path = "tests/oracle/mod.rs"
Loading

0 comments on commit b338798

Please sign in to comment.