diff --git a/e2e-tests/.localconfig.js b/e2e-tests/.localconfig.js new file mode 100644 index 000000000..3fc7c3427 --- /dev/null +++ b/e2e-tests/.localconfig.js @@ -0,0 +1,7 @@ +module.exports = { + mysql: true, + postgres: true, + mssql: true, +// oracle: true, + sqlite: true, +}; diff --git a/e2e-tests/cypress/e2e/multi-sql.cy.js b/e2e-tests/cypress/e2e/multi-sql.cy.js index 60b19c0a3..3af3b2f6a 100644 --- a/e2e-tests/cypress/e2e/multi-sql.cy.js +++ b/e2e-tests/cypress/e2e/multi-sql.cy.js @@ -1,3 +1,5 @@ +const localconfig = require('../../.localconfig'); + Cypress.on('uncaught:exception', (err, runnable) => { // if the error message matches the one about WorkerGlobalScope importScripts if (err.message.includes("Failed to execute 'importScripts' on 'WorkerGlobalScope'")) { @@ -13,8 +15,18 @@ beforeEach(() => { }); function multiTest(testName, testDefinition) { - it(testName + ' MySQL', () => testDefinition('MySql-connection')); - it(testName + ' Postgres', () => testDefinition('Postgres-connection')); + if (localconfig.mysql) { + 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', () => { @@ -24,19 +36,31 @@ describe('Mutli-sql tests', () => { cy.testid('TabsPanel_buttonNewQuery').click(); cy.wait(1000); cy.get('body').type("INSERT INTO categories (category_id, category_name) VALUES (5, 'test');"); + + // rollback cy.testid('QueryTab_beginTransactionButton').click(); cy.contains('Query execution finished'); cy.testid('QueryTab_executeButton').click(); 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.contains('Guitars').click(); cy.testid('TableDataTab_refreshGrid').click(); cy.contains('Rows: 4'); + // commit 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.contains('Query execution finished'); + + // should contain 5 rows cy.testid('SqlObjectList_container').contains('categories').click(); cy.contains('Guitars').click(); cy.testid('TableDataTab_refreshGrid').click(); diff --git a/e2e-tests/data/my-guitar-shop/categories.table.yaml b/e2e-tests/data/my-guitar-shop/categories.table.yaml index 6ad63bdc2..c96f6d6db 100644 --- a/e2e-tests/data/my-guitar-shop/categories.table.yaml +++ b/e2e-tests/data/my-guitar-shop/categories.table.yaml @@ -3,7 +3,6 @@ columns: - name: category_id type: int default: null - autoIncrement: true notNull: true - name: category_name type: varchar(255) diff --git a/e2e-tests/docker-compose.yaml b/e2e-tests/docker-compose.yaml index 63b4c2ee1..b30d5a28c 100644 --- a/e2e-tests/docker-compose.yaml +++ b/e2e-tests/docker-compose.yaml @@ -49,3 +49,20 @@ services: image: redis ports: - 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 diff --git a/e2e-tests/env/multi-sql/.env b/e2e-tests/env/multi-sql/.env index 2954399d6..c3a6f2735 100644 --- a/e2e-tests/env/multi-sql/.env +++ b/e2e-tests/env/multi-sql/.env @@ -1,4 +1,4 @@ -CONNECTIONS=mysql,postgres +CONNECTIONS=mysql,postgres,mssql,oracle LABEL_mysql=MySql-connection SERVER_mysql=localhost @@ -15,3 +15,18 @@ PASSWORD_postgres=Pwd2020Db PORT_postgres=16000 ENGINE_postgres=postgres@dbgate-plugin-postgres 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 diff --git a/e2e-tests/init/multi-sql.js b/e2e-tests/init/multi-sql.js index 94507f372..866ab67bf 100644 --- a/e2e-tests/init/multi-sql.js +++ b/e2e-tests/init/multi-sql.js @@ -1,4 +1,5 @@ const path = require('path'); +const localconfig = require('../.localconfig'); const dbgateApi = require('dbgate-api'); dbgateApi.initializeApiEnvironment(); @@ -7,11 +8,15 @@ dbgateApi.registerPlugins(dbgatePluginMysql); const dbgatePluginPostgres = require('dbgate-plugin-postgres'); dbgateApi.registerPlugins(dbgatePluginPostgres); -async function createDb(connection, dropDbSql, createDbSql) { - await dbgateApi.executeQuery({ - connection, - sql: dropDbSql, - }); +async function createDb(connection, dropDbSql, createDbSql, database = 'my_guitar_shop') { + try { + await dbgateApi.executeQuery({ + connection, + sql: dropDbSql, + }); + } catch (err) { + console.error('Failed to drop database', err); + } await dbgateApi.executeQuery({ connection, @@ -21,36 +26,69 @@ async function createDb(connection, dropDbSql, createDbSql) { await dbgateApi.importDbFromFolder({ connection: { ...connection, - database: 'my_guitar_shop', + database, }, folder: path.resolve(path.join(__dirname, '../data/my-guitar-shop')), }); } async function run() { - await createDb( - { - server: process.env.SERVER_postgres, - user: process.env.USER_postgres, - password: process.env.PASSWORD_postgres, - port: process.env.PORT_postgres, - engine: 'postgres@dbgate-plugin-postgres', - }, - 'drop database if exists my_guitar_shop', - 'create database my_guitar_shop' - ); + if (localconfig.postgres) { + await createDb( + { + server: process.env.SERVER_postgres, + user: process.env.USER_postgres, + password: process.env.PASSWORD_postgres, + port: process.env.PORT_postgres, + engine: 'postgres@dbgate-plugin-postgres', + }, + 'drop database if exists my_guitar_shop', + 'create database my_guitar_shop' + ); + } - await createDb( - { - server: process.env.SERVER_mysql, - user: process.env.USER_mysql, - password: process.env.PASSWORD_mysql, - port: process.env.PORT_mysql, - engine: 'mysql@dbgate-plugin-mysql', - }, - 'drop database if exists my_guitar_shop', - 'create database my_guitar_shop' - ); + if (localconfig.mysql) { + await createDb( + { + server: process.env.SERVER_mysql, + user: process.env.USER_mysql, + password: process.env.PASSWORD_mysql, + port: process.env.PORT_mysql, + engine: 'mysql@dbgate-plugin-mysql', + }, + '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); diff --git a/workflow-templates/e2e-pro.yaml b/workflow-templates/e2e-pro.yaml index 071c263e9..c37b5e5be 100644 --- a/workflow-templates/e2e-pro.yaml +++ b/workflow-templates/e2e-pro.yaml @@ -109,3 +109,19 @@ jobs: image: redis ports: - 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