mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 16:13:58 +00:00
SYNC: mutli-sql tests
This commit is contained in:
committed by
Diflow
parent
5b246fe44c
commit
afcb226111
7
e2e-tests/.localconfig.js
Normal file
7
e2e-tests/.localconfig.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
mysql: true,
|
||||||
|
postgres: true,
|
||||||
|
mssql: true,
|
||||||
|
// oracle: true,
|
||||||
|
sqlite: true,
|
||||||
|
};
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
const localconfig = require('../../.localconfig');
|
||||||
|
|
||||||
Cypress.on('uncaught:exception', (err, runnable) => {
|
Cypress.on('uncaught:exception', (err, runnable) => {
|
||||||
// if the error message matches the one about WorkerGlobalScope importScripts
|
// if the error message matches the one about WorkerGlobalScope importScripts
|
||||||
if (err.message.includes("Failed to execute 'importScripts' on 'WorkerGlobalScope'")) {
|
if (err.message.includes("Failed to execute 'importScripts' on 'WorkerGlobalScope'")) {
|
||||||
@@ -13,8 +15,18 @@ beforeEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function multiTest(testName, testDefinition) {
|
function multiTest(testName, testDefinition) {
|
||||||
it(testName + ' MySQL', () => testDefinition('MySql-connection'));
|
if (localconfig.mysql) {
|
||||||
it(testName + ' Postgres', () => testDefinition('Postgres-connection'));
|
it(testName + ' MySQL', () => testDefinition('MySql-connection'));
|
||||||
|
}
|
||||||
|
if (localconfig.postgres) {
|
||||||
|
it(testName + ' Postgres', () => testDefinition('Postgres-connection'));
|
||||||
|
}
|
||||||
|
if (localconfig.mssql) {
|
||||||
|
it(testName + ' Mssql', () => testDefinition('Mssql-connection'));
|
||||||
|
}
|
||||||
|
if (localconfig.oracle) {
|
||||||
|
it(testName + ' Oracle', () => testDefinition('Oracle-connection'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Mutli-sql tests', () => {
|
describe('Mutli-sql tests', () => {
|
||||||
@@ -24,19 +36,31 @@ describe('Mutli-sql tests', () => {
|
|||||||
cy.testid('TabsPanel_buttonNewQuery').click();
|
cy.testid('TabsPanel_buttonNewQuery').click();
|
||||||
cy.wait(1000);
|
cy.wait(1000);
|
||||||
cy.get('body').type("INSERT INTO categories (category_id, category_name) VALUES (5, 'test');");
|
cy.get('body').type("INSERT INTO categories (category_id, category_name) VALUES (5, 'test');");
|
||||||
|
|
||||||
|
// rollback
|
||||||
cy.testid('QueryTab_beginTransactionButton').click();
|
cy.testid('QueryTab_beginTransactionButton').click();
|
||||||
cy.contains('Query execution finished');
|
cy.contains('Query execution finished');
|
||||||
cy.testid('QueryTab_executeButton').click();
|
cy.testid('QueryTab_executeButton').click();
|
||||||
cy.contains('Query execution finished');
|
cy.contains('Query execution finished');
|
||||||
|
cy.testid('QueryTab_rollbackTransactionButton').click();
|
||||||
|
cy.contains('Query execution finished');
|
||||||
|
|
||||||
|
// should contain 4 rows
|
||||||
cy.testid('SqlObjectList_container').contains('categories').click();
|
cy.testid('SqlObjectList_container').contains('categories').click();
|
||||||
cy.contains('Guitars').click();
|
cy.contains('Guitars').click();
|
||||||
cy.testid('TableDataTab_refreshGrid').click();
|
cy.testid('TableDataTab_refreshGrid').click();
|
||||||
cy.contains('Rows: 4');
|
cy.contains('Rows: 4');
|
||||||
|
|
||||||
|
// commit
|
||||||
cy.contains('Query #1').click();
|
cy.contains('Query #1').click();
|
||||||
|
cy.testid('QueryTab_beginTransactionButton').click();
|
||||||
|
cy.contains('Query execution finished');
|
||||||
|
cy.testid('QueryTab_executeButton').click();
|
||||||
|
cy.contains('Query execution finished');
|
||||||
cy.testid('QueryTab_commitTransactionButton').click();
|
cy.testid('QueryTab_commitTransactionButton').click();
|
||||||
cy.contains('Query execution finished');
|
cy.contains('Query execution finished');
|
||||||
|
|
||||||
|
// should contain 5 rows
|
||||||
cy.testid('SqlObjectList_container').contains('categories').click();
|
cy.testid('SqlObjectList_container').contains('categories').click();
|
||||||
cy.contains('Guitars').click();
|
cy.contains('Guitars').click();
|
||||||
cy.testid('TableDataTab_refreshGrid').click();
|
cy.testid('TableDataTab_refreshGrid').click();
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ columns:
|
|||||||
- name: category_id
|
- name: category_id
|
||||||
type: int
|
type: int
|
||||||
default: null
|
default: null
|
||||||
autoIncrement: true
|
|
||||||
notNull: true
|
notNull: true
|
||||||
- name: category_name
|
- name: category_name
|
||||||
type: varchar(255)
|
type: varchar(255)
|
||||||
|
|||||||
@@ -49,3 +49,20 @@ services:
|
|||||||
image: redis
|
image: redis
|
||||||
ports:
|
ports:
|
||||||
- 16011:6379
|
- 16011:6379
|
||||||
|
|
||||||
|
mssql:
|
||||||
|
image: mcr.microsoft.com/mssql/server
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 16012:1433
|
||||||
|
environment:
|
||||||
|
- ACCEPT_EULA=Y
|
||||||
|
- SA_PASSWORD=Pwd2020Db
|
||||||
|
- MSSQL_PID=Express
|
||||||
|
|
||||||
|
oracle:
|
||||||
|
image: gvenzl/oracle-xe:21-slim
|
||||||
|
environment:
|
||||||
|
ORACLE_PASSWORD: Pwd2020Db
|
||||||
|
ports:
|
||||||
|
- 16013:1521
|
||||||
|
|||||||
17
e2e-tests/env/multi-sql/.env
vendored
17
e2e-tests/env/multi-sql/.env
vendored
@@ -1,4 +1,4 @@
|
|||||||
CONNECTIONS=mysql,postgres
|
CONNECTIONS=mysql,postgres,mssql,oracle
|
||||||
|
|
||||||
LABEL_mysql=MySql-connection
|
LABEL_mysql=MySql-connection
|
||||||
SERVER_mysql=localhost
|
SERVER_mysql=localhost
|
||||||
@@ -15,3 +15,18 @@ PASSWORD_postgres=Pwd2020Db
|
|||||||
PORT_postgres=16000
|
PORT_postgres=16000
|
||||||
ENGINE_postgres=postgres@dbgate-plugin-postgres
|
ENGINE_postgres=postgres@dbgate-plugin-postgres
|
||||||
DBCONFIG_postgres=[{"name":"PgChinook","connectionColor":"red"}]
|
DBCONFIG_postgres=[{"name":"PgChinook","connectionColor":"red"}]
|
||||||
|
|
||||||
|
LABEL_oracle=Oracle-connection
|
||||||
|
SERVER_oracle=localhost
|
||||||
|
USER_oracle=system
|
||||||
|
PASSWORD_oracle=Pwd2020Db
|
||||||
|
PORT_oracle=16013
|
||||||
|
ENGINE_oracle=oracle@dbgate-plugin-oracle
|
||||||
|
SERVICE_NAME_oracle=xe
|
||||||
|
|
||||||
|
LABEL_mssql=Mssql-connection
|
||||||
|
SERVER_mssql=localhost
|
||||||
|
USER_mssql=sa
|
||||||
|
PASSWORD_mssql=Pwd2020Db
|
||||||
|
PORT_mssql=16012
|
||||||
|
ENGINE_mssql=mssql@dbgate-plugin-mssql
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const localconfig = require('../.localconfig');
|
||||||
|
|
||||||
const dbgateApi = require('dbgate-api');
|
const dbgateApi = require('dbgate-api');
|
||||||
dbgateApi.initializeApiEnvironment();
|
dbgateApi.initializeApiEnvironment();
|
||||||
@@ -7,11 +8,15 @@ dbgateApi.registerPlugins(dbgatePluginMysql);
|
|||||||
const dbgatePluginPostgres = require('dbgate-plugin-postgres');
|
const dbgatePluginPostgres = require('dbgate-plugin-postgres');
|
||||||
dbgateApi.registerPlugins(dbgatePluginPostgres);
|
dbgateApi.registerPlugins(dbgatePluginPostgres);
|
||||||
|
|
||||||
async function createDb(connection, dropDbSql, createDbSql) {
|
async function createDb(connection, dropDbSql, createDbSql, database = 'my_guitar_shop') {
|
||||||
await dbgateApi.executeQuery({
|
try {
|
||||||
connection,
|
await dbgateApi.executeQuery({
|
||||||
sql: dropDbSql,
|
connection,
|
||||||
});
|
sql: dropDbSql,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to drop database', err);
|
||||||
|
}
|
||||||
|
|
||||||
await dbgateApi.executeQuery({
|
await dbgateApi.executeQuery({
|
||||||
connection,
|
connection,
|
||||||
@@ -21,36 +26,69 @@ async function createDb(connection, dropDbSql, createDbSql) {
|
|||||||
await dbgateApi.importDbFromFolder({
|
await dbgateApi.importDbFromFolder({
|
||||||
connection: {
|
connection: {
|
||||||
...connection,
|
...connection,
|
||||||
database: 'my_guitar_shop',
|
database,
|
||||||
},
|
},
|
||||||
folder: path.resolve(path.join(__dirname, '../data/my-guitar-shop')),
|
folder: path.resolve(path.join(__dirname, '../data/my-guitar-shop')),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
await createDb(
|
if (localconfig.postgres) {
|
||||||
{
|
await createDb(
|
||||||
server: process.env.SERVER_postgres,
|
{
|
||||||
user: process.env.USER_postgres,
|
server: process.env.SERVER_postgres,
|
||||||
password: process.env.PASSWORD_postgres,
|
user: process.env.USER_postgres,
|
||||||
port: process.env.PORT_postgres,
|
password: process.env.PASSWORD_postgres,
|
||||||
engine: 'postgres@dbgate-plugin-postgres',
|
port: process.env.PORT_postgres,
|
||||||
},
|
engine: 'postgres@dbgate-plugin-postgres',
|
||||||
'drop database if exists my_guitar_shop',
|
},
|
||||||
'create database my_guitar_shop'
|
'drop database if exists my_guitar_shop',
|
||||||
);
|
'create database my_guitar_shop'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await createDb(
|
if (localconfig.mysql) {
|
||||||
{
|
await createDb(
|
||||||
server: process.env.SERVER_mysql,
|
{
|
||||||
user: process.env.USER_mysql,
|
server: process.env.SERVER_mysql,
|
||||||
password: process.env.PASSWORD_mysql,
|
user: process.env.USER_mysql,
|
||||||
port: process.env.PORT_mysql,
|
password: process.env.PASSWORD_mysql,
|
||||||
engine: 'mysql@dbgate-plugin-mysql',
|
port: process.env.PORT_mysql,
|
||||||
},
|
engine: 'mysql@dbgate-plugin-mysql',
|
||||||
'drop database if exists my_guitar_shop',
|
},
|
||||||
'create database my_guitar_shop'
|
'drop database if exists my_guitar_shop',
|
||||||
);
|
'create database my_guitar_shop'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (localconfig.mssql) {
|
||||||
|
await createDb(
|
||||||
|
{
|
||||||
|
server: process.env.SERVER_mssql,
|
||||||
|
user: process.env.USER_mssql,
|
||||||
|
password: process.env.PASSWORD_mssql,
|
||||||
|
port: process.env.PORT_mssql,
|
||||||
|
engine: 'mssql@dbgate-plugin-mssql',
|
||||||
|
},
|
||||||
|
'drop database if exists my_guitar_shop',
|
||||||
|
'create database my_guitar_shop'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (localconfig.oracle) {
|
||||||
|
await createDb(
|
||||||
|
{
|
||||||
|
server: process.env.SERVER_oracle,
|
||||||
|
user: process.env.USER_oracle,
|
||||||
|
password: process.env.PASSWORD_oracle,
|
||||||
|
port: process.env.PORT_oracle,
|
||||||
|
engine: 'oracle@dbgate-plugin-oracle',
|
||||||
|
},
|
||||||
|
'DROP USER C##my_guitar_shop',
|
||||||
|
'CREATE USER c##my_guitar_shop IDENTIFIED BY my_guitar_shop DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp QUOTA 10M ON users',
|
||||||
|
'C##my_guitar_shop'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgateApi.runScript(run);
|
dbgateApi.runScript(run);
|
||||||
|
|||||||
@@ -109,3 +109,19 @@ jobs:
|
|||||||
image: redis
|
image: redis
|
||||||
ports:
|
ports:
|
||||||
- 16011:6379
|
- 16011:6379
|
||||||
|
|
||||||
|
mssql:
|
||||||
|
image: mcr.microsoft.com/mssql/server
|
||||||
|
ports:
|
||||||
|
- 16012:1433
|
||||||
|
env:
|
||||||
|
- ACCEPT_EULA=Y
|
||||||
|
- SA_PASSWORD=Pwd2020Db
|
||||||
|
- MSSQL_PID=Express
|
||||||
|
|
||||||
|
oracle:
|
||||||
|
image: gvenzl/oracle-xe:21-slim
|
||||||
|
env:
|
||||||
|
ORACLE_PASSWORD: Pwd2020Db
|
||||||
|
ports:
|
||||||
|
- 16013:1521
|
||||||
|
|||||||
Reference in New Issue
Block a user