From 28f74d663b7695c437deeee795471fc6fb8e48bd Mon Sep 17 00:00:00 2001 From: Dominik Przybysz Date: Mon, 29 Jul 2024 14:35:41 +0200 Subject: [PATCH] SNOW-979081: Run perf test N runs --- test/integration/generic/generic_test.js | 132 ++++++++++++----------- 1 file changed, 72 insertions(+), 60 deletions(-) diff --git a/test/integration/generic/generic_test.js b/test/integration/generic/generic_test.js index aa7a8f8c5..0c38ba127 100644 --- a/test/integration/generic/generic_test.js +++ b/test/integration/generic/generic_test.js @@ -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, @@ -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); + } }); }); }); @@ -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) => { @@ -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); + } }); }); }); \ No newline at end of file