mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-02-10 18:05:07 +08:00
[git actions] Oracle and mssql actions, unit test action
This commit is contained in:
60
.github/workflows/databasesTestsAaction.yml
vendored
60
.github/workflows/databasesTestsAaction.yml
vendored
@ -1,60 +0,0 @@
|
||||
name: check
|
||||
on: [push]
|
||||
jobs:
|
||||
mysql-tests:
|
||||
name: MYSQL database tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Run Mysql DB docker container
|
||||
run: docker run --name mysql -p 8080:3306 -p 8081:33060 -e MYSQL_HOST=127.0.0.1 -e MYSQL_ROOT_PASSWORD=onlyoffice -e MYSQL_DATABASE=onlyoffice -d mysql:latest
|
||||
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install modules
|
||||
run: |
|
||||
npm ci
|
||||
npm --prefix Common ci
|
||||
npm --prefix DocService ci
|
||||
|
||||
- name: Configure local IP
|
||||
run: |
|
||||
echo '{"services": {"CoAuthoring": {"sql": {"type": "mysql", "dbHost": "127.0.0.1", "dbPort": "8080", "dbUser": "root", "dbPass": "onlyoffice"}}}}' >> Common/config/local.json
|
||||
|
||||
- name : Creating schema
|
||||
run: |
|
||||
docker cp ./schema/mysql/createdb.sql mysql:/
|
||||
docker exec mysql mysql -h 127.0.0.1 -u root --password=onlyoffice -D onlyoffice -e 'source /createdb.sql'
|
||||
|
||||
- name: Run Jest
|
||||
run: npm exec -c 'cd ./DocService && jest baseConnector.tests.js --inject-globals=false --config=../tests/jest.config.js'
|
||||
|
||||
postgres-tests:
|
||||
name: Postgres database tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Run Postgres DB docker container
|
||||
run: docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=onlyoffice -e POSTGRES_USER=onlyoffice -e POSTGRES_DB=onlyoffice -d postgres:latest
|
||||
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install modules
|
||||
run: |
|
||||
npm ci
|
||||
npm --prefix Common ci
|
||||
npm --prefix DocService ci
|
||||
|
||||
- name: Configure local IP
|
||||
run: |
|
||||
echo '{"services": {"CoAuthoring": {"sql": {"dbHost": "127.0.0.1"}}}}' >> Common/config/local.json
|
||||
|
||||
- name : Creating schema
|
||||
run: |
|
||||
docker cp ./schema/postgresql/createdb.sql postgres:/
|
||||
docker exec postgres psql -d onlyoffice -U onlyoffice -a -f /createdb.sql
|
||||
|
||||
- name: Run Jest
|
||||
run: npm exec -c 'cd ./DocService && jest baseConnector.tests.js --inject-globals=false --config=../tests/jest.config.js'
|
||||
127
.github/workflows/databasesTestsWorkflow.yml
vendored
Normal file
127
.github/workflows/databasesTestsWorkflow.yml
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
name: Integration databases tests
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'DocService/sources/**Connector.js'
|
||||
jobs:
|
||||
oracle-tests:
|
||||
name: Oracle database tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Run Oracle DB docker container
|
||||
run: docker run --name oracle -p 8080:1521 -p 8081:5500 -e ORACLE_PASSWORD=admin -e APP_USER=onlyoffice -e APP_USER_PASSWORD=onlyoffice -d gvenzl/oracle-xe:21-slim
|
||||
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install modules
|
||||
run: |
|
||||
npm ci
|
||||
npm --prefix Common ci
|
||||
npm --prefix DocService ci
|
||||
|
||||
- name: Creating service DB configuration
|
||||
run: |
|
||||
echo '{"services": {"CoAuthoring": {"sql": {"type": "oracle", "dbHost": "127.0.0.1", "dbPort": "8080", "dbUser": "onlyoffice", "dbPass": "onlyoffice", "dbName": "xepdb1"}}}}' >> Common/config/local.json
|
||||
|
||||
- name: Await database service to finish startup
|
||||
run: sleep 15
|
||||
|
||||
- name: Creating schema
|
||||
run: |
|
||||
docker cp ./schema/oracle/createdb.sql oracle:/
|
||||
docker exec oracle sqlplus -s onlyoffice/onlyoffice@//localhost/xepdb1 @/createdb.sql
|
||||
|
||||
- name: Run Jest
|
||||
run: npm exec -c 'cd ./DocService && jest databaseTests --inject-globals=false --config=../tests/jest.config.js'
|
||||
|
||||
mssql-tests:
|
||||
name: MSSQL database tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Run MSSQL DB docker container
|
||||
run: docker run --name mssql -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=onlYoff1ce" -p 8080:1433 -d mcr.microsoft.com/mssql/server:2022-latest
|
||||
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install modules
|
||||
run: |
|
||||
npm ci
|
||||
npm --prefix Common ci
|
||||
npm --prefix DocService ci
|
||||
|
||||
- name: Creating service DB configuration
|
||||
run: |
|
||||
echo '{"services": {"CoAuthoring": {"sql": {"type": "mssql", "dbHost": "localhost", "dbPort": 8080, "dbUser": "sa", "dbPass": "onlYoff1ce"}}}}' >> Common/config/local.json
|
||||
|
||||
- name: Await database service to finish startup
|
||||
run: sleep 5
|
||||
|
||||
- name: Creating schema
|
||||
run: |
|
||||
docker cp ./schema/mssql/createdb.sql mssql:/
|
||||
docker exec mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P onlYoff1ce -i /createdb.sql
|
||||
|
||||
- name: Run Jest
|
||||
run: npm exec -c 'cd ./DocService && jest databaseTests --inject-globals=false --config=../tests/jest.config.js'
|
||||
|
||||
mysql-tests:
|
||||
name: MYSQL database tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Run Mysql DB docker container
|
||||
run: docker run --name mysql -p 8080:3306 -p 8081:33060 -e MYSQL_HOST=127.0.0.1 -e MYSQL_ROOT_PASSWORD=onlyoffice -e MYSQL_DATABASE=onlyoffice -d mysql:latest
|
||||
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install modules
|
||||
run: |
|
||||
npm ci
|
||||
npm --prefix Common ci
|
||||
npm --prefix DocService ci
|
||||
|
||||
- name: Creating service DB configuration
|
||||
run: |
|
||||
echo '{"services": {"CoAuthoring": {"sql": {"type": "mysql", "dbHost": "127.0.0.1", "dbPort": "8080", "dbUser": "root", "dbPass": "onlyoffice"}}}}' >> Common/config/local.json
|
||||
|
||||
- name : Creating schema
|
||||
run: |
|
||||
docker cp ./schema/mysql/createdb.sql mysql:/
|
||||
docker exec mysql mysql -h 127.0.0.1 -u root --password=onlyoffice -D onlyoffice -e 'source /createdb.sql'
|
||||
|
||||
- name: Run Jest
|
||||
run: npm exec -c 'cd ./DocService && jest databaseTests --inject-globals=false --config=../tests/jest.config.js'
|
||||
|
||||
postgres-tests:
|
||||
name: Postgres database tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Run Postgres DB docker container
|
||||
run: docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=onlyoffice -e POSTGRES_USER=onlyoffice -e POSTGRES_DB=onlyoffice -d postgres:latest
|
||||
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install modules
|
||||
run: |
|
||||
npm ci
|
||||
npm --prefix Common ci
|
||||
npm --prefix DocService ci
|
||||
|
||||
- name: Creating service DB configuration
|
||||
run: |
|
||||
echo '{"services": {"CoAuthoring": {"sql": {"dbHost": "127.0.0.1"}}}}' >> Common/config/local.json
|
||||
|
||||
- name : Creating schema
|
||||
run: |
|
||||
docker cp ./schema/postgresql/createdb.sql postgres:/
|
||||
docker exec postgres psql -d onlyoffice -U onlyoffice -a -f /createdb.sql
|
||||
|
||||
- name: Run Jest
|
||||
run: npm exec -c 'cd ./DocService && jest databaseTests --inject-globals=false --config=../tests/jest.config.js'
|
||||
24
.github/workflows/unitTestsWorkflow.yml
vendored
Normal file
24
.github/workflows/unitTestsWorkflow.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
name: Service unit tests
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.js'
|
||||
- '!tests/integration/**'
|
||||
- '!DocService/sources/**Connector.js'
|
||||
jobs:
|
||||
unit-tests:
|
||||
name: Service unit tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install modules
|
||||
run: |
|
||||
npm ci
|
||||
npm --prefix Common ci
|
||||
npm --prefix DocService ci
|
||||
|
||||
- name: Run Jest
|
||||
run: npm run "unit tests"
|
||||
@ -46,6 +46,7 @@ const cfgTableResult = config.get('services.CoAuthoring.sql.tableResult');
|
||||
var cfgDamengExtraOptions = config.get('services.CoAuthoring.sql.damengExtraOptions');
|
||||
|
||||
let pool = null;
|
||||
//todo add '?loginEncrypt=false' connectString query param to config(for docker on win)
|
||||
let connectString = `dm://${cfgDbUser}:${cfgDbPass}@${cfgDbHost}:${cfgDbPort}`;
|
||||
let connectionConfig = {
|
||||
connectString: connectString,
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
CREATE DATABASE onlyoffice;
|
||||
GO
|
||||
|
||||
USE onlyoffice;
|
||||
|
||||
CREATE TABLE doc_changes(
|
||||
@ -27,4 +30,6 @@ CREATE TABLE task_result (
|
||||
additional NVARCHAR(MAX) NULL,
|
||||
UNIQUE (tenant, id),
|
||||
CONSTRAINT unsigned_task_result CHECK(change_id BETWEEN 0 AND 4294967295 AND user_index BETWEEN 0 AND 4294967295)
|
||||
);
|
||||
);
|
||||
|
||||
GO
|
||||
@ -1,11 +1,11 @@
|
||||
const { describe, test, expect, afterAll } = require('@jest/globals');
|
||||
const config = require('../../Common/node_modules/config');
|
||||
const config = require('../../../Common/node_modules/config');
|
||||
|
||||
const baseConnector = require('../../DocService/sources/baseConnector');
|
||||
const operationContext = require('../../Common/sources/operationContext');
|
||||
const taskResult = require('../../DocService/sources/taskresult');
|
||||
const commonDefines = require('../../Common/sources/commondefines');
|
||||
const constants = require('../../Common/sources/constants');
|
||||
const baseConnector = require('../../../DocService/sources/baseConnector');
|
||||
const operationContext = require('../../../Common/sources/operationContext');
|
||||
const taskResult = require('../../../DocService/sources/taskresult');
|
||||
const commonDefines = require('../../../Common/sources/commondefines');
|
||||
const constants = require('../../../Common/sources/constants');
|
||||
const configSql = config.get('services.CoAuthoring.sql');
|
||||
|
||||
const ctx = new operationContext.Context();
|
||||
@ -300,6 +300,7 @@ describe('Base database connector', function () {
|
||||
const result = await baseConnector.getChangesPromise(ctx, docId, index, changesCount);
|
||||
expect(result.length).toEqual(changesCount);
|
||||
|
||||
dayBefore.setSeconds(dayBefore.getSeconds() + 1);
|
||||
const resultByDate = await baseConnector.getChangesPromise(ctx, docId, index, changesCount + additionalChangesCount, dayBefore);
|
||||
expect(resultByDate.length).toEqual(additionalChangesCount);
|
||||
});
|
||||
@ -1,11 +1,11 @@
|
||||
const { describe, test, expect, afterAll } = require('@jest/globals');
|
||||
const { describe, test, expect } = require('@jest/globals');
|
||||
|
||||
describe('Successful and failure tests', function () {
|
||||
test('Successful test', function () {
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Failure test', function () {
|
||||
test.skip('Failure test', function () {
|
||||
expect(true).toBeFalsy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user