Test case updates for SODA in Oracle Database 23c
This commit is contained in:
parent
4d80a7b83b
commit
561d63e446
|
@ -241,10 +241,12 @@ describe('164. soda1.js', () => {
|
|||
// Fetch the document back
|
||||
const doc2 = await collection.find().key(myKey).getOne();
|
||||
const content2 = doc2.getContent(); // A JavaScript object
|
||||
testsUtil.removeID(content1);
|
||||
testsUtil.removeID(content2);
|
||||
assert.deepStrictEqual(content2, content1);
|
||||
|
||||
const content3 = doc2.getContentAsString(); // A JSON string
|
||||
assert.strictEqual(typeof (content3), "string");
|
||||
const content3 = testsUtil.removeID(doc2.getContentAsString()); // A JSON string
|
||||
|
||||
assert.strictEqual(JSON.stringify(content2), content3);
|
||||
|
||||
// Replace document contents
|
||||
|
|
|
@ -86,7 +86,7 @@ describe('178. soda10.js', function() {
|
|||
const outDocuments = await collection.find().getDocuments();
|
||||
const outContents = [];
|
||||
for (let i = 0; i < outDocuments.length; i++) {
|
||||
outContents[i] = outDocuments[i].getContent(); // n.b. synchronous method
|
||||
outContents[i] = testsUtil.removeID(outDocuments[i].getContent()); // n.b. synchronous method
|
||||
}
|
||||
|
||||
assert.deepStrictEqual(outContents, inContents);
|
||||
|
@ -107,7 +107,7 @@ describe('178. soda10.js', function() {
|
|||
const outDocuments = await collection.find().getDocuments();
|
||||
const outContents = [];
|
||||
for (let i = 0; i < outDocuments.length; i++) {
|
||||
outContents[i] = outDocuments[i].getContent(); // n.b. synchronous method
|
||||
outContents[i] = testsUtil.removeID(outDocuments[i].getContent()); // n.b. synchronous method
|
||||
}
|
||||
|
||||
assert.deepStrictEqual(outContents, inContents);
|
||||
|
@ -139,7 +139,7 @@ describe('178. soda10.js', function() {
|
|||
const outDocuments = await collection.find().getDocuments();
|
||||
const outContents = [];
|
||||
for (let i = 0; i < outDocuments.length; i++) {
|
||||
outContents[i] = outDocuments[i].getContent(); // n.b. synchronous method
|
||||
outContents[i] = testsUtil.removeID(outDocuments[i].getContent()); // n.b. synchronous method
|
||||
}
|
||||
|
||||
assert.deepStrictEqual(outContents, inContents);
|
||||
|
@ -166,7 +166,7 @@ describe('178. soda10.js', function() {
|
|||
const outDocuments = await collection.find().getDocuments();
|
||||
const outContents = [];
|
||||
for (let i = 0; i < outDocuments.length; i++) {
|
||||
outContents[i] = outDocuments[i].getContent(); // n.b. synchronous method
|
||||
outContents[i] = testsUtil.removeID(outDocuments[i].getContent()); // n.b. synchronous method
|
||||
}
|
||||
|
||||
assert.deepStrictEqual(outContents, inContents);
|
||||
|
@ -241,7 +241,7 @@ describe('178. soda10.js', function() {
|
|||
const outDocuments = await collection.find().hint("MONITOR").getDocuments();
|
||||
const outContents = [];
|
||||
for (let i = 0; i < outDocuments.length; i++) {
|
||||
outContents[i] = outDocuments[i].getContent(); // n.b. synchronous method
|
||||
outContents[i] = testsUtil.removeID(outDocuments[i].getContent()); // n.b. synchronous method
|
||||
}
|
||||
|
||||
assert.deepStrictEqual(outContents, inContents);
|
||||
|
|
|
@ -105,6 +105,8 @@ describe('168. soda4.js', () => {
|
|||
// Fetch it back
|
||||
const doc2 = await coll.find().key(myKey).getOne();
|
||||
const content2 = doc2.getContent();
|
||||
testsUtil.removeID(testContent);
|
||||
testsUtil.removeID(content2);
|
||||
assert.deepStrictEqual(content2, testContent);
|
||||
|
||||
await conn.commit();
|
||||
|
|
|
@ -141,6 +141,8 @@ describe('174. soda6.js', function() {
|
|||
// Fetch it back
|
||||
const doc2 = await collection.find().key(key1).getOne();
|
||||
const content2 = doc2.getContent();
|
||||
testsUtil.removeID(content1);
|
||||
testsUtil.removeID(content2);
|
||||
assert.deepStrictEqual(content2, content1);
|
||||
|
||||
|
||||
|
|
|
@ -72,8 +72,12 @@ describe('176. soda8.js', () => {
|
|||
for (let i = 0; i < outDocuments.length; i++) {
|
||||
contents[i] = outDocuments[i].getContent();
|
||||
if (i == 1) {
|
||||
testsUtil.removeID(contents[i]);
|
||||
testsUtil.removeID(inContent);
|
||||
assert.deepStrictEqual(contents[i], inContent);
|
||||
} else {
|
||||
testsUtil.removeID(contents[i]);
|
||||
testsUtil.removeID(t_contents);
|
||||
testsUtil.assertOneOf(t_contents, contents[i]);
|
||||
}
|
||||
}
|
||||
|
@ -108,8 +112,12 @@ describe('176. soda8.js', () => {
|
|||
for (let i = 0; i < documents.length; i++) {
|
||||
contents[i] = documents[i].getContent();
|
||||
if (i == 1) {
|
||||
testsUtil.removeID(contents[i]);
|
||||
testsUtil.removeID(inContent);
|
||||
assert.deepStrictEqual(contents[i], inContent);
|
||||
} else {
|
||||
testsUtil.removeID(contents[i]);
|
||||
testsUtil.removeID(t_contents);
|
||||
testsUtil.assertOneOf(t_contents, contents[i]);
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +151,8 @@ describe('176. soda8.js', () => {
|
|||
const contents = [];
|
||||
for (let i = 0; i < outDocuments.length; i++) {
|
||||
contents[i] = outDocuments[i].getContent();
|
||||
testsUtil.removeID(contents[i]);
|
||||
testsUtil.removeID(t_contents);
|
||||
testsUtil.assertOneOf(t_contents, contents[i]);
|
||||
}
|
||||
|
||||
|
@ -177,6 +187,8 @@ describe('176. soda8.js', () => {
|
|||
const contents = [];
|
||||
for (let i = 0; i < outDocuments.length; i++) {
|
||||
contents[i] = outDocuments[i].getContent();
|
||||
testsUtil.removeID(contents[i]);
|
||||
testsUtil.removeID(t_contents);
|
||||
testsUtil.assertOneOf(t_contents, contents[i]);
|
||||
}
|
||||
|
||||
|
@ -208,8 +220,12 @@ describe('176. soda8.js', () => {
|
|||
for (let i = 0; i < outDocuments.length; i++) {
|
||||
contents[i] = outDocuments[i].getContent();
|
||||
if (i == 1) {
|
||||
testsUtil.removeID(contents[i]);
|
||||
testsUtil.removeID(inContent);
|
||||
assert.deepStrictEqual(contents[i], inContent);
|
||||
} else {
|
||||
testsUtil.removeID(contents[i]);
|
||||
testsUtil.removeID(t_contents);
|
||||
testsUtil.assertOneOf(t_contents, contents[i]);
|
||||
}
|
||||
}
|
||||
|
@ -244,8 +260,13 @@ describe('176. soda8.js', () => {
|
|||
for (let i = 0; i < documents.length; i++) {
|
||||
contents[i] = documents[i].getContent();
|
||||
if (i == 1) {
|
||||
testsUtil.removeID(contents[i]);
|
||||
testsUtil.removeID(inContent);
|
||||
assert.deepStrictEqual(contents[i], inContent);
|
||||
} else {
|
||||
|
||||
testsUtil.removeID(contents[i]);
|
||||
testsUtil.removeID(t_contents);
|
||||
testsUtil.assertOneOf(t_contents, contents[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ describe('177. soda9.js', () => {
|
|||
// fetch back
|
||||
const outDocuments = await collection.find().getDocuments();
|
||||
const outContent = outDocuments[0].getContent();
|
||||
testsUtil.removeID(outContent);
|
||||
testsUtil.removeID(inContent);
|
||||
assert.deepStrictEqual(outContent, inContent);
|
||||
|
||||
await conn.commit();
|
||||
|
@ -77,6 +79,8 @@ describe('177. soda9.js', () => {
|
|||
// fetch back
|
||||
const outDocuments = await collection.find().getDocuments();
|
||||
const outContent = outDocuments[0].getContent();
|
||||
testsUtil.removeID(outContent);
|
||||
testsUtil.removeID(inContent);
|
||||
assert.deepStrictEqual(outContent, inContent);
|
||||
|
||||
await conn.commit();
|
||||
|
@ -99,6 +103,9 @@ describe('177. soda9.js', () => {
|
|||
// Fetch it back
|
||||
const outDocuments = await collection.find().getDocuments();
|
||||
const outContent = outDocuments[0].getContent();
|
||||
|
||||
testsUtil.removeID(outContent);
|
||||
testsUtil.removeID(inContent);
|
||||
assert.deepStrictEqual(outContent, inContent);
|
||||
|
||||
await conn.commit();
|
||||
|
@ -122,6 +129,9 @@ describe('177. soda9.js', () => {
|
|||
// Fetch it back
|
||||
const outDocuments = await collection.find().getDocuments();
|
||||
const outContent = outDocuments[0].getContent();
|
||||
|
||||
testsUtil.removeID(outContent);
|
||||
testsUtil.removeID(inContent);
|
||||
assert.deepStrictEqual(outContent, inContent);
|
||||
|
||||
await conn.commit();
|
||||
|
|
|
@ -85,6 +85,9 @@ describe('257. sodahint.js', () => {
|
|||
// Fetch back
|
||||
const outDocuments = await collection.find().hint("MONITOR").getDocuments();
|
||||
const outContent = outDocuments[0].getContent();
|
||||
|
||||
testsUtil.removeID(outContent);
|
||||
testsUtil.removeID(inContent);
|
||||
assert.deepStrictEqual(outContent, inContent);
|
||||
await conn.commit();
|
||||
|
||||
|
@ -112,7 +115,8 @@ describe('257. sodahint.js', () => {
|
|||
assert.strictEqual(res.dropped, true);
|
||||
}); // 257.2
|
||||
|
||||
it('257.3 saveAndGet() with hint option', async () => {
|
||||
it('257.3 saveAndGet() with hint option', async function() {
|
||||
if (oracledb.oracleClientVersion >= 2300000000) this.skip();
|
||||
const COLL = "soda_test_257_3";
|
||||
const collection = await soda.createCollection(COLL);
|
||||
|
||||
|
|
|
@ -37,9 +37,19 @@ const sodaUtil = require('./sodaUtil.js');
|
|||
const assert = require('assert');
|
||||
const os = require('os');
|
||||
|
||||
let testsUtil = exports;
|
||||
const testsUtil = exports;
|
||||
module.exports = testsUtil;
|
||||
|
||||
testsUtil.removeID = function(content) {
|
||||
if (typeof content == "string") {
|
||||
const data = JSON.parse(content);
|
||||
delete data._id;
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
delete content._id;
|
||||
return content;
|
||||
};
|
||||
|
||||
testsUtil.sqlCreateTable = function(tableName, sql) {
|
||||
// The NOCOMPRESS option for CREATE TABLE ensures Hybrid Columnar Compression (HCC)
|
||||
// is disabled for tables with LONG & LONG RAW columns in all types of Oracle DB.
|
||||
|
@ -156,7 +166,7 @@ testsUtil.isSodaRunnable = async function() {
|
|||
|
||||
if ((clientVersion >= 1909000000) && (serverVersion < 1909000000)) return false;
|
||||
|
||||
let sodaRole = await sodaUtil.isSodaRoleGranted();
|
||||
const sodaRole = await sodaUtil.isSodaRoleGranted();
|
||||
if (!sodaRole) return false;
|
||||
|
||||
return true;
|
||||
|
@ -180,8 +190,8 @@ testsUtil.getDBCompatibleVersion = async function() {
|
|||
connectString : dbConfig.connectString,
|
||||
privilege : oracledb.SYSDBA,
|
||||
};
|
||||
let conn = await oracledb.getConnection(connectionDetails);
|
||||
let res = await conn.execute("select name, value from v$parameter where name = 'compatible'");
|
||||
const conn = await oracledb.getConnection(connectionDetails);
|
||||
const res = await conn.execute("select name, value from v$parameter where name = 'compatible'");
|
||||
if (res.rows.length > 0) {
|
||||
compatibleVersion = res.rows[0][1];
|
||||
}
|
||||
|
@ -197,9 +207,9 @@ testsUtil.getDBCompatibleVersion = async function() {
|
|||
// * undefined if eigher version1 or version2 is not string
|
||||
testsUtil.versionStringCompare = function(version1, version2) {
|
||||
if (typeof version1 === 'string' && typeof version2 === 'string') {
|
||||
let tokens1 = version1.split('.');
|
||||
let tokens2 = version2.split('.');
|
||||
let len = Math.min(tokens1.length, tokens2.length);
|
||||
const tokens1 = version1.split('.');
|
||||
const tokens2 = version2.split('.');
|
||||
const len = Math.min(tokens1.length, tokens2.length);
|
||||
for (let i = 0; i < len; i++) {
|
||||
const t1 = parseInt(tokens1[i]), t2 = parseInt(tokens2[i]);
|
||||
if (t1 > t2) return 1;
|
||||
|
@ -214,7 +224,7 @@ testsUtil.versionStringCompare = function(version1, version2) {
|
|||
|
||||
testsUtil.getLocalIPAddress = function() {
|
||||
const ifaces = os.networkInterfaces();
|
||||
let result = [];
|
||||
const result = [];
|
||||
Object.keys(ifaces).forEach(function(ifname) {
|
||||
var alias = 0;
|
||||
ifaces[ifname].forEach(function(iface) {
|
||||
|
@ -250,7 +260,7 @@ testsUtil.getRoundTripCount = async function(sid) {
|
|||
msg += "Without DBA privilege the test cannot get the current round trip count!";
|
||||
throw new Error(msg);
|
||||
} else {
|
||||
let dbaCredential = {
|
||||
const dbaCredential = {
|
||||
user: dbConfig.test.DBA_user,
|
||||
password: dbConfig.test.DBA_password,
|
||||
connectString: dbConfig.connectString,
|
||||
|
@ -290,14 +300,14 @@ testsUtil.createAQtestUser = async function(AQ_USER, AQ_USER_PWD) {
|
|||
msg += "Without DBA privilege, the test cannot create the schema!";
|
||||
throw new Error(msg);
|
||||
} else {
|
||||
let dbaCredential = {
|
||||
const dbaCredential = {
|
||||
user: dbConfig.test.DBA_user,
|
||||
password: dbConfig.test.DBA_password,
|
||||
connectString: dbConfig.connectString,
|
||||
privilege: oracledb.SYSDBA
|
||||
};
|
||||
|
||||
let plsql = `
|
||||
const plsql = `
|
||||
BEGIN
|
||||
DECLARE
|
||||
e_user_missing EXCEPTION;
|
||||
|
@ -336,7 +346,7 @@ testsUtil.dropAQtestUser = async function(AQ_USER) {
|
|||
msg += "Without DBA privilege, the test cannot drop the schema!\n";
|
||||
throw new Error(msg);
|
||||
} else {
|
||||
let dbaCredential = {
|
||||
const dbaCredential = {
|
||||
user: dbConfig.test.DBA_user,
|
||||
password: dbConfig.test.DBA_password,
|
||||
connectString: dbConfig.connectString,
|
||||
|
@ -344,7 +354,7 @@ testsUtil.dropAQtestUser = async function(AQ_USER) {
|
|||
};
|
||||
|
||||
const connAsDBA = await oracledb.getConnection(dbaCredential);
|
||||
let sql = `DROP USER ${AQ_USER} CASCADE`;
|
||||
const sql = `DROP USER ${AQ_USER} CASCADE`;
|
||||
await connAsDBA.execute(sql);
|
||||
}
|
||||
};
|
||||
|
@ -373,8 +383,8 @@ testsUtil.isLongUserNameRunnable = async function() {
|
|||
if (!dbConfig.test.DBA_PRIVILEGE) {
|
||||
return false;
|
||||
} else {
|
||||
let checkVersions = await testsUtil.checkPrerequisites(1800000000, 1800000000);
|
||||
let checkCompatible = await testsUtil.versionStringCompare(await testsUtil.getDBCompatibleVersion(), '12.2.0.0.0');
|
||||
const checkVersions = await testsUtil.checkPrerequisites(1800000000, 1800000000);
|
||||
const checkCompatible = await testsUtil.versionStringCompare(await testsUtil.getDBCompatibleVersion(), '12.2.0.0.0');
|
||||
if (checkVersions && (checkCompatible >= 0)) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -431,7 +441,7 @@ testsUtil.isDeepEqual = function(x, y) {
|
|||
return false;
|
||||
|
||||
// each key must have the same value
|
||||
for (let key in x) {
|
||||
for (const key in x) {
|
||||
if (!testsUtil.isDeepEqual(x[key], y[key]))
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue