diff --git a/test/integration/testLargeResultSet.js b/test/integration/testLargeResultSet.js index 79d6194c9..8ea81853b 100644 --- a/test/integration/testLargeResultSet.js +++ b/test/integration/testLargeResultSet.js @@ -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 () { @@ -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 () => { @@ -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++) @@ -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)`; diff --git a/test/integration/testPutGet.js b/test/integration/testPutGet.js index 2e5ef67a0..5e8109c9e 100644 --- a/test/integration/testPutGet.js +++ b/test/integration/testPutGet.js @@ -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'; diff --git a/test/integration/testPutSmallFiles.js b/test/integration/testPutSmallFiles.js index 78b352d91..81e7b1c96 100644 --- a/test/integration/testPutSmallFiles.js +++ b/test/integration/testPutSmallFiles.js @@ -8,10 +8,12 @@ var os = require('os'); var path = require('path'); var testUtil = require('./testUtil'); const connOption = require('./connectionOptions'); +const {randomizeName} = require('./testUtil'); const DATABASE_NAME = connOption.valid.database; const SCHEMA_NAME = connOption.valid.schema; const WAREHOUSE_NAME = connOption.valid.warehouse; +const TABLE = randomizeName('TESTTBL'); var connection; var files = new Array(); @@ -20,7 +22,7 @@ function uploadFiles(callback, index = 0) { if(index < files.length) { - var putQuery = `PUT file://${files[index]} @${DATABASE_NAME}.${SCHEMA_NAME}.%TESTTBL`; + var putQuery = `PUT file://${files[index]} @${DATABASE_NAME}.${SCHEMA_NAME}.%${TABLE}`; var insertStmt = connection.execute({ sqlText: putQuery, complete: function (err, stmt) { @@ -46,10 +48,10 @@ describe('Test Put Small Files', function () { this.timeout(100000); var useWH = `use warehouse ${WAREHOUSE_NAME}`; - var createTable = `create or replace table ${DATABASE_NAME}.${SCHEMA_NAME}.TESTTBL(colA string, colB number, colC date, colD time, colE TIMESTAMP_NTZ, colF TIMESTAMP_TZ)`; - var copytInto = `copy into ${DATABASE_NAME}.${SCHEMA_NAME}.TESTTBL`; - var select1row = `select * from ${DATABASE_NAME}.${SCHEMA_NAME}.TESTTBL where colB = 3`; - var selectAll = `select count(*) AS NUM from ${DATABASE_NAME}.${SCHEMA_NAME}.TESTTBL`; + var createTable = `create or replace table ${DATABASE_NAME}.${SCHEMA_NAME}.${TABLE}(colA string, colB number, colC date, colD time, colE TIMESTAMP_NTZ, colF TIMESTAMP_TZ)`; + var copytInto = `copy into ${DATABASE_NAME}.${SCHEMA_NAME}.${TABLE}`; + var select1row = `select * from ${DATABASE_NAME}.${SCHEMA_NAME}.${TABLE} where colB = 3`; + var selectAll = `select count(*) AS NUM from ${DATABASE_NAME}.${SCHEMA_NAME}.${TABLE}`; var count = 5000; before(function (done) diff --git a/test/integration/testUtil.js b/test/integration/testUtil.js index ce9812077..a57131660 100644 --- a/test/integration/testUtil.js +++ b/test/integration/testUtil.js @@ -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({ @@ -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); +};