chore: MSSQL, Cockroachdb, Oracle tests on CI (#5293)

* enable cockroachdb, oracle builds on CircleCI
update mssql version

* make oracle tests work again (based on #4314)

* fix Oracle - repository > find options > locking

* proper hydralization of cockroach integer types

* linting
This commit is contained in:
Kononnable 2020-01-22 08:06:05 +01:00 committed by Umed Khudoiberdiev
parent 4c8ec25c8b
commit 2d3ad50220
14 changed files with 351 additions and 110 deletions

View File

@ -2,12 +2,10 @@
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
version: 2
jobs:
build:
common:
working_directory: ~/typeorm
docker:
# specify pre-built docker images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: circleci/node:10.15.0
- image: circleci/node:10.16.0
- image: mysql:5.7.24
environment:
MYSQL_ROOT_PASSWORD: "admin"
@ -23,58 +21,94 @@ jobs:
POSTGRES_PASSWORD: "test"
POSTGRES_DB: "test"
- image: circleci/mongo:3.4.18
# - image: "store/saplabs/hanaexpress:2.00.040.00.20190729.1"
# auth:
# username: $DOCKER_USER
# password: $DOCKER_PASSWORD
## name: hanaexpress
## container_name: "typeorm-hanaexpress"
## hostname: hxe
# command: ['--passwords-url', 'https://raw.githubusercontent.com/typeorm/typeorm/b119f7c3b8748aea9c77c7bc42b8e1be209b43ec/docker/hana/hxe-config.json', '--agree-to-sap-license']
## ulimits:
## nofile: 1048576
## sysctls:
## - kernel.shmmax=1073741824
## - net.ipv4.ip_local_port_range=40000 60999
## - kernel.shmmni=524288
## - kernel.shmall=8388608
## volumes:
## - volume-hana-xe:/hana/mounts
## - ./docker/hana/hxe-config.json:/hana/hxe-config.json
## ports:
## - 39013:39013
## - 39017:39017
## - 39041-39045:39041-39045
## - 1128-1129:1128-1129
## - 59013-59014:59013-59014
# - image: mcr.microsoft.com/mssql/server:2017-GA-ubuntu
# environment:
# SA_PASSWORD: "Admin12345"
# ACCEPT_EULA: "Y"
# - image: cockroachdb/cockroach-unstable:latest
# command: start --insecure
- image: mcr.microsoft.com/mssql/server:2017-latest-ubuntu
environment:
SA_PASSWORD: "Admin12345"
ACCEPT_EULA: "Y"
steps:
- checkout
- run: sudo npm install -g npm@latest
- run: cp ormconfig.circleci.json ormconfig.json
- run: cp ormconfig.circleci-common.json ormconfig.json
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
# - run: docker-compose up -d
# run tests
- run: npm run lint
- run: npm test
cockroachdb:
working_directory: ~/typeorm
docker:
- image: circleci/node:10.15.0
- image: cockroachdb/cockroach:latest
command: start --insecure
steps:
- checkout
- run: cp ormconfig.circleci-cockroach.json ormconfig.json
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: npm run lint
- run:
npm test
oracle:
working_directory: ~/typeorm
docker:
- image: circleci/node:10.16.0
- image: "store/oracle/database-enterprise:12.2.0.1-slim"
auth:
username: $DOCKER_USER
password: $DOCKER_PASSWORD
environment:
DB_SID: "sys"
SYS_PASSWORD: "ORCLCDB"
steps:
- run: if [ -z "$DOCKER_USER" ]; then echo "DOCKER_USER is unset"; circleci step halt; fi
- checkout
- run: sudo npm install -g npm@latest
- run: cp ormconfig.circleci-oracle.json ormconfig.json
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: wget https://download.oracle.com/otn_software/linux/instantclient/195000/instantclient-basiclite-linux.x64-19.5.0.0.0dbru.zip
- run: unzip instantclient-basiclite-linux.x64-19.5.0.0.0dbru.zip -d /tmp/oracle
- run: wget https://download.oracle.com/otn_software/linux/instantclient/195000/instantclient-sqlplus-linux.x64-19.5.0.0.0dbru.zip
- run: unzip instantclient-sqlplus-linux.x64-19.5.0.0.0dbru.zip -d /tmp/oracle
- run: echo "export LD_LIBRARY_PATH=/tmp/oracle/instantclient_19_5" >> $BASH_ENV
- run: sudo sh -c "echo /tmp/oracle/instantclient_19_5 > /etc/ld.so.conf.d/oracle-instantclient.conf";sudo ldconfig
- run: sh -c 'echo WHENEVER SQLERROR EXIT FAILURE > /tmp/user.sql; echo CREATE USER typeorm IDENTIFIED BY Passw0rd\; >> /tmp/user.sql; echo GRANT CONNECT TO typeorm\; >> /tmp/user.sql; echo GRANT UNLIMITED TABLESPACE TO typeorm\; >> /tmp/user.sql; echo exit >> /tmp/user.sql'
- run: sudo apt install libaio1
- run: until /tmp/oracle/instantclient_19_5/sqlplus -L -S sys/Oradoc_db1@//localhost:1521/orclpdb1.localdomain as sysdba @/tmp/user.sql ; do echo waiting for oracle; sleep 10; done;
- run: npm install oracledb --no-save
- run: npm run lint
- run: npm test
workflows:
version: 2
test:
jobs:
- common
- cockroachdb
- oracle

View File

@ -1,6 +1,5 @@
version: '3'
version: "3"
services:
# mysql-5.5
#mysql5.5:
# image: "mysql:5.5"
@ -53,7 +52,7 @@ services:
# mssql
mssql:
image: "mcr.microsoft.com/mssql/server:2017-GA-ubuntu"
image: "mcr.microsoft.com/mssql/server:2017-latest-ubuntu"
container_name: "typeorm-mssql"
ports:
- "1433:1433"
@ -70,27 +69,32 @@ services:
- "26257:26257"
# sap hana (works only on linux)
# hanaexpress:
# image: "store/saplabs/hanaexpress:2.00.040.00.20190729.1"
# container_name: "typeorm-hanaexpress"
# hostname: hxe
# command: ['--passwords-url', 'file:////hana/hxe-config.json', '--agree-to-sap-license']
# ulimits:
# nofile: 1048576
# sysctls:
# - kernel.shmmax=1073741824
# - net.ipv4.ip_local_port_range=40000 60999
# - kernel.shmmni=524288
# - kernel.shmall=8388608
# volumes:
# - volume-hana-xe:/hana/mounts
# - ./docker/hana/hxe-config.json:/hana/hxe-config.json
# ports:
# - 39013:39013
# - 39017:39017
# - 39041-39045:39041-39045
# - 1128-1129:1128-1129
# - 59013-59014:59013-59014
# hanaexpress:
# image: "store/saplabs/hanaexpress:2.00.040.00.20190729.1"
# container_name: "typeorm-hanaexpress"
# hostname: hxe
# command:
# [
# "--passwords-url",
# "file:////hana/hxe-config.json",
# "--agree-to-sap-license",
# ]
# ulimits:
# nofile: 1048576
# sysctls:
# - kernel.shmmax=1073741824
# - net.ipv4.ip_local_port_range=40000 60999
# - kernel.shmmni=524288
# - kernel.shmall=8388608
# volumes:
# - volume-hana-xe:/hana/mounts
# - ./docker/hana/hxe-config.json:/hana/hxe-config.json
# ports:
# - 39013:39013
# - 39017:39017
# - 39041-39045:39041-39045
# - 1128-1129:1128-1129
# - 59013-59014:59013-59014
# mongodb
mongodb:
@ -98,13 +102,11 @@ services:
container_name: "typeorm-mongodb"
ports:
- "27017:27017"
# redis
# redis:
# image: "redis:3.0.3"
# container_name: "typeorm-redis"
# ports:
# - "6379:6379"
#volumes:
# volume-hana-xe:

View File

@ -0,0 +1,92 @@
[
{
"skip": true,
"name": "mysql",
"type": "mysql",
"host": "localhost",
"port": 3306,
"username": "root",
"password": "admin",
"database": "test"
},
{
"skip": true,
"name": "mariadb",
"type": "mariadb",
"host": "mariadb",
"port": 3306,
"username": "root",
"password": "admin",
"database": "test"
},
{
"skip": true,
"name": "sqlite",
"type": "sqlite",
"database": "temp/sqlitedb.db"
},
{
"skip": true,
"name": "postgres",
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "test",
"password": "test",
"database": "test"
},
{
"skip": true,
"name": "sqljs",
"type": "sqljs"
},
{
"skip": true,
"name": "mssql",
"type": "mssql",
"host": "localhost",
"username": "sa",
"password": "Admin12345",
"database": "tempdb"
},
{
"skip": true,
"name": "sap",
"type": "sap",
"host": "localhost",
"port": 39015,
"username": "SYSTEM",
"password": "HXEHana1",
"database": "HXE",
"logging": false
},
{
"skip": true,
"disabledIfNotEnabledImplicitly": true,
"name": "mongodb",
"type": "mongodb",
"database": "test",
"useNewUrlParser": true,
"useUnifiedTopology": true
},
{
"skip": false,
"name": "cockroachdb",
"type": "cockroachdb",
"host": "localhost",
"port": 26257,
"username": "root",
"password": "",
"database": "defaultdb"
},
{
"skip": true,
"name": "oracle",
"type": "oracle",
"host": "localhost",
"username": "typeorm",
"password": "Passw0rd",
"port": 1521,
"sid": "orclpdb1.localdomain"
}
]

View File

@ -41,7 +41,7 @@
"type": "sqljs"
},
{
"skip": true,
"skip": false,
"name": "mssql",
"type": "mssql",
"host": "localhost",
@ -49,26 +49,6 @@
"password": "Admin12345",
"database": "tempdb"
},
{
"skip": true,
"name": "oracle",
"type": "oracle",
"host": "localhost",
"username": "system",
"password": "oracle",
"port": 1521,
"sid": "xe.oracle.docker"
},
{
"skip": true,
"name": "cockroachdb",
"type": "cockroachdb",
"host": "localhost",
"port": 26257,
"username": "root",
"password": "",
"database": "defaultdb"
},
{
"skip": true,
"name": "sap",
@ -88,5 +68,25 @@
"database": "test",
"useNewUrlParser": true,
"useUnifiedTopology": true
},
{
"skip": true,
"name": "cockroachdb",
"type": "cockroachdb",
"host": "localhost",
"port": 26257,
"username": "root",
"password": "",
"database": "defaultdb"
},
{
"skip": true,
"name": "oracle",
"type": "oracle",
"host": "localhost",
"username": "typeorm",
"password": "Passw0rd",
"port": 1521,
"sid": "orclpdb1.localdomain"
}
]

View File

@ -0,0 +1,92 @@
[
{
"skip": true,
"name": "mysql",
"type": "mysql",
"host": "localhost",
"port": 3306,
"username": "root",
"password": "admin",
"database": "test"
},
{
"skip": true,
"name": "mariadb",
"type": "mariadb",
"host": "mariadb",
"port": 3306,
"username": "root",
"password": "admin",
"database": "test"
},
{
"skip": true,
"name": "sqlite",
"type": "sqlite",
"database": "temp/sqlitedb.db"
},
{
"skip": true,
"name": "postgres",
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "test",
"password": "test",
"database": "test"
},
{
"skip": true,
"name": "sqljs",
"type": "sqljs"
},
{
"skip": true,
"name": "mssql",
"type": "mssql",
"host": "localhost",
"username": "sa",
"password": "Admin12345",
"database": "tempdb"
},
{
"skip": true,
"name": "sap",
"type": "sap",
"host": "localhost",
"port": 39015,
"username": "SYSTEM",
"password": "HXEHana1",
"database": "HXE",
"logging": false
},
{
"skip": true,
"disabledIfNotEnabledImplicitly": true,
"name": "mongodb",
"type": "mongodb",
"database": "test",
"useNewUrlParser": true,
"useUnifiedTopology": true
},
{
"skip": true,
"name": "cockroachdb",
"type": "cockroachdb",
"host": "localhost",
"port": 26257,
"username": "root",
"password": "",
"database": "defaultdb"
},
{
"skip": false,
"name": "oracle",
"type": "oracle",
"host": "localhost",
"username": "typeorm",
"password": "Passw0rd",
"port": 1521,
"sid": "orclpdb1.localdomain"
}
]

View File

@ -70,6 +70,17 @@
"password": "",
"database": "defaultdb"
},
{
"skip": true,
"name": "sap",
"type": "sap",
"host": "localhost",
"port": 39015,
"username": "SYSTEM",
"password": "HXEHana1",
"database": "HXE",
"logging": false
},
{
"skip": false,
"disabledIfNotEnabledImplicitly": true,

View File

@ -335,7 +335,8 @@ export class CockroachDriver implements Driver {
return columnMetadata.transformer ? ApplyValueTransformers.transformFrom(columnMetadata.transformer, value) : value;
// unique_rowid() generates bigint value and should not be converted to number
if ((columnMetadata.type === Number && !columnMetadata.isArray) || columnMetadata.generationStrategy === "increment") {
if (([Number, "int4", "smallint", "int2"].some(v => v === columnMetadata.type)
&& !columnMetadata.isArray) || columnMetadata.generationStrategy === "increment") {
value = parseInt(value);
} else if (columnMetadata.type === Boolean) {

View File

@ -1529,7 +1529,7 @@ export class OracleQueryRunner extends BaseQueryRunner implements QueryRunner {
if (column.isNullable !== true && !column.isGenerated) // NOT NULL is not supported with GENERATED
c += " NOT NULL";
if (column.isGenerated === true && column.generationStrategy === "increment")
c += " GENERATED ALWAYS AS IDENTITY";
c += " GENERATED BY DEFAULT AS IDENTITY";
return c;
}

View File

@ -839,17 +839,21 @@ export class EntityManager {
if (!findOptions || findOptions.loadEagerRelations !== false)
FindOptionsUtils.joinEagerRelations(qb, qb.alias, qb.expressionMap.mainAlias!.metadata);
findOptions = {
...(findOptions || {}),
take: 1,
};
const passedId = typeof idOrOptionsOrConditions === "string" || typeof idOrOptionsOrConditions === "number" || (idOrOptionsOrConditions as any) instanceof Date;
if (!passedId) {
findOptions = {
...(findOptions || {}),
take: 1,
};
}
FindOptionsUtils.applyOptionsToQueryBuilder(qb, findOptions);
if (options) {
qb.where(options);
} else if (typeof idOrOptionsOrConditions === "string" || typeof idOrOptionsOrConditions === "number" || (idOrOptionsOrConditions as any) instanceof Date) {
} else if (passedId) {
qb.andWhereInIds(metadata.ensureEntityIdMap(idOrOptionsOrConditions));
}

View File

@ -28,10 +28,10 @@ describe("database schema > column types > cockroachdb", () => {
post.id = 1;
post.name = "Post";
post.integer = "2147483647";
post.int4 = "2147483647";
post.int4 = 2147483647;
post.int = "2147483647";
post.smallint = "32767";
post.int2 = "32767";
post.smallint = 32767;
post.int2 = 32767;
post.bigint = "8223372036854775807";
post.int8 = "8223372036854775807";
post.int64 = "8223372036854775807";

View File

@ -19,16 +19,16 @@ export class Post {
integer: string;
@Column("int4")
int4: string;
int4: number;
@Column("int")
int: string;
@Column("smallint")
smallint: string;
smallint: number;
@Column("int2")
int2: string;
int2: number;
@Column("bigint")
bigint: string;

View File

@ -6,7 +6,9 @@ describe("table-inheritance > single-table > database-option-inherited", () => {
let connections: Connection[];
before(async () => connections = await createTestingConnections({
entities: [__dirname + "/entity/*{.js,.ts}"]
entities: [__dirname + "/entity/*{.js,.ts}"],
// creating more databases isn't always possible(e.g oracle official docker images)
enabledDrivers: ["postgres", "cockroachdb", "mariadb", "mssql", "mysql", "sqlite", "sqljs"]
}));
beforeEach(() => reloadTestingDatabases(connections));
after(() => closeTestingConnections(connections));

View File

@ -10,7 +10,9 @@ describe("github issues > #2518 TreeRepository.findDescendantsTree does not load
before(
async () =>
(connections = await createTestingConnections({
entities: [__dirname + "/entity/*{.js,.ts}"]
entities: [__dirname + "/entity/*{.js,.ts}"],
// data type text isn't compatible with oracle
enabledDrivers: ["postgres", "cockroachdb", "mariadb", "mssql", "mysql", "sqlite", "sqljs"]
}))
);

View File

@ -5,6 +5,7 @@ import {Connection} from "../../../src/connection/Connection";
import {Post} from "./entity/Post";
import {expect} from "chai";
import { Category } from "./entity/Category";
import { OracleDriver } from "../../../src/driver/oracle/OracleDriver";
describe("github issues > #3363 Isolation Level in transaction() from Connection", () => {
@ -17,8 +18,8 @@ describe("github issues > #3363 Isolation Level in transaction() from Connection
after(() => closeTestingConnections(connections));
it("should execute operations in READ UNCOMMITED isolation level", () => Promise.all(connections.map(async function(connection) {
// SAP does not support READ UNCOMMITTED isolation level
if (connection.driver instanceof SapDriver)
// SAP, Oracle does not support READ UNCOMMITTED isolation level
if (connection.driver instanceof SapDriver || connection.driver instanceof OracleDriver)
return;
let postId: number|undefined = undefined, categoryId: number|undefined = undefined;