Skip to content

Commit

Permalink
feat: add json type support for Oracle (#10611)
Browse files Browse the repository at this point in the history
* refactor: remove oracle docker tests and update DEVELOPER.md

Since oracle runs at thin mode now. Now extra docker tests are needed

* chore: increase oracle version to 21c

* feat: add json column types to oracle

* fix: try to resolve pipeline issue to increase oracle waiting time

* fix: try remove networks from oracle to fix pipeline

* fix: add container name

* fix: add missing oracledb driver in package-lock.json

* fix: corrected tests

* fix: remove tests, since only work with old oracle db

* fix: correct tests

* fix: remove deprecated types

* fix: add missing grant for materialized views

* fix: oracle-isolation.ts test

* fix: issue-3363.ts test

* fix: schema in tests
  • Loading branch information
ertl committed Jan 26, 2024
1 parent 4493db4 commit 7e85460
Show file tree
Hide file tree
Showing 23 changed files with 113 additions and 257 deletions.
26 changes: 6 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ commands:
command: |
if [ ! -d node_modules ]; then
npm install
npm install oracledb
fi
- save_cache:
name: Save node_modules cache
Expand Down Expand Up @@ -126,6 +125,9 @@ jobs:
- run:
name: Wait for Services to be Available
command: |
DEFAULT_WAIT_TIME=60
ORACLE_WAIT_TIME=120
COMMANDS=$(
cat ormconfig.json \
| jq -r '
Expand All @@ -139,31 +141,15 @@ jobs:
)
echo "Running '$COMMANDS'"
WAIT_TIME=$([ ! -z "$(jq -r '.[] | select(.skip == false and .name == "oracle")' ormconfig.json)" ] && echo "$ORACLE_WAIT_TIME" || echo "$DEFAULT_WAIT_TIME")
if [ ! -z "$COMMANDS" ]; then
docker run \
--network typeorm_default \
--tty \
ubuntu:trusty \
timeout 60 sh -c "until ($COMMANDS); do echo \"Waiting for Services to be Available ...\"; sleep 5; done"
timeout $WAIT_TIME sh -c "until ($COMMANDS); do echo \"Waiting for Services to be Available ...\"; sleep 5; done"
fi
- run:
name: "Wait for OracleDB to be Available"
command: |
COMMANDS=$(
cat ormconfig.json \
| jq -r '
map(select(.skip == false)
| select(.name == "oracle")
| "sleep 60"
)
| join(" && ")
'
)
if [ ! -z "$COMMANDS" ]; then
echo "$COMMANDS seconds to wait for oracledb";
$COMMANDS
fi
# Download and cache dependencies
- run:
name: "Run Tests with Coverage"
Expand Down
42 changes: 0 additions & 42 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ Install all TypeORM dependencies by running this command:
npm install
```

During installation, you may have some problems with some dependencies.
For example to properly install oracle driver you need to follow all instructions from
[node-oracle documentation](https://github.com/oracle/node-oracledb).

## ORM config

To create an initial `ormconfig.json` file, run the following command:
Expand Down Expand Up @@ -174,41 +170,3 @@ in the root of the project. Once all images are fetched and run you can run test

- The docker image of mssql-server needs at least 3.25GB of RAM.
- Make sure to assign enough memory to the Docker VM if you're running on Docker for Mac or Windows

### Oracle XE

In order to run tests on Oracle XE locally, we need to start 2 docker containers:

- a container with Oracle XE database
- a container with typeorm and its tests

#### 1. Booting Oracle XE database

Execute in shell the next command:

```shell
docker-compose up -d oracle
```

It will start an oracle instance only.
The instance will be run in background,
therefore, we need to stop it later on.

#### 2. Booting typeorm for Oracle

Execute in shell the next command:

```shell
docker-compose -f docker-compose.oracle.yml up
```

it will start a nodejs instance which builds typeorm and executes unit tests.
The instance exits after the run.

#### 3. Shutting down Oracle XE database

Execute in shell the next command:

```shell
docker-compose down
```
15 changes: 0 additions & 15 deletions docker-compose.oracle.yml

This file was deleted.

15 changes: 8 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ services:
ports:
- "26257:26257"

# oracle
oracle:
image: imnotjames/oracle-xe:18
build:
context: docker/oracle
container_name: "typeorm-oracle"
ports:
- "1521:1521"
networks:
- default
- typeorm
#volumes:
# - oracle-data:/opt/oracle/oradata
healthcheck:
test: [ "CMD", "/opt/oracle/checkDBStatus.sh" ]
interval: 2s

# google cloud spanner
spanner:
Expand Down Expand Up @@ -118,6 +122,3 @@ services:
#volumes:
# volume-hana-xe:
# mysql8_volume:

networks:
typeorm:
22 changes: 22 additions & 0 deletions docker/oracle/01_init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ALTER SESSION SET CONTAINER = XEPDB1;

CREATE TABLESPACE typeormspace32
DATAFILE 'typeormspace32.dbf'
SIZE 100M
AUTOEXTEND ON;

-- create users:
CREATE USER typeorm IDENTIFIED BY "oracle" DEFAULT TABLESPACE typeormspace32;

GRANT CREATE SESSION TO typeorm;
GRANT CREATE TABLE TO typeorm;
GRANT CREATE VIEW TO typeorm;
GRANT CREATE MATERIALIZED VIEW TO typeorm;
GRANT CREATE PROCEDURE TO typeorm;
GRANT CREATE SEQUENCE TO typeorm;

ALTER USER typeorm QUOTA UNLIMITED ON typeormspace32;

-- set password expiry to unlimited
ALTER PROFILE DEFAULT LIMIT PASSWORD_REUSE_TIME UNLIMITED;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
22 changes: 6 additions & 16 deletions docker/oracle/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
FROM node:12
FROM container-registry.oracle.com/database/express:21.3.0-xe

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -qq -y install libaio1 && \
apt-get -q -y autoremove && \
rm -Rf /var/lib/apt/lists/*
ENV ORACLE_PWD=oracle
ENV ORACLE_SID=XE
COPY 01_init.sql /docker-entrypoint-initdb.d/startup/
ENV PORT=1521

WORKDIR /typeorm
ENTRYPOINT ["/docker-entrypoint.sh"]

COPY . /
RUN chmod 0755 /docker-entrypoint.sh

ENV PATH="$PATH:/typeorm/node_modules/.bin"
ENV LD_LIBRARY_PATH="/typeorm/node_modules/oracledb/instantclient_19_8/:$LD_LIBRARY_PATH"
ENV BLOB_URL="https://download.oracle.com/otn_software/linux/instantclient/19800/instantclient-basiclite-linux.x64-19.8.0.0.0dbru.zip"

CMD ["npm", "run", "test-fast"]
EXPOSE ${PORT}
16 changes: 0 additions & 16 deletions docker/oracle/config/ormconfig.json

This file was deleted.

24 changes: 0 additions & 24 deletions docker/oracle/docker-entrypoint.d/030-npm-install.sh

This file was deleted.

12 changes: 0 additions & 12 deletions docker/oracle/docker-entrypoint.d/040-instantclient.sh

This file was deleted.

12 changes: 0 additions & 12 deletions docker/oracle/docker-entrypoint.d/050-npm-compile.sh

This file was deleted.

43 changes: 0 additions & 43 deletions docker/oracle/docker-entrypoint.sh

This file was deleted.

6 changes: 3 additions & 3 deletions ormconfig.circleci-common.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@
"type": "oracle",
"host": "typeorm-oracle",
"port": 1521,
"sid": "XE",
"username": "system",
"serviceName": "XEPDB1",
"username": "typeorm",
"password": "oracle",
"logging": false,
"extra": {
"connectString": "typeorm-oracle:1521/XE"
"connectString": "typeorm-oracle:1521/XEPDB1"
}
}
]
6 changes: 3 additions & 3 deletions ormconfig.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@
}
},
{
"skip": true,
"skip": false,
"name": "oracle",
"type": "oracle",
"host": "localhost",
"username": "system",
"username": "typeorm",
"password": "oracle",
"port": 1521,
"sid": "xe.oracle.docker",
"serviceName": "XEPDB1",
"logging": false
},
{
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

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

0 comments on commit 7e85460

Please sign in to comment.