Skip to content

Commit

Permalink
fixed testing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jy committed Sep 21, 2023
1 parent 5492ad7 commit 7cc15af
Showing 1 changed file with 87 additions and 98 deletions.
185 changes: 87 additions & 98 deletions test/integration/testHTAP.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,113 +2,102 @@ const assert = require('assert');
const async = require('async');
const connOption = require('./connectionOptions').valid;
const testUtil = require('./testUtil');
const { configureLogger } = require('../configureLogger');
const Logger = require('../../lib/logger');


describe('Query Context Cache test', function () {
this.timeout(1000000);
let connection;
before((done) => {
connection = testUtil.createConnection(connOption);
async.series([
function (callback)
{
if(process.env.CLOUD_PROVIDER === 'AWS'){
describe('Query Context Cache test', function () {
this.timeout(1000000);
let connection;
before((done) => {
connection = testUtil.createConnection(connOption);
async.series([
function (callback) {
testUtil.connect(connection, callback);
}],
done)
configureLogger('TRACE');
});
done);
});

after(async () => {
configureLogger('ERROR');
await testUtil.destroyConnectionAsync(connection);
});
const querySet = [
{
sqlTexts:[
'create or replace database db1',
'create or replace hybrid table t1 (a int primary key, b int)',
'insert into t1 values (1, 2), (2, 3), (3, 4)'
],
QccSize:2,
},
{
sqlTexts:[
'create or replace database db2',
'create or replace hybrid table t2 (a int primary key, b int)',
'insert into t2 values (1, 2), (2, 3), (3, 4)'
],
QccSize:3,
},
{
sqlTexts:[
'create or replace database db3',
'create or replace hybrid table t3 (a int primary key, b int)',
'insert into t3 values (1, 2), (2, 3), (3, 4)'
],
QccSize:4,
},
{
sqlTexts:[
'select * from db1.public.t1 x, db2.public.t2 y, db3.public.t3 z where x.a = y.a and y.a = z.a;',
'select * from db1.public.t1 x, db2.public.t2 y where x.a = y.a;',
'select * from db2.public.t2 y, db3.public.t3 z where y.a = z.a;'
],
QccSize:4,
},
];
after(async () => {
await testUtil.destroyConnectionAsync(connection);
});
const querySet = [
{
sqlTexts:[
'create or replace database db1',
'create or replace hybrid table t1 (a int primary key, b int)',
'insert into t1 values (1, 2), (2, 3), (3, 4)'
],
QccSize:2,
},
{
sqlTexts:[
'create or replace database db2',
'create or replace hybrid table t2 (a int primary key, b int)',
'insert into t2 values (1, 2), (2, 3), (3, 4)'
],
QccSize:3,
},
{
sqlTexts:[
'create or replace database db3',
'create or replace hybrid table t3 (a int primary key, b int)',
'insert into t3 values (1, 2), (2, 3), (3, 4)'
],
QccSize:4,
},
{
sqlTexts:[
'select * from db1.public.t1 x, db2.public.t2 y, db3.public.t3 z where x.a = y.a and y.a = z.a;',
'select * from db1.public.t1 x, db2.public.t2 y where x.a = y.a;',
'select * from db2.public.t2 y, db3.public.t3 z where y.a = z.a;'
],
QccSize:4,
},
];

function createQueryTest () {
const testingSet = [];
let testingfunction;
for(let i = 0; i < querySet.length; i++) {
const {sqlTexts,QccSize} = querySet[i];
for(let k = 0; k < sqlTexts.length; k++){
if(k!==sqlTexts.length-1){
testingfunction = function(callback) {
connection.execute({
sqlText: sqlTexts[k],
complete: function (err) {
if(err){
Logger.getInstance().trace("The error occurs for the testHTAP", err.message);
function createQueryTest () {
const testingSet = [];
let testingfunction;
for(let i = 0; i < querySet.length; i++) {
const {sqlTexts,QccSize} = querySet[i];
for(let k = 0; k < sqlTexts.length; k++){
if(k!==sqlTexts.length-1){
testingfunction = function(callback) {
connection.execute({
sqlText: sqlTexts[k],
complete: function (err) {
assert.ok(!err,'There should be no error!');
callback();
}
assert.ok(!err,'There should be no error!');
callback();
}
});
};
}
else{
testingfunction = function(callback) {
connection.execute({
sqlText: sqlTexts[k],
complete: function (err, stmt) {
if(err){
Logger.getInstance().trace("The error occurs for the testHTAP", err.message);
});
};
} else{
testingfunction = function(callback) {
connection.execute({
sqlText: sqlTexts[k],
complete: function (err, stmt) {
assert.ok(!err,'There should be no error!');
assert.strictEqual(stmt.getQueryContextCacheSize(), QccSize);
assert.strictEqual(stmt.getQueryContextDTOSize(), QccSize);
callback();
}
assert.ok(!err,'There should be no error!');
assert.strictEqual(stmt.getQueryContextCacheSize(), QccSize);
assert.strictEqual(stmt.getQueryContextDTOSize(), QccSize);
callback();
}
});
};
});
};
}
testingSet.push(testingfunction);
}
testingSet.push(testingfunction);
}
return testingSet;
}
return testingSet;
}

it('test Query Context Cache', function (done) {
const queryTests = createQueryTest();
async.series(
[
...queryTests
],
function () {
done();
});
it('test Query Context Cache', function (done) {
const queryTests = createQueryTest();
async.series(
[
...queryTests
],
function () {
done();
});
});
});
});
}

0 comments on commit 7cc15af

Please sign in to comment.