import SQL dump tests
Some checks failed
Run tests / test-runner (push) Has been cancelled

This commit is contained in:
Jan Prochazka 2024-09-27 08:33:16 +02:00
parent 5287a86397
commit cbf1b0a3cc
5 changed files with 32194 additions and 11 deletions

View File

@ -3,6 +3,7 @@ const stream = require('stream');
const { testWrapper } = require('../tools');
const tableWriter = require('dbgate-api/src/shell/tableWriter');
const copyStream = require('dbgate-api/src/shell/copyStream');
const importDatabase = require('dbgate-api/src/shell/importDatabase');
const fakeObjectReader = require('dbgate-api/src/shell/fakeObjectReader');
function createImportStream() {
@ -72,4 +73,29 @@ describe('DB Import', () => {
})
);
test.each(engines.filter(x => x.dumpFile).map(engine => [engine.label, engine]))(
'Import SQL dump - %s',
testWrapper(async (conn, driver, engine) => {
// const reader = await fakeObjectReader({ delay: 10 });
// const reader = await fakeObjectReader();
await importDatabase({
systemConnection: conn,
driver,
inputFile: engine.dumpFile,
});
const structure = await driver.analyseFull(conn);
for (const check of engine.dumpChecks || []) {
const res = await driver.query(conn, check.sql);
expect(res.rows[0].res.toString()).toEqual(check.res);
}
// const res1 = await driver.query(conn, `select count(*) as cnt from t1`);
// expect(res1.rows[0].cnt.toString()).toEqual('6');
// const res2 = await driver.query(conn, `select count(*) as cnt from t2`);
// expect(res2.rows[0].cnt.toString()).toEqual('6');
})
);
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,14 +8,14 @@ services:
ports:
- 15000:5432
# mariadb:
# image: mariadb
# command: --default-authentication-plugin=mysql_native_password
# restart: always
# ports:
# - 15004:3306
# environment:
# - MYSQL_ROOT_PASSWORD=Pwd2020Db
mariadb:
image: mariadb
command: --default-authentication-plugin=mysql_native_password
restart: always
ports:
- 15004:3306
environment:
- MYSQL_ROOT_PASSWORD=Pwd2020Db
# mysql:
# image: mysql:8.0.18

View File

@ -30,6 +30,13 @@ const engines = [
// skipOnCI: true,
objects: [views],
dbSnapshotBySeconds: true,
dumpFile: 'data/chinook-mysql.sql',
dumpChecks: [
{
sql: 'select count(*) as res from genre',
res: '25',
},
],
},
{
label: 'MariaDB',
@ -47,6 +54,13 @@ const engines = [
skipOnCI: true,
objects: [views],
dbSnapshotBySeconds: true,
dumpFile: 'data/chinook-mysql.sql',
dumpChecks: [
{
sql: 'select count(*) as res from genre',
res: '25',
},
],
},
{
label: 'PostgreSQL',
@ -83,6 +97,13 @@ const engines = [
],
supportSchemas: true,
defaultSchemaName: 'public',
dumpFile: 'data/chinook-postgre.sql',
dumpChecks: [
{
sql: 'select count(*) as res from "public"."Genre"',
res: '25',
},
],
},
{
label: 'SQL Server',
@ -164,10 +185,10 @@ const engines = [
const filterLocal = [
// filter local testing
'-MySQL',
'-MariaDB',
'-PostgreSQL',
'MariaDB',
'PostgreSQL',
'-SQL Server',
'SQLite',
'-SQLite',
'-CockroachDB',
'-ClickHouse',
];