Skip to content

Commit

Permalink
misc - update maxscale test for 6.2.0
Browse files Browse the repository at this point in the history
add PAM test for maxscale (using dedicated port)
  • Loading branch information
diego Dupin committed Jan 10, 2022
1 parent d7d4844 commit 7a2f6b3
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/cmd/batch-bulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class BatchBulk extends Parser {
*/
sendComStmtBulkExecute(out, opts, info) {
if (opts.logger.query)
opts.logger.query(`BULK: (${this.prepare.id}) ${opts.logger.logParam ? this.displaySql() : this.sql}`);
opts.logger.query(`BULK: (${this.prepare.id}) sql: ${opts.logger.logParam ? this.displaySql() : this.sql}`);
const parameterCount = this.prepare.parameters.length;
this.rowIdx = 0;
this.vals = this.values[this.rowIdx++];
Expand Down
10 changes: 6 additions & 4 deletions lib/cmd/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ class Execute extends Parser {
Buffer.isBuffer(value))
) {
if (opts.logger.query)
opts.logger.query(`EXECUTE: (${this.prepare.id}) ${opts.logger.logParam ? this.displaySql() : this.sql}`);
opts.logger.query(
`EXECUTE: (${this.prepare.id}) sql: ${opts.logger.logParam ? this.displaySql() : this.sql}`
);
if (!this.longDataStep) {
this.longDataStep = true;
this.registerStreamSendEvent(out, info);
Expand All @@ -69,7 +71,7 @@ class Execute extends Parser {
if (!this.longDataStep) {
// no stream parameter, so can send directly
if (opts.logger.query)
opts.logger.query(`EXECUTE: (${this.prepare.id}) ${opts.logger.logParam ? this.displaySql() : this.sql}`);
opts.logger.query(`EXECUTE: (${this.prepare.id}) sql: ${opts.logger.logParam ? this.displaySql() : this.sql}`);
this.sendComStmtExecute(out, info);
}
}
Expand All @@ -85,7 +87,7 @@ class Execute extends Parser {
if (this.prepare.parameters.length > this.values.length) {
this.emit('send_end');
this.throwNewError(
`Parameter at position ${this.values.length} is not set\\n${this.displaySql()}`,
`Parameter at position ${this.values.length} is not set\\nsql: ${this.displaySql()}`,
false,
info,
'HY000',
Expand All @@ -103,7 +105,7 @@ class Execute extends Parser {
errMsg = `Parameter named ${this.prepare._placeHolderIndex[i]} is not set`;
}

this.throwNewError(errMsg + '\n' + this.displaySql(), false, info, 'HY000', Errors.ER_PARAMETER_UNDEFINED);
this.throwNewError(errMsg + '\nsql: ' + this.displaySql(), false, info, 'HY000', Errors.ER_PARAMETER_UNDEFINED);
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/cmd/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ class Prepare extends Parser {
displaySql() {
if (this.opts) {
if (this.sql.length > this.opts.debugLen) {
return 'sql: ' + this.sql.substring(0, this.opts.debugLen) + '...';
return this.sql.substring(0, this.opts.debugLen) + '...';
}
}
return 'sql: ' + this.sql;
return this.sql;
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/integration/datatype/test-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ describe('string', () => {
assert.equal(res[4].tt, '😎🌶🎤🥂');
};

it('connection encoding', async () => {
it('connection encoding', async function () {
this.timeout(10000);
const value = '©°';
const encodings = ['KOI8R_GENERAL_CI', 'UTF8_GENERAL_CI', 'CP850_BIN', 'CP1251_GENERAL_CI'];
for (let i = 0; i < encodings.length; i++) {
Expand Down
1 change: 1 addition & 0 deletions test/integration/test-additional-server-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { assert } = require('chai');

describe('server additional information API', () => {
it('server version', function (done) {
if (process.env.srv === 'maxscale' || process.env.srv === 'skysql-ha') this.skip();
shareConn
.query('SELECT VERSION() a')
.then((res) => {
Expand Down
15 changes: 12 additions & 3 deletions test/integration/test-auth-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,16 @@ describe('authentication plugin', () => {
await shareConn.query("GRANT SELECT ON *.* TO '" + process.env.TEST_PAM_USER + "'@'%' IDENTIFIED VIA pam");
await shareConn.query('FLUSH PRIVILEGES');

let testPort = Conf.baseConfig.port;
if (process.env.TEST_PAM_PORT != null) {
testPort = parseInt(process.env.TEST_PAM_PORT);
}
//password is unix password "myPwd"
try {
const conn = await base.createConnection({
user: process.env.TEST_PAM_USER,
password: process.env.TEST_PAM_PWD
password: process.env.TEST_PAM_PWD,
port: testPort
});
await conn.end();
} catch (err) {
Expand All @@ -241,12 +246,16 @@ describe('authentication plugin', () => {
await shareConn.query("GRANT SELECT ON *.* TO '" + process.env.TEST_PAM_USER + "'@'%' IDENTIFIED VIA pam");
await shareConn.query('FLUSH PRIVILEGES');

//password is unix password "myPwd"
let testPort = Conf.baseConfig.port;
if (process.env.TEST_PAM_PORT != null) {
testPort = parseInt(process.env.TEST_PAM_PORT);
}
//password is unix password "myPwd"
try {
const conn = await base.createConnection({
user: process.env.TEST_PAM_USER,
password: [process.env.TEST_PAM_PWD, process.env.TEST_PAM_PWD]
password: [process.env.TEST_PAM_PWD, process.env.TEST_PAM_PWD],
port: testPort
});
await conn.end();
} catch (err) {
Expand Down
1 change: 1 addition & 0 deletions test/integration/test-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { assert } = require('chai');
describe('stored procedure', () => {
before(async function () {
if (process.env.srv === 'skysql' || process.env.srv === 'skysql-ha') this.skip();
if (shareConn.serverVersion().includes('maxScale-6.2.0')) this.skip();
await shareConn.query('DROP PROCEDURE IF EXISTS stmtOutParam');
await shareConn.query('DROP PROCEDURE IF EXISTS stmtSimple');
await shareConn.query('DROP PROCEDURE IF EXISTS someProc');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe('debug', () => {
setTimeout(() => {
const data = fs.readFileSync(tmpLogFile, 'utf8');
const serverVersion = conn.serverVersion();
const range = [6500, 8000];
const range = [6500, 8100];
assert(
data.length > range[0] && data.length < range[1],
'wrong data length : ' +
Expand Down
1 change: 1 addition & 0 deletions test/integration/test-multi-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ describe('multi-results', () => {
});

it('multiple result type with multiple rows', async function () {
if (shareConn.serverVersion().includes('maxScale-6.2.0')) this.skip();
if (process.env.srv === 'skysql' || process.env.srv === 'skysql-ha') this.skip();
//using sequence engine
if (!shareConn.info.isMariaDB() || !shareConn.info.hasMinVersion(10, 1)) this.skip();
Expand Down
1 change: 1 addition & 0 deletions test/integration/test-query-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ describe('basic query callback', () => {
});

it('permitSetMultiParamEntries escape ', function (done) {
this.timeout(5000);
const fctStr = new Object();
fctStr.toSqlString = () => {
return "bla'bla";
Expand Down
7 changes: 7 additions & 0 deletions test/integration/test-typecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,31 @@ describe('TypeCast', () => {
});

it('connection level typecast function', async function () {
this.timeout(5000);
const conn = await base.createConnection({ typeCast: changeCaseCast });
const rows = await conn.query("SELECT 'blaBLA' as upper, 'blaBLA' as lower, 'blaBLA' as std, '1' as r");
assert.deepEqual(rows, [{ upper: 'BLABLA', lower: 'blabla', std: 'blaBLA', r: '1' }]);
conn.end();
});

it('connection level typecast function execute', async function () {
this.timeout(5000);
const conn = await base.createConnection({ typeCast: changeCaseCast });
const rows = await conn.execute("SELECT 'blaBLA' as upper, 'blaBLA' as lower, 'blaBLA' as std, '1' as r");
assert.deepEqual(rows, [{ upper: 'BLABLA', lower: 'blabla', std: 'blaBLA', r: '1' }]);
conn.end();
});

it('compatibility automatic cast', async function () {
this.timeout(5000);
const conn = await base.createConnection({ typeCast: true });
const rows = await conn.query("SELECT '1' as r");
assert.deepEqual(rows, [{ r: '1' }]);
conn.end();
});

it('compatibility automatic cast execute', async function () {
this.timeout(5000);
const conn = await base.createConnection({ typeCast: true });
const rows = await conn.execute("SELECT '1' as r");
assert.deepEqual(rows, [{ r: '1' }]);
Expand Down Expand Up @@ -123,6 +127,7 @@ describe('TypeCast', () => {
});

it('long cast', async function () {
this.timeout(5000);
const longCast = (column, next) => {
if (column.type == 'TINY' && column.columnLength === 1) {
const val = column.tiny();
Expand Down Expand Up @@ -153,6 +158,7 @@ describe('TypeCast', () => {
});

it('date cast', async function () {
this.timeout(5000);
const longCast = (column, next) => {
if (column.type == 'TIMESTAMP' || column.type == 'DATETIME') {
let da = column.datetime();
Expand Down Expand Up @@ -187,6 +193,7 @@ describe('TypeCast', () => {
});

it('geometry cast', async function () {
this.timeout(5000);
const longCast = (column, next) => {
if (column.type == 'BINARY') {
return column.geometry();
Expand Down
4 changes: 4 additions & 0 deletions types/mariadb-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ async function testMisc(): Promise<void> {
console.log(defaultOptionsWithTz);
const connection = await createConnection();

rows = await connection.query('INSERT INTO myTable VALUE (1)');
console.log(rows.insertId === 1);
console.log(rows.affectedRows === 1);

rows = await connection.query('SELECT 1 + 1 AS solution');
console.log(rows[0].solution === 2);

Expand Down

0 comments on commit 7a2f6b3

Please sign in to comment.