From 9dd5ef372f01797a5006f13bf0b3bdd68851c21d Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 18 Jul 2019 17:54:08 +0200 Subject: [PATCH 01/17] [misc] adding 10.4 TLSv1.2 testing on windows --- test/integration/test-auth-plugin.js | 3 +-- test/integration/test-debug.js | 1 - test/integration/test-ssl.js | 8 ++++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/integration/test-auth-plugin.js b/test/integration/test-auth-plugin.js index 87ecf570..d10a2784 100644 --- a/test/integration/test-auth-plugin.js +++ b/test/integration/test-auth-plugin.js @@ -196,8 +196,7 @@ describe('authentication plugin', () => { .then(() => { return base.createConnection({ user: 'mysqltest1', - password: '!Passw0rd3', - debug: true + password: '!Passw0rd3' }); }) .then(conn => { diff --git a/test/integration/test-debug.js b/test/integration/test-debug.js index 6c291eb4..ed787157 100644 --- a/test/integration/test-debug.js +++ b/test/integration/test-debug.js @@ -40,7 +40,6 @@ describe('debug', () => { }, 1000); }); - after(done => { fs.unlink(smallFileName, done); }); diff --git a/test/integration/test-ssl.js b/test/integration/test-ssl.js index 5bda4ca5..f2e35baa 100644 --- a/test/integration/test-ssl.js +++ b/test/integration/test-ssl.js @@ -302,7 +302,11 @@ describe('ssl', function() { //MariaDB server doesn't permit TLSv1.2 on windows //MySQL community version doesn't support TLSv1.2 const isWin = process.platform === 'win32'; - if (isWin || !shareConn.info.isMariaDB()) this.skip(); + if ( + (shareConn.info.isMariaDB() && isWin && !shareConn.info.hasMinVersion(10, 4, 2)) || + (isWin && !shareConn.info.isMariaDB()) + ) + this.skip(); base .createConnection({ @@ -310,7 +314,7 @@ describe('ssl', function() { rejectUnauthorized: false, secureProtocol: 'TLSv1_2_method', ciphers: - 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256' + 'DHE-RSA-AES256-SHA:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256' } }) .then(conn => { From a2aa58bdc65382de4fb54abce835c6628116fb35 Mon Sep 17 00:00:00 2001 From: rusher Date: Fri, 19 Jul 2019 15:44:31 +0200 Subject: [PATCH 02/17] [misc] correcting test for mysql community before 8.0 version that doesn't support TLSv1.2 --- test/integration/test-connection.js | 1 + test/integration/test-ssl.js | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test/integration/test-connection.js b/test/integration/test-connection.js index 9598be0c..2f5b0f6b 100644 --- a/test/integration/test-connection.js +++ b/test/integration/test-connection.js @@ -182,6 +182,7 @@ describe('connection', () => { }); it('connection error event', function(done) { + if (!shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(5, 6, 0)) this.skip(); base .createConnection() .then(conn => { diff --git a/test/integration/test-ssl.js b/test/integration/test-ssl.js index f2e35baa..a210858b 100644 --- a/test/integration/test-ssl.js +++ b/test/integration/test-ssl.js @@ -302,11 +302,9 @@ describe('ssl', function() { //MariaDB server doesn't permit TLSv1.2 on windows //MySQL community version doesn't support TLSv1.2 const isWin = process.platform === 'win32'; - if ( - (shareConn.info.isMariaDB() && isWin && !shareConn.info.hasMinVersion(10, 4, 2)) || - (isWin && !shareConn.info.isMariaDB()) - ) + if (!shareConn.info.isMariaDB() || (isWin && !shareConn.info.hasMinVersion(10, 4, 2))) { this.skip(); + } base .createConnection({ From 46fbc65b30b0a9d9f16c06bfc89053cf93676cc7 Mon Sep 17 00:00:00 2001 From: "Indospace.io" Date: Wed, 4 Sep 2019 05:34:37 -0700 Subject: [PATCH 03/17] bump dependencies bump dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e984ebb1..67e28d74 100644 --- a/package.json +++ b/package.json @@ -46,11 +46,11 @@ "license": "LGPL-2.1+", "dependencies": { "@types/geojson": "^7946.0.7", - "@types/node": "^11.13.15", - "denque": "^1.4.0", - "iconv-lite": "^0.4.24", + "@types/node": "^12.7.4", + "denque": "^1.4.1", + "iconv-lite": "^0.5.0", "long": "^4.0.0", - "moment-timezone": "^0.5.25" + "moment-timezone": "^0.5.26" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^1.11.0", From 7f3e8aee83a4978cbd153adacd17b759aa364887 Mon Sep 17 00:00:00 2001 From: "Indospace.io" Date: Wed, 4 Sep 2019 05:36:29 -0700 Subject: [PATCH 04/17] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 67e28d74..e881820a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mariadb", - "version": "2.1.0", + "version": "2.1.1", "description": "fast mariadb/mysql connector.", "main": "promise.js", "types": "types/index.d.ts", From 5058c83d6660fe032c6c9b552bb4669b62c52896 Mon Sep 17 00:00:00 2001 From: rusher Date: Wed, 4 Sep 2019 15:58:43 +0200 Subject: [PATCH 05/17] [misc] benchmark init function using promise or callback implementation depending on benchmark --- benchmarks/benchmarkOne.js | 2 +- benchmarks/benchmarks.js | 2 +- benchmarks/common_benchmarks.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmarks/benchmarkOne.js b/benchmarks/benchmarkOne.js index f18c7590..e3e01798 100644 --- a/benchmarks/benchmarkOne.js +++ b/benchmarks/benchmarkOne.js @@ -9,7 +9,7 @@ const launchBenchs = function(path) { const test = 'bench_promise_select_one_user.js'; const m = require(path + '/' + test); - bench.initFcts.push(m.initFct); + bench.initFcts.push([m.initFct, m.promise]); bench.add(m.title, m.displaySql, m.benchFct, m.onComplete, m.promise, m.pool); //, bench.CONN.MYSQL); bench.suiteReady(); diff --git a/benchmarks/benchmarks.js b/benchmarks/benchmarks.js index f933f380..4e9145ef 100644 --- a/benchmarks/benchmarks.js +++ b/benchmarks/benchmarks.js @@ -13,7 +13,7 @@ const launchBenchs = function(path) { for (let i = 0; i < list.length; i++) { console.log('benchmark: ./benchs/' + list[i]); const m = require('./benchs/' + list[i]); - bench.initFcts.push(m.initFct); + bench.initFcts.push([m.initFct, m.promise]); bench.add(m.title, m.displaySql, m.benchFct, m.onComplete, m.promise, m.pool); } bench.suiteReady(); diff --git a/benchmarks/common_benchmarks.js b/benchmarks/common_benchmarks.js index 60548cb4..60576324 100644 --- a/benchmarks/common_benchmarks.js +++ b/benchmarks/common_benchmarks.js @@ -198,7 +198,7 @@ function Bench() { for (let i = 0; i < bench.initFcts.length; i++) { console.log('initializing test data ' + (i + 1) + '/' + bench.initFcts.length); if (bench.initFcts[i]) { - bench.initFcts[i].call(this, bench.CONN.MARIADB.drv); + bench.initFcts[i][0].call(this, bench.initFcts[i][0] ? bench.CONN.PROMISE_MARIADB.drv : bench.CONN.MARIADB.drv); } } this.currentNb = 0; From a888b1d0f4fa6dfa55862df9e6777ce5de723684 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 10:36:48 +0200 Subject: [PATCH 06/17] [misc] Node.js v12 require TLSv1.2 by default Correcting SSL test to permit TLSv1 and TLSv1.1 in case of windows server --- documentation/connection-options.md | 9 ++++++++- test/integration/test-ssl.js | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/documentation/connection-options.md b/documentation/connection-options.md index de9519ab..59b6da14 100644 --- a/documentation/connection-options.md +++ b/documentation/connection-options.md @@ -367,6 +367,13 @@ Hostname/IP doesn't match certificate's altnames: "Host: other.example.com. is n ``` To fix this, correct the `host` value to correspond to the host identified in the certificate. - +#### routines:ssl_choose_client_version:unsupported protocol + +Since Node.js 12 minimum TLS version is set to 1.2. +MariaDB server can be build with different SSL library, old version supporting only TLS up to 1.1. +The error "1976:error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol" can occur if MariaDB SSL implementation doesn't support TLSv1.2. +This can be solved by : +- Server side: update MariaDB to a recent version +- Client side: permit lesser version with "tls.DEFAULT_MIN_VERSION = 'TLSv1.1';" or with connection configuration: using option `ssl: { secureProtocol: 'TLSv1_1_method' }' diff --git a/test/integration/test-ssl.js b/test/integration/test-ssl.js index a210858b..078ae2f7 100644 --- a/test/integration/test-ssl.js +++ b/test/integration/test-ssl.js @@ -4,6 +4,7 @@ const base = require('../base.js'); const { assert } = require('chai'); const fs = require('fs'); const Conf = require('../conf'); +const tls = require('tls'); describe('ssl', function() { let ca = null; @@ -11,6 +12,17 @@ describe('ssl', function() { before(function(done) { if (process.env.MAXSCALE_VERSION) this.skip(); + console.log(tls.DEFAULT_MIN_VERSION); + if ( + process.platform === 'win32' && + tls.DEFAULT_MIN_VERSION === 'TLSv1.2' && + ((shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(10, 4, 0)) || + (!shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(8, 0, 0))) + ) { + //TLSv1.2 is supported on windows only since MariaDB 10.4 and MySQL 8.0 + //so if testing with Node.js 12, force possible TLS1.1 + tls.DEFAULT_MIN_VERSION = 'TLSv1.1'; + } if (process.env.TEST_SSL_CA_FILE) { const caFileName = process.env.TEST_SSL_CA_FILE; From 1400b1f49a80f17e952c3e0bd15714ba7f410628 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 10:37:58 +0200 Subject: [PATCH 07/17] [misc] type script correction for triple slash importation --- types/index.d.ts | 11 ++++------- types/tsconfig.json | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 518d4623..c47c40f2 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -4,12 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 -/// -/// - import tls = require('tls'); import stream = require('stream'); -import { Geometry } from 'geojson'; +import geojson = require('geojson'); export function createConnection(connectionUri: string | ConnectionConfig): Promise; export function createPool(config: PoolConfig | string): Pool; @@ -26,8 +23,8 @@ export interface QueryConfig { */ typeCast?: ( field: FieldInfo, - next: () => boolean | number | string | symbol | null | Geometry | Buffer - ) => boolean | number | string | symbol | null | Geometry | Buffer; + next: () => boolean | number | string | symbol | null | geojson.Geometry | Buffer + ) => boolean | number | string | symbol | null | geojson.Geometry | Buffer; /** * Return result-sets as array, rather than a JSON object. This is a faster way to get results @@ -636,5 +633,5 @@ export interface FieldInfo { long(): number | null; decimal(): number | null; date(): Date | null; - geometry(): Geometry | null; + geometry(): geojson.Geometry | null; } diff --git a/types/tsconfig.json b/types/tsconfig.json index a832d1d5..8c0e5555 100644 --- a/types/tsconfig.json +++ b/types/tsconfig.json @@ -13,7 +13,7 @@ "typeRoots": [ "../" ], - "types": [], + "types": ["node", "geojson"], "noEmit": true, "forceConsistentCasingInFileNames": true }, From f697e9591601cde0f7a83366a21b91ead0f1db81 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 10:38:31 +0200 Subject: [PATCH 08/17] [misc] code style correction --- benchmarks/common_benchmarks.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/benchmarks/common_benchmarks.js b/benchmarks/common_benchmarks.js index 60576324..f78ec78d 100644 --- a/benchmarks/common_benchmarks.js +++ b/benchmarks/common_benchmarks.js @@ -198,7 +198,10 @@ function Bench() { for (let i = 0; i < bench.initFcts.length; i++) { console.log('initializing test data ' + (i + 1) + '/' + bench.initFcts.length); if (bench.initFcts[i]) { - bench.initFcts[i][0].call(this, bench.initFcts[i][0] ? bench.CONN.PROMISE_MARIADB.drv : bench.CONN.MARIADB.drv); + bench.initFcts[i][0].call( + this, + bench.initFcts[i][0] ? bench.CONN.PROMISE_MARIADB.drv : bench.CONN.MARIADB.drv + ); } } this.currentNb = 0; From aa25af9a82bbfe1d3691ddccfc9744c14868c7e4 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 10:39:04 +0200 Subject: [PATCH 09/17] [misc] update dependencies to latest version --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index e881820a..636abf3c 100644 --- a/package.json +++ b/package.json @@ -53,23 +53,23 @@ "moment-timezone": "^0.5.26" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^1.11.0", - "@typescript-eslint/parser": "^1.11.0", + "@typescript-eslint/eslint-plugin": "^2.1.0", + "@typescript-eslint/parser": "^2.1.0", "benchmark": "^2.1.4", "chai": "^4.2.0", "codecov": "^3.5.0", "colors": "^1.3.2", "dom-parser": "^0.1.6", - "error-stack-parser": "^2.0.1", - "eslint": "^5.15.3", - "eslint-config-prettier": "^4.3.0", + "error-stack-parser": "^2.0.3", + "eslint": "^6.3.0", + "eslint-config-prettier": "^6.2.0", "eslint-plugin-markdown": "^1.0.0-rc.0", "eslint-plugin-prettier": "^3.1.0", - "mocha": "^6.1.4", + "mocha": "^6.2.0", "mocha-lcov-reporter": "^1.3.0", "nyc": "^14.1.1", "prettier": "^1.18.2", - "typescript": "^3.5.2" + "typescript": "^3.5.3" }, "bugs": { "url": "https://jira.mariadb.org/projects/CONJS/" From 4da0e5aae73baa0f7f632fa894bfa4bcfe7651a4 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 10:46:49 +0200 Subject: [PATCH 10/17] [misc] CI testing replacing node.js v11 by supported LTS v12 --- .travis.yml | 30 +++++++++++++++--------------- appveyor.yml | 16 ++++++++-------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6353b2bd..d831c043 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,10 +39,10 @@ env: matrix: allow_failures: - - node_js: "11" + - node_js: "12" env: DB=build include: - - node_js: "11" + - node_js: "12" env: DB=build - node_js: "6" env: DB=mariadb:10.4 SKIP_LEAK=1 @@ -50,31 +50,31 @@ matrix: env: DB=mariadb:10.4 - node_js: "10" env: DB=mariadb:10.4 - - node_js: "11" + - node_js: "12" env: DB=mariadb:10.4 - - node_js: "11" + - node_js: "12" env: DB=mariadb:10.4 LINT=1 - - node_js: "11" + - node_js: "12" env: DB=mariadb:10.4 BENCH=1 - - node_js: "11" + - node_js: "12" env: DB=mariadb:10.4 MAXSCALE_VERSION=2.2.9 TEST_PORT=4007 TEST_USER=bob TEXT_DATABASE=test2 - - node_js: "11" + - node_js: "12" env: DB=mariadb:5.5 - - node_js: "11" + - node_js: "12" env: DB=mariadb:10.0 - - node_js: "11" + - node_js: "12" env: DB=mariadb:10.1 - - node_js: "11" + - node_js: "12" env: DB=mariadb:10.2 - - node_js: "11" + - node_js: "12" env: DB=mariadb:10.3 - - node_js: "11" + - node_js: "12" env: DB=mysql:5.5 - - node_js: "11" + - node_js: "12" env: DB=mysql:5.6 - - node_js: "11" + - node_js: "12" env: DB=mysql:5.7 - - node_js: "11" + - node_js: "12" env: DB=mysql:8.0 notifications: diff --git a/appveyor.yml b/appveyor.yml index b6c5a2c3..d7d8c7df 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,37 +27,37 @@ environment: - DB: '10.4.6' MEM: "21" - nodejs_version: "11" + nodejs_version: "12" - DB: '10.4.6' - nodejs_version: "10" + nodejs_version: "12" MEM: "21" TEST_ZIP: 1 - DB: '10.4.6' - nodejs_version: "10" + nodejs_version: "12" MEM: "21" BENCH: "1" - DB: '10.3.16' MEM: "21" - nodejs_version: "10" + nodejs_version: "12" - DB: '10.2.25' MEM: "21" - nodejs_version: "10" + nodejs_version: "12" - DB: '10.1.40' MEM: "21" - nodejs_version: "10" + nodejs_version: "12" - DB: '10.0.38' MEM: "21" - nodejs_version: "10" + nodejs_version: "12" - DB: '5.5.64' MEM: "5" - nodejs_version: "10" + nodejs_version: "12" cache: - node_modules From 6ae18cc86b32723bfbdbd1d4dcfbc60596c498b0 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 10:51:15 +0200 Subject: [PATCH 11/17] [misc] removing node.js 6 from CI, ESLint 6 requiring 8 or newer --- .travis.yml | 2 -- .travis/script.sh | 2 +- appveyor.yml | 7 +------ 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index d831c043..c51b3495 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,8 +44,6 @@ matrix: include: - node_js: "12" env: DB=build - - node_js: "6" - env: DB=mariadb:10.4 SKIP_LEAK=1 - node_js: "8" env: DB=mariadb:10.4 - node_js: "10" diff --git a/.travis/script.sh b/.travis/script.sh index c8ca9cc8..e166681a 100644 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -25,7 +25,7 @@ else docker-compose -f .travis/docker-compose.yml up -d fi -if [ -z "$SKIP_LEAK" ] ; then npm install node-memwatch; fi +npm install node-memwatch node .travis/wait-for-docker-up.js diff --git a/appveyor.yml b/appveyor.yml index d7d8c7df..9846e7c8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,11 +12,6 @@ environment: TEST_LOG_PACKETS: true matrix: - - DB: '10.4.6' - MEM: "21" - nodejs_version: "6" - SKIP_LEAK: "1" - - DB: '10.4.6' MEM: "21" nodejs_version: "8" @@ -92,7 +87,7 @@ build: off test_script: - node --version - - if "%SKIP_LEAK%" == "" npm install node-memwatch + - npm install node-memwatch - if "%BENCH%" == "1" ( npm install microtime ) else ( npm test ) - if "%BENCH%" == "1" ( npm install promise-mysql mysql2 ) - if "%BENCH%" == "1" ( node c:\projects\mariadb-connector-nodejs\benchmarks\benchmarks.js ) From fbe82aa649a3ab00a9dc40b3eec8be6d9195434f Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 11:10:22 +0200 Subject: [PATCH 12/17] [misc] removing memory leak detection for node.js 12 until mem-watch compatibility --- .travis.yml | 30 +++++++++++++++--------------- .travis/script.sh | 2 +- appveyor.yml | 10 +++++++++- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index c51b3495..4f9003f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,40 +40,40 @@ env: matrix: allow_failures: - node_js: "12" - env: DB=build + env: DB=build SKIP_LEAK=1 include: - node_js: "12" - env: DB=build + env: DB=build SKIP_LEAK=1 - node_js: "8" env: DB=mariadb:10.4 - node_js: "10" env: DB=mariadb:10.4 - node_js: "12" - env: DB=mariadb:10.4 + env: DB=mariadb:10.4 SKIP_LEAK=1 - node_js: "12" - env: DB=mariadb:10.4 LINT=1 + env: DB=mariadb:10.4 LINT=1 SKIP_LEAK=1 - node_js: "12" - env: DB=mariadb:10.4 BENCH=1 + env: DB=mariadb:10.4 BENCH=1 SKIP_LEAK=1 - node_js: "12" - env: DB=mariadb:10.4 MAXSCALE_VERSION=2.2.9 TEST_PORT=4007 TEST_USER=bob TEXT_DATABASE=test2 + env: DB=mariadb:10.4 MAXSCALE_VERSION=2.2.9 TEST_PORT=4007 TEST_USER=bob TEXT_DATABASE=test2 SKIP_LEAK=1 - node_js: "12" - env: DB=mariadb:5.5 + env: DB=mariadb:5.5 SKIP_LEAK=1 - node_js: "12" - env: DB=mariadb:10.0 + env: DB=mariadb:10.0 SKIP_LEAK=1 - node_js: "12" - env: DB=mariadb:10.1 + env: DB=mariadb:10.1 SKIP_LEAK=1 - node_js: "12" - env: DB=mariadb:10.2 + env: DB=mariadb:10.2 SKIP_LEAK=1 - node_js: "12" - env: DB=mariadb:10.3 + env: DB=mariadb:10.3 SKIP_LEAK=1 - node_js: "12" - env: DB=mysql:5.5 + env: DB=mysql:5.5 SKIP_LEAK=1 - node_js: "12" - env: DB=mysql:5.6 + env: DB=mysql:5.6 SKIP_LEAK=1 - node_js: "12" - env: DB=mysql:5.7 + env: DB=mysql:5.7 SKIP_LEAK=1 - node_js: "12" - env: DB=mysql:8.0 + env: DB=mysql:8.0 SKIP_LEAK=1 notifications: email: false diff --git a/.travis/script.sh b/.travis/script.sh index e166681a..c8ca9cc8 100644 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -25,7 +25,7 @@ else docker-compose -f .travis/docker-compose.yml up -d fi -npm install node-memwatch +if [ -z "$SKIP_LEAK" ] ; then npm install node-memwatch; fi node .travis/wait-for-docker-up.js diff --git a/appveyor.yml b/appveyor.yml index 9846e7c8..ad7face2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,36 +23,44 @@ environment: - DB: '10.4.6' MEM: "21" nodejs_version: "12" + SKIP_LEAK: "1" - DB: '10.4.6' nodejs_version: "12" MEM: "21" TEST_ZIP: 1 + SKIP_LEAK: "1" - DB: '10.4.6' nodejs_version: "12" MEM: "21" BENCH: "1" + SKIP_LEAK: "1" - DB: '10.3.16' MEM: "21" nodejs_version: "12" + SKIP_LEAK: "1" - DB: '10.2.25' MEM: "21" nodejs_version: "12" + SKIP_LEAK: "1" - DB: '10.1.40' MEM: "21" nodejs_version: "12" + SKIP_LEAK: "1" - DB: '10.0.38' MEM: "21" nodejs_version: "12" + SKIP_LEAK: "1" - DB: '5.5.64' MEM: "5" nodejs_version: "12" + SKIP_LEAK: "1" cache: - node_modules @@ -87,7 +95,7 @@ build: off test_script: - node --version - - npm install node-memwatch + - if "%SKIP_LEAK%" == "" npm install node-memwatch - if "%BENCH%" == "1" ( npm install microtime ) else ( npm test ) - if "%BENCH%" == "1" ( npm install promise-mysql mysql2 ) - if "%BENCH%" == "1" ( node c:\projects\mariadb-connector-nodejs\benchmarks\benchmarks.js ) From a9e11b16c5d3a3bb0b201adc87c5d62cbdae8623 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 14:37:39 +0200 Subject: [PATCH 13/17] [misc] correcting SSL test that now can use TLSv1.3 protocol for MariaDB 10.4 --- benchmarks/common_benchmarks.js | 4 ++-- test/integration/test-ssl.js | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/benchmarks/common_benchmarks.js b/benchmarks/common_benchmarks.js index f78ec78d..18f34baf 100644 --- a/benchmarks/common_benchmarks.js +++ b/benchmarks/common_benchmarks.js @@ -197,10 +197,10 @@ function Bench() { console.log('start : init test : ' + bench.initFcts.length); for (let i = 0; i < bench.initFcts.length; i++) { console.log('initializing test data ' + (i + 1) + '/' + bench.initFcts.length); - if (bench.initFcts[i]) { + if (bench.initFcts[i][0]) { bench.initFcts[i][0].call( this, - bench.initFcts[i][0] ? bench.CONN.PROMISE_MARIADB.drv : bench.CONN.MARIADB.drv + bench.initFcts[i][1] ? bench.CONN.PROMISE_MARIADB.drv : bench.CONN.MARIADB.drv ); } } diff --git a/test/integration/test-ssl.js b/test/integration/test-ssl.js index 078ae2f7..c9d7eb6f 100644 --- a/test/integration/test-ssl.js +++ b/test/integration/test-ssl.js @@ -12,7 +12,6 @@ describe('ssl', function() { before(function(done) { if (process.env.MAXSCALE_VERSION) this.skip(); - console.log(tls.DEFAULT_MIN_VERSION); if ( process.platform === 'win32' && tls.DEFAULT_MIN_VERSION === 'TLSv1.2' && @@ -392,7 +391,7 @@ describe('ssl', function() { .createConnection({ host: 'mariadb.example.com', ssl: { ca: ca } }) .then(conn => { const isWin = process.platform === 'win32'; - let expectedProtocol = 'TLSv1.2'; + let expectedProtocol = ['TLSv1.2', 'TLSv1.3']; if (shareConn.info.isMariaDB()) { if (isWin && !shareConn.info.hasMinVersion(10, 4, 0)) { expectedProtocol = 'TLSv1.1'; @@ -527,7 +526,17 @@ describe('ssl', function() { function checkProtocol(conn, protocol) { const ver = process.version.substring(1).split('.'); - if (ver[0] > 5 || (ver[0] === 5 && ver[1] === 7)) { - assert.equal(conn.__tests.getSocket().getProtocol(), protocol); + const currentProtocol = conn.__tests.getSocket().getProtocol(); + + if (ver[0] > 5 || (ver[0] == 5 && ver[1] == 7)) { + if (Array.isArray(protocol)) { + for (let i = 0; i < protocol.length; i++) { + if (currentProtocol === protocol[i]) return; + } + //throw error + assert.equal(currentProtocol, protocol); + return; + } + assert.equal(currentProtocol, protocol); } } From 74ceab550391784fe99e759213caba8e3e04f727 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 15:48:09 +0200 Subject: [PATCH 14/17] [misc] force test TLSv1.1 compatibility if Node.js 12 and MySQL before version 8.0 --- test/integration/test-ssl.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/integration/test-ssl.js b/test/integration/test-ssl.js index c9d7eb6f..e2d81fd8 100644 --- a/test/integration/test-ssl.js +++ b/test/integration/test-ssl.js @@ -13,12 +13,12 @@ describe('ssl', function() { before(function(done) { if (process.env.MAXSCALE_VERSION) this.skip(); if ( - process.platform === 'win32' && tls.DEFAULT_MIN_VERSION === 'TLSv1.2' && - ((shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(10, 4, 0)) || + ((process.platform === 'win32' && shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(10, 4, 0)) || (!shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(8, 0, 0))) ) { - //TLSv1.2 is supported on windows only since MariaDB 10.4 and MySQL 8.0 + //TLSv1.2 is supported on windows only since MariaDB 10.4 + //TLSv1.2 is supported in MySQL only since 8.0 (unix/windows) //so if testing with Node.js 12, force possible TLS1.1 tls.DEFAULT_MIN_VERSION = 'TLSv1.1'; } From 0f542cc3641c8481a30340a99f6bc61438fbd393 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 17:12:36 +0200 Subject: [PATCH 15/17] [misc] small performance improvement to avoid testing debug each packet --- lib/connection.js | 1 + lib/io/packet-input-stream.js | 24 +++++++++++- lib/io/packet-output-stream.js | 72 +++++++++++++++++++++++----------- test/integration/test-ssl.js | 4 +- 4 files changed, 76 insertions(+), 25 deletions(-) diff --git a/lib/connection.js b/lib/connection.js index 22ca6e12..5b5ff763 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -442,6 +442,7 @@ function Connection(options) { */ this.debug = val => { opts.debug = val; + opts.emit('debug', opts.logPackets, opts.debug); }; this.debugCompress = val => { diff --git a/lib/io/packet-input-stream.js b/lib/io/packet-input-stream.js index 96a86a50..e4358a41 100644 --- a/lib/io/packet-input-stream.js +++ b/lib/io/packet-input-stream.js @@ -26,7 +26,9 @@ class PacketInputStream { this.parts = null; this.partsTotalLen = 0; this.changeEncoding(this.opts.collation); + this.changeDebug(this.opts.logPackets, this.opts.debug); this.opts.on('collation', this.changeEncoding.bind(this)); + this.opts.on('debug', this.changeDebug.bind(this)); } changeEncoding(collation) { @@ -36,10 +38,17 @@ class PacketInputStream { : PacketIconvEncoded; } - receivePacket(packet) { + changeDebug(logPackets, debug) { + this.logPackets = logPackets; + this.debug = debug; + this.receivePacket = + this.logPackets || this.debug ? this.receivePacketDebug : this.receivePacketBasic; + } + + receivePacketDebug(packet) { let cmd = this.currentCmd(); - if (packet && (this.opts.logPackets || this.opts.debug)) { + if (packet) { const packetStr = Utils.log(this.opts, packet.buf, packet.pos, packet.end, this.header); if (this.opts.logPackets) { this.info.addPacket( @@ -85,6 +94,17 @@ class PacketInputStream { if (!cmd.onPacketReceive) this.receiveQueue.shift(); } + receivePacketBasic(packet) { + let cmd = this.currentCmd(); + if (!cmd) { + this.unexpectedPacket(packet); + return; + } + cmd.sequenceNo = this.header[3]; + cmd.onPacketReceive(packet, this.out, this.opts, this.info); + if (!cmd.onPacketReceive) this.receiveQueue.shift(); + } + resetHeader() { this.remainingLen = null; this.headerLen = 0; diff --git a/lib/io/packet-output-stream.js b/lib/io/packet-output-stream.js index 0ba3c8ab..c43a90f3 100644 --- a/lib/io/packet-output-stream.js +++ b/lib/io/packet-output-stream.js @@ -30,7 +30,10 @@ class PacketOutputStream { this.pos = 4; this.buf = Buffer.allocUnsafe(SMALL_BUFFER_SIZE); this.changeEncoding(this.opts.collation); + this.changeDebug(this.opts.logPackets, this.opts.debug); + this.opts.on('collation', this.changeEncoding.bind(this)); + this.opts.on('debug', this.changeDebug.bind(this)); } changeEncoding(collation) { @@ -47,6 +50,13 @@ class PacketOutputStream { } } + changeDebug(logPackets, debug) { + this.logPackets = logPackets; + this.debug = debug; + this.flushBuffer = + this.logPackets || this.debug ? this.flushBufferDebug : this.flushBufferBasic; + } + setStream(stream) { this.stream = stream; } @@ -381,7 +391,7 @@ class PacketOutputStream { /** * Flush the internal buffer. */ - flushBuffer(commandEnd, remainingLen) { + flushBufferDebug(commandEnd, remainingLen) { this.buf[0] = this.pos - 4; this.buf[1] = (this.pos - 4) >>> 8; this.buf[2] = (this.pos - 4) >>> 16; @@ -389,31 +399,49 @@ class PacketOutputStream { this.stream.writeBuf(this.buf.slice(0, this.pos), this.cmd); - if (this.opts.logPackets || this.opts.debug) { - const packet = Utils.log(this.opts, this.buf, 0, this.pos); - if (this.opts.logPackets) { - this.info.addPacket( - '==> conn:' + - (this.info.threadId ? this.info.threadId : -1) + - ' ' + - this.cmd.constructor.name + - '(0,' + - this.pos + - ')\n' + - packet - ); - } + const packet = Utils.log(this.opts, this.buf, 0, this.pos); + if (this.opts.logPackets) { + this.info.addPacket( + '==> conn:' + + (this.info.threadId ? this.info.threadId : -1) + + ' ' + + this.cmd.constructor.name + + '(0,' + + this.pos + + ')\n' + + packet + ); + } - if (this.opts.debug) { - console.log( - '==> conn:%d %s\n%s', - this.info.threadId ? this.info.threadId : -1, - this.cmd.constructor.name + '(0,' + this.pos + ')', - Utils.log(this.opts, this.buf, 0, this.pos) - ); + if (this.opts.debug) { + console.log( + '==> conn:%d %s\n%s', + this.info.threadId ? this.info.threadId : -1, + this.cmd.constructor.name + '(0,' + this.pos + ')', + Utils.log(this.opts, this.buf, 0, this.pos) + ); + } + + if (commandEnd) { + //if last packet fill the max size, must send an empty com to indicate that command end. + if (this.pos === MAX_BUFFER_SIZE) { + this.writeEmptyPacket(); + } else { + this.stream.flush(true, this.cmd); + this.buf = Buffer.allocUnsafe(SMALL_BUFFER_SIZE); } + } else { + this.buf = allocateBuffer(remainingLen + 4); + this.pos = 4; } + } + flushBufferBasic(commandEnd, remainingLen) { + this.buf[0] = this.pos - 4; + this.buf[1] = (this.pos - 4) >>> 8; + this.buf[2] = (this.pos - 4) >>> 16; + this.buf[3] = ++this.cmd.sequenceNo; + this.stream.writeBuf(this.buf.slice(0, this.pos), this.cmd); if (commandEnd) { //if last packet fill the max size, must send an empty com to indicate that command end. if (this.pos === MAX_BUFFER_SIZE) { diff --git a/test/integration/test-ssl.js b/test/integration/test-ssl.js index e2d81fd8..e94b1c6a 100644 --- a/test/integration/test-ssl.js +++ b/test/integration/test-ssl.js @@ -14,7 +14,9 @@ describe('ssl', function() { if (process.env.MAXSCALE_VERSION) this.skip(); if ( tls.DEFAULT_MIN_VERSION === 'TLSv1.2' && - ((process.platform === 'win32' && shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(10, 4, 0)) || + ((process.platform === 'win32' && + shareConn.info.isMariaDB() && + !shareConn.info.hasMinVersion(10, 4, 0)) || (!shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(8, 0, 0))) ) { //TLSv1.2 is supported on windows only since MariaDB 10.4 From 0c0df1af843887f564b14fc3ec2856748fa4fb55 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 5 Sep 2019 17:17:53 +0200 Subject: [PATCH 16/17] [misc] test TLS minimum version change in order to test old mysql server with Node.js 12 --- test/integration/test-ssl.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/integration/test-ssl.js b/test/integration/test-ssl.js index e94b1c6a..0dbd665c 100644 --- a/test/integration/test-ssl.js +++ b/test/integration/test-ssl.js @@ -22,7 +22,12 @@ describe('ssl', function() { //TLSv1.2 is supported on windows only since MariaDB 10.4 //TLSv1.2 is supported in MySQL only since 8.0 (unix/windows) //so if testing with Node.js 12, force possible TLS1.1 - tls.DEFAULT_MIN_VERSION = 'TLSv1.1'; + if (!shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(5, 7, 0)) { + //MySQL 5.5 and MySQL 5.6 needs TLSv1 + tls.DEFAULT_MIN_VERSION = 'TLSv1'; + } else { + tls.DEFAULT_MIN_VERSION = 'TLSv1.1'; + } } if (process.env.TEST_SSL_CA_FILE) { From 24bc77b017bac127c8a80625774cc241dc49dfe1 Mon Sep 17 00:00:00 2001 From: rusher Date: Fri, 6 Sep 2019 02:17:53 +0200 Subject: [PATCH 17/17] [misc] adding changelog for 2.1.1 --- documentation/changelog.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/documentation/changelog.md b/documentation/changelog.md index 2e02d948..178fb3ad 100644 --- a/documentation/changelog.md +++ b/documentation/changelog.md @@ -1,3 +1,12 @@ +#### 2.1.1 - 06-09-2019 + +* node.je v12 CI testing +* cluster ordered selector bug fix on failover (thanks to @kkx) +* bump dependencies +* documentation update with node.js v12 minimum TLSv1.2 default support +* connection.reset() error message improvement (and documentation) +* small performance improvement when debug not enable + #### 2.1.0 - 11-07-2019 * [CONJS-19] implement Ed25519 plugin