Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,5 @@ export class ClickHouseDbRunner extends BaseDbRunner {
return data;
}
}

export const dbRunner = new ClickHouseDbRunner();
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ import { ClickHouseQuery } from '../../../src/adapter/ClickHouseQuery';
import { prepareCompiler } from '../../../src/compiler/PrepareCompiler';

import { prepareJsCompiler } from '../../unit/PrepareCompiler';
import { ClickHouseDbRunner } from './ClickHouseDbRunner';
import { dbRunner } from './ClickHouseDbRunner';
import { logSqlAndParams } from '../../unit/TestUtil';

const itif = (condition, description, fn) => (condition ? it(description, fn) : it.skip(description, fn));

describe('ClickHouse DataSchemaCompiler', () => {
jest.setTimeout(200000);

const dbRunner = new ClickHouseDbRunner();

afterAll(async () => {
await dbRunner.tearDown();
});

it('gutter', () => {
const { compiler } = prepareJsCompiler(`
cube('visitors', {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { UserError } from '../../../src/compiler/UserError';
import { prepareJsCompiler } from '../../unit/PrepareCompiler';
import { ClickHouseDbRunner } from './ClickHouseDbRunner';
import { dbRunner } from './ClickHouseDbRunner';
import { debugLog, logSqlAndParams } from '../../unit/TestUtil';
import { ClickHouseQuery } from '../../../src/adapter/ClickHouseQuery';

describe('ClickHouse JoinGraph', () => {
jest.setTimeout(200000);

const dbRunner = new ClickHouseDbRunner();

afterAll(async () => {
await dbRunner.tearDown();
});

const { compiler, joinGraph, cubeEvaluator } = prepareJsCompiler(`
const perVisitorRevenueMeasure = {
type: 'number',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { dbRunner } from './ClickHouseDbRunner';

import './clickhouse-dataschema-compiler.suite';
import './clickhouse-graph-builder.suite';
import './complex-joins.suite';
import './custom-granularities.suite';

afterAll(async () => {
await dbRunner.tearDown();
});
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { prepareJsCompiler } from '../../unit/PrepareCompiler';
import { ClickHouseDbRunner } from './ClickHouseDbRunner';
import { dbRunner } from './ClickHouseDbRunner';

describe('ClickHouse complex joins', () => {
jest.setTimeout(20 * 1000);

const dbRunner = new ClickHouseDbRunner();

afterAll(async () => {
await dbRunner.tearDown();
});

const { compiler, joinGraph, cubeEvaluator } = prepareJsCompiler(`
cube(\`Acube\`, {
sql: \`SELECT * FROM (SELECT 1 as id, 'Category A' as category, 10 as value UNION ALL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { prepareYamlCompiler } from '../../unit/PrepareCompiler';
import { ClickHouseDbRunner } from './ClickHouseDbRunner';
import { dbRunner } from './ClickHouseDbRunner';

describe('Custom Granularities', () => {
jest.setTimeout(200000);

const dbRunner = new ClickHouseDbRunner();

afterAll(async () => {
await dbRunner.tearDown();
});

const { compiler, joinGraph, cubeEvaluator } = prepareYamlCompiler(`
cubes:
- name: orders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ export class MSSqlDbRunner extends BaseDbRunner {
return new MssqlQuery(compilers, query);
}
}

export const dbRunner = new MSSqlDbRunner();
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { prepareYamlCompiler } from '../../unit/PrepareCompiler';
import { MSSqlDbRunner } from './MSSqlDbRunner';
import { dbRunner } from './MSSqlDbRunner';

describe('Custom Granularities', () => {
jest.setTimeout(200000);

const dbRunner = new MSSqlDbRunner();

const { compiler, joinGraph, cubeEvaluator } = prepareYamlCompiler(`
cubes:
- name: orders
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { MssqlQuery } from '../../../src/adapter/MssqlQuery';
import { prepareJsCompiler } from '../../unit/PrepareCompiler';
import { MSSqlDbRunner } from './MSSqlDbRunner';
import { dbRunner } from './MSSqlDbRunner';

describe('MSSqlCumulativeMeasures', () => {
jest.setTimeout(200000);

const dbRunner = new MSSqlDbRunner();

afterAll(async () => {
await dbRunner.tearDown();
});

const { compiler, joinGraph, cubeEvaluator } = prepareJsCompiler(`
cube(\`visitors\`, {
sql: \`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import R from 'ramda';
import { MssqlQuery } from '../../../src/adapter/MssqlQuery';
import { prepareJsCompiler } from '../../unit/PrepareCompiler';
import { MSSqlDbRunner } from './MSSqlDbRunner';
import { dbRunner } from './MSSqlDbRunner';
import { createJoinedCubesSchema } from '../../unit/utils';

describe('MSSqlPreAggregations', () => {
jest.setTimeout(200000);

const dbRunner = new MSSqlDbRunner();

afterAll(async () => {
await dbRunner.tearDown();
});

const { compiler, joinGraph, cubeEvaluator } = prepareJsCompiler(`
cube(\`visitors\`, {
sql: \`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { MssqlQuery } from '../../../src/adapter/MssqlQuery';
import { prepareJsCompiler } from '../../unit/PrepareCompiler';
import { MSSqlDbRunner } from './MSSqlDbRunner';
import { dbRunner } from './MSSqlDbRunner';

describe('MSSqlUngrouped', () => {
jest.setTimeout(200000);

const dbRunner = new MSSqlDbRunner();

afterAll(async () => {
await dbRunner.tearDown();
});

const { compiler, joinGraph, cubeEvaluator } = prepareJsCompiler(`
const perVisitorRevenueMeasure = {
type: 'number',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { dbRunner } from './MSSqlDbRunner';

import './custom-granularities.suite';
import './mssql-cumulative-measures.suite';
import './mssql-pre-aggregations.suite';
import './mssql-ungrouped.suite';

afterAll(async () => {
await dbRunner.tearDown();
});
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ export class MySqlDbRunner extends BaseDbRunner {
return new MysqlQuery(compilers, query);
}
}

export const dbRunner = new MySqlDbRunner();
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { prepareYamlCompiler } from '../../unit/PrepareCompiler';
import { MySqlDbRunner } from './MySqlDbRunner';
import { dbRunner } from './MySqlDbRunner';

describe('Custom Granularities', () => {
jest.setTimeout(200000);

const dbRunner = new MySqlDbRunner();

const { compiler, joinGraph, cubeEvaluator } = prepareYamlCompiler(`
cubes:
- name: orders
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import R from 'ramda';
import { MysqlQuery } from '../../../src/adapter/MysqlQuery';
import { prepareJsCompiler } from '../../unit/PrepareCompiler';
import { MySqlDbRunner } from './MySqlDbRunner';
import { dbRunner } from './MySqlDbRunner';

describe('MySqlPreAggregations', () => {
jest.setTimeout(200000);

const dbRunner = new MySqlDbRunner();

afterAll(async () => {
await dbRunner.tearDown();
});

const { compiler, joinGraph, cubeEvaluator } = prepareJsCompiler(`
cube(\`visitors\`, {
sql: \`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { dbRunner } from './MySqlDbRunner';

import './custom-granularities.suite';
import './mysql-pre-aggregations.suite';

afterAll(async () => {
await dbRunner.tearDown();
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class PostgresDBRunner extends BaseDbRunner {
port,
password: this.password(),
database: 'model_test',
poolSize: 1,
poolSize: 10,
user: process.env.TEST_PG_USER || 'root',
});

Expand Down Expand Up @@ -146,12 +146,11 @@ export class PostgresDBRunner extends BaseDbRunner {
`pg_isready -h localhost -p ${this.port()} -U root -d model_test || exit 1`
],
interval: 1000,
timeout: 500,
timeout: 1000,
retries: 20,
startPeriod: 5 * 1000,
})
.withWaitStrategy(Wait.forHealthCheck())
.withStartupTimeout(15 * 1000)
.start();
}

Expand All @@ -169,8 +168,3 @@ export class PostgresDBRunner extends BaseDbRunner {
}

export const dbRunner = new PostgresDBRunner();

// eslint-disable-next-line no-undef
afterAll(async () => {
await dbRunner.tearDown();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { dbRunner } from './PostgresDBRunner';

// SQL generation and data schema tests
import './async-module.suite';
import './dataschema-compiler.suite';
import './member-expression.suite';
import './member-expressions-on-views.suite';
import './sql-generation-logic.suite';
import './sql-generation.suite';
import './yaml-compiler.suite';

afterAll(async () => {
await dbRunner.tearDown();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { dbRunner } from './PostgresDBRunner';

// Miscellaneous feature tests
import './bucketing.suite';
import './calc-groups.suite';
import './calendars.suite';
import './custom-granularities.suite';
import './multi-fact-join.suite';
import './multi-stage.suite';
import './multiple-join-paths.suite';
import './sub-query-dimensions.suite';

afterAll(async () => {
await dbRunner.tearDown();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { dbRunner } from './PostgresDBRunner';

// Pre-aggregation tests
import './pre-agg-allow-non-strict.suite';
import './pre-aggregations-alias.suite';
import './pre-aggregations-multi-stage.suite';
import './pre-aggregations-time.suite';
import './pre-aggregations.suite';

afterAll(async () => {
await dbRunner.tearDown();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { dbRunner } from './PostgresDBRunner';

// Views and join order tests
import './cube-views.suite';
import './view-deduplication.suite';
import './views-join-order-2.suite';
import './views-join-order-3.suite';
import './views-join-order-join-maps.suite';
import './views-join-order.suite';
import './views.suite';

afterAll(async () => {
await dbRunner.tearDown();
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import R from 'ramda';
import { PostgresQuery } from '../../../src/adapter/PostgresQuery';
import { prepareJsCompiler } from '../../unit/PrepareCompiler';
import { PostgresDBRunner } from './PostgresDBRunner';
import { dbRunner } from './PostgresDBRunner';

const SCHEMA_VARIANTS = [
// with references postfix
Expand Down Expand Up @@ -84,14 +84,11 @@ for (const [index, schema] of Object.entries(SCHEMA_VARIANTS)) {
describe(`PreAggregations in time hierarchy (schema #${index})`, () => {
jest.setTimeout(200000);

const dbRunner = new PostgresDBRunner();

afterAll(async () => {
await dbRunner.tearDown();
});

const { compiler, joinGraph, cubeEvaluator } = prepareJsCompiler(schema);

// Use schema index as base for suffix to avoid table name conflicts between schema variants
const baseSuffix = `s${index}`;

function replaceTableName(query, preAggregation, suffix) {
const [toReplace, params] = query;
console.log(toReplace);
Expand Down Expand Up @@ -137,7 +134,7 @@ for (const [index, schema] of Object.entries(SCHEMA_VARIANTS)) {
console.log(JSON.stringify(queries.concat(queryAndParams)));

return dbRunner.testQueries(
queries.concat([queryAndParams]).map(q => replaceTableName(q, preAggregationsDescription, 1))
queries.concat([queryAndParams]).map(q => replaceTableName(q, preAggregationsDescription, `${baseSuffix}_1`))
).then(res => {
console.log(JSON.stringify(res));
expect(res).toEqual(
Expand Down Expand Up @@ -197,7 +194,7 @@ for (const [index, schema] of Object.entries(SCHEMA_VARIANTS)) {
console.log(JSON.stringify(queries.concat(queryAndParams)));

return dbRunner.testQueries(
queries.concat([queryAndParams]).map(q => replaceTableName(q, preAggregationsDescription, 1))
queries.concat([queryAndParams]).map(q => replaceTableName(q, preAggregationsDescription, `${baseSuffix}_2`))
).then(res => {
console.log(JSON.stringify(res));
expect(res).toEqual(
Expand Down
Loading