Skip to content

Commit

Permalink
SNOW-1843504 - Testing resubmitting requests using request id
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pmotacki committed Dec 4, 2024
1 parent 10c46ef commit 56d2b0d
Showing 1 changed file with 25 additions and 43 deletions.
68 changes: 25 additions & 43 deletions test/integration/testExecute.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ describe('Execute test - variant', function () {
it(testCase.name, createItCallback(testCase, rowAsserts));
});

describe.only( 'connection.execute() Resubmitting requests using requestId and different connections', function () {
describe( 'connection.execute() Resubmitting requests using requestId and different connections', function () {
const createTable = 'create or replace table test_request_id(colA string)';
let firstConnection;
let secondConnection;
Expand All @@ -441,7 +441,6 @@ describe('Execute test - variant', function () {
secondConnection = testUtil.createConnection();
await testUtil.connectAsync(firstConnection);
await testUtil.connectAsync(secondConnection);
await testUtil.executeCmdAsync(firstConnection, 'truncate table if exists test_request_id');
await testUtil.executeCmdAsync(firstConnection, createTable);
});

Expand All @@ -451,65 +450,48 @@ describe('Execute test - variant', function () {

after(async () => {
await testUtil.executeCmdAsync(firstConnection, 'drop table if exists test_request_id');
await testUtil.destroyConnectionAsync(firstConnection);
await testUtil.destroyConnectionAsync(secondConnection);
});

it('Do not INSERT twice when the same request id and connection', async () => {
let requestId;
await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'INSERT INTO test_request_id VALUES (\'testValue\');')
.then((result) => {
requestId = result.rowStatement.getRequestId();
});
let result;
result = await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'INSERT INTO test_request_id VALUES (\'testValue\');');
const requestId = result.rowStatement.getRequestId();

await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection,
result = await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection,
'INSERT INTO test_request_id VALUES (\'testValue\');',
{ requestId: requestId })
.then((result) => {
assert.strictEqual(result.rowStatement.getRequestId(), requestId);
});
{ requestId: requestId });
assert.strictEqual(result.rowStatement.getRequestId(), requestId);

await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'SELECT * from test_request_id ;')
.then((result) => {
assert.strictEqual(result.rows.length, 1);
});
result = await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'SELECT * from test_request_id ;');
assert.strictEqual(result.rows.length, 1);
});

it('Execute INSERT for the same request id and different connection', async () => {
let requestId;
await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'INSERT INTO test_request_id VALUES (\'testValue\');')
.then((result) => {
requestId = result.rowStatement.getRequestId();
});
let result;
result = await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'INSERT INTO test_request_id VALUES (\'testValue\');');
const requestId = result.rowStatement.getRequestId();

await testUtil.executeCmdAsyncWithAdditionalParameters(secondConnection, 'INSERT INTO test_request_id VALUES (\'testValue\');', { requestId: requestId })
.then((result) => {
assert.strictEqual(result.rowStatement.getRequestId(), requestId);
});
result = await testUtil.executeCmdAsyncWithAdditionalParameters(secondConnection, 'INSERT INTO test_request_id VALUES (\'testValue\');', { requestId: requestId });
assert.strictEqual(result.rowStatement.getRequestId(), requestId);

await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'SELECT * from test_request_id ;')
.then((result) => {
assert.strictEqual(result.rows.length, 2);
});
result = await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'SELECT * from test_request_id ;');
assert.strictEqual(result.rows.length, 2);
});

it('Execute SELECT for the same request id and different data', async () => {
let requestId;
await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'INSERT INTO test_request_id VALUES (\'testValue\');');
await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'SELECT * from test_request_id;')
.then((result) => {
assert.strictEqual(result.rows.length, 1);
requestId = result.rowStatement.getRequestId();
});
let result = await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'SELECT * from test_request_id;');
assert.strictEqual(result.rows.length, 1);
const requestId = result.rowStatement.getRequestId();

await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'INSERT INTO test_request_id VALUES (\'testValue\');');
await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'SELECT * from test_request_id;', { requestId: requestId })
.then((result) => {
assert.strictEqual(result.rows.length, 1);
});
result = await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'SELECT * from test_request_id;', { requestId: requestId });
assert.strictEqual(result.rows.length, 1);

await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'SELECT * from test_request_id ;')
.then((result) => {
assert.strictEqual(result.rows.length, 2);
});
result = await testUtil.executeCmdAsyncWithAdditionalParameters(firstConnection, 'SELECT * from test_request_id ;');
assert.strictEqual(result.rows.length, 2);
});
});

Expand Down

0 comments on commit 56d2b0d

Please sign in to comment.