Skip to content

Commit

Permalink
SNOW-930831: Add randomization to the table name in put/get test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pmotacki committed Oct 5, 2023
1 parent 40f370c commit d83f3b9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
19 changes: 11 additions & 8 deletions test/integration/testLargeResultSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const assert = require('assert');
const async = require('async');
const testUtil = require('./testUtil');
const { configureLogger } = require('../configureLogger');
const {randomizeName} = require('./testUtil');

describe('Large result Set Tests', function ()
{
Expand Down Expand Up @@ -110,10 +111,12 @@ describe('Large result Set Tests', function ()

describe('Large Result Set Tests For Variant Column Type', function ()
{
const createTempTable = 'create or replace table testVariantTemp(value string)';
const createTableWithVariant = 'create or replace table testVariantTable(colA variant)';
const dropTableWithVariant = 'drop table if exists testVariantTable';
const dropTempTable = 'drop table if exists testVariantTemp';
const testVariantTemp = randomizeName('testVariantTemp');
const testVariantTable = randomizeName('testVariantTable');
const createTempTable = `create or replace table ${testVariantTemp} (value string)`;
const createTableWithVariant = `create or replace table ${testVariantTable} (colA variant)`;
const dropTableWithVariant = `drop table if exists ${testVariantTable}`;
const dropTempTable = `drop table if exists ${testVariantTemp} `;

before(async () =>
{
Expand All @@ -129,9 +132,9 @@ describe('Large result Set Tests', function ()

it('testSelectOnVariantColumnForLargeResultSets', function (done)
{
const insertTemp = 'insert into testVariantTemp values (?)';
const insertVariant = 'insert into testVariantTable select parse_json(value) from testVariantTemp';
const selectVariant = 'select * from testVariantTable';
const insertTemp = `insert into ${testVariantTemp} values (?)`;
const insertVariant = `insert into ${testVariantTable} select parse_json(value) from ${testVariantTemp}`;
const selectVariant = `select * from ${testVariantTable}`;

const arrJSON = [];
for (let i = 0; i < sourceRowCount; i++)
Expand Down Expand Up @@ -254,7 +257,7 @@ describe('Large result Set Tests', function ()

describe('SNOW-743920:Large result set with ~35 chunks', function () {
let connection;
const tableName = 'test_table';
const tableName = randomizeName('test_table');
const sourceRowCount = 251002;
const generatedRowSize = 350;
const createTable = `create or replace table ${tableName} (data string)`;
Expand Down
3 changes: 2 additions & 1 deletion test/integration/testPutGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ const tmp = require('tmp');
const os = require('os');
const path = require('path');
const zlib = require('zlib');
const {randomizeName} = require("./testUtil");

const DATABASE_NAME = connOption.valid.database;
const SCHEMA_NAME = connOption.valid.schema;
const TEMP_TABLE_NAME = 'TEMP_TABLE';
const TEMP_TABLE_NAME = randomizeName('TEMP_TABLE');

const SKIPPED = 'SKIPPED';
const UPLOADED = 'UPLOADED';
Expand Down
12 changes: 12 additions & 0 deletions test/integration/testUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const snowflake = require('./../../lib/snowflake');
const connOptions = require('./connectionOptions');
const assert = require('assert');
const fs = require('fs');
const crypto = require('crypto');

module.exports.createConnection = function (validConnectionOptionsOverride = {}) {
return snowflake.createConnection({
Expand Down Expand Up @@ -244,3 +245,14 @@ module.exports.deleteFolderSyncIgnoringErrors = function (directory) {
console.warn(`Cannot delete folder ${directory}: ${JSON.stringify(e)}`);
}
};

/**
* @param name string
*/
module.exports.randomizeName = function (name) {
if (name === null || name.trim() === '') {
throw new Error('Name must be non empty string');
}
const randomString = crypto.randomBytes(4).toString('hex');
return name.concat(randomString);
};

0 comments on commit d83f3b9

Please sign in to comment.