Skip to content

Commit

Permalink
SNOW-979081: Run perf test N runs
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dprzybysz committed Jul 29, 2024
1 parent 8ce4d14 commit 28f74d6
Showing 1 changed file with 72 additions and 60 deletions.
132 changes: 72 additions & 60 deletions test/integration/generic/generic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const generic = require('../../../lib/generic');
const snowflake = require('../../../lib/snowflake');
const testUtil = require('../testUtil');

const repeatTimesPerfRun = 5;

describe.only('test generic binding', () => {
const connectionParams = {
username: process.env.SNOWFLAKE_TEST_USER,
Expand Down Expand Up @@ -99,60 +101,66 @@ describe.only('test generic binding', () => {
});

[10, 10000, 1000000].forEach(sourceRowCount => {
it(`GENERIC|${sourceRowCount}|${resultFormat}|ROWS`, () => {
const result = generic.executeQuery(connectionId,
`select randstr(10, random())
from table (generator(rowcount =>${sourceRowCount}))`);
assert.equal(result.length, sourceRowCount);
result.forEach(row => {
assert.ok(row);
assert.equal(row.length, 1);
assert.ok(row[0]);
});
});

it(`GENERIC|${sourceRowCount}|${resultFormat}|DELAYED`, () => {
const streamRowsSize = 1000;
const statementId = generic.executeQueryWithoutFetchingRows(connectionId,
`select randstr(10, random())
from table (generator(rowcount =>${sourceRowCount}))`);
assert.ok(statementId);
let fetchedRows = 0;
// eslint-disable-next-line no-constant-condition
while (true) {
const { rows, end } = generic.fetchNextRows(connectionId, statementId, streamRowsSize);
rows.forEach(row => {
it(`GENERIC|${sourceRowCount}|${resultFormat}|ROWS|${repeatTimesPerfRun}`, () => {
for (let i = 0; i < repeatTimesPerfRun; i++) {
const result = generic.executeQuery(connectionId,
`select randstr(10, random())
from table (generator(rowcount =>${sourceRowCount}))`);
assert.equal(result.length, sourceRowCount);
result.forEach(row => {
assert.ok(row);
assert.equal(row.length, 1);
assert.ok(row[0]);
++fetchedRows;
});
if (end) {
break;
}
}
assert.equal(fetchedRows, sourceRowCount);
});

it(`GENERIC|${sourceRowCount}|${resultFormat}|STREAM`, () => {
let fetchedRows = 0;
let invalidRows = 0;
const options = {
handleRow: row => {
if (row && row.length === 1 && row[0]) {
it(`GENERIC|${sourceRowCount}|${resultFormat}|DELAYED|${repeatTimesPerfRun}`, () => {
for (let i = 0; i < repeatTimesPerfRun; i++) {
const streamRowsSize = 1000;
const statementId = generic.executeQueryWithoutFetchingRows(connectionId,
`select randstr(10, random())
from table (generator(rowcount =>${sourceRowCount}))`);
assert.ok(statementId);
let fetchedRows = 0;
// eslint-disable-next-line no-constant-condition
while (true) {
const { rows, end } = generic.fetchNextRows(connectionId, statementId, streamRowsSize);
rows.forEach(row => {
assert.ok(row);
assert.equal(row.length, 1);
assert.ok(row[0]);
++fetchedRows;
} else {
++invalidRows;
});
if (end) {
break;
}
}
};
const result = generic.executeQuery(connectionId,
`select randstr(10, random())
from table (generator(rowcount =>${sourceRowCount}))`,
options);
assert.equal(result.length, 0);
assert.equal(invalidRows, 0);
assert.equal(fetchedRows, sourceRowCount);
assert.equal(fetchedRows, sourceRowCount);
}
});

it(`GENERIC|${sourceRowCount}|${resultFormat}|STREAM|${repeatTimesPerfRun}`, () => {
for (let i = 0; i < repeatTimesPerfRun; i++) {
let fetchedRows = 0;
let invalidRows = 0;
const options = {
handleRow: row => {
if (row && row.length === 1 && row[0]) {
++fetchedRows;
} else {
++invalidRows;
}
}
};
const result = generic.executeQuery(connectionId,
`select randstr(10, random())
from table (generator(rowcount =>${sourceRowCount}))`,
options);
assert.equal(result.length, 0);
assert.equal(invalidRows, 0);
assert.equal(fetchedRows, sourceRowCount);
}
});
});
});
Expand Down Expand Up @@ -183,16 +191,18 @@ describe.only('Perf selects standard nodejs', () => {
[10, 10000, 1000000].forEach(sourceRowCount => {
const resultFormat = 'JSON';

it(`NODEJS|${sourceRowCount}|${resultFormat}|ROWS`, async () => {
const result = await testUtil.executeCmdAsync(connection,
`select randstr(10, random()) as a
from table (generator(rowcount =>${sourceRowCount}))`,
);
assert.equal(result.length, sourceRowCount);
result.forEach(row => {
assert.ok(row);
assert.ok(row['A']);
});
it(`NODEJS|${sourceRowCount}|${resultFormat}|ROWS|${repeatTimesPerfRun}`, async () => {
for (let i = 0; i < repeatTimesPerfRun; i++) {
const result = await testUtil.executeCmdAsync(connection,
`select randstr(10, random()) as a
from table (generator(rowcount =>${sourceRowCount}))`,
);
assert.equal(result.length, sourceRowCount);
result.forEach(row => {
assert.ok(row);
assert.ok(row['A']);
});
}
});

const countRows = (connection, sqlText, validateRow) => {
Expand All @@ -219,12 +229,14 @@ describe.only('Perf selects standard nodejs', () => {
});
};

it(`NODEJS|${sourceRowCount}|${resultFormat}|STREAM`, async () => {
const rowLength = await countRows(connection,
`select randstr(10, random()) as a
from table (generator(rowcount =>${sourceRowCount}))`,
row => row && row['A']);
assert.equal(rowLength, sourceRowCount);
it(`NODEJS|${sourceRowCount}|${resultFormat}|STREAM|${repeatTimesPerfRun}`, async () => {
for (let i = 0; i < repeatTimesPerfRun; i++) {
const rowLength = await countRows(connection,
`select randstr(10, random()) as a
from table (generator(rowcount =>${sourceRowCount}))`,
row => row && row['A']);
assert.equal(rowLength, sourceRowCount);
}
});
});
});

0 comments on commit 28f74d6

Please sign in to comment.