From 2aec2826fcda7dfe2da3c95f5ecaacf024477d92 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 30 Jan 2023 14:21:43 +1100 Subject: [PATCH 1/6] build: enable compression for Bun unit tests --- .github/workflows/ci-bun.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-bun.yml b/.github/workflows/ci-bun.yml index 14ddb03faa..df02521e3c 100644 --- a/.github/workflows/ci-bun.yml +++ b/.github/workflows/ci-bun.yml @@ -20,10 +20,19 @@ jobs: strategy: fail-fast: false matrix: - bun-version: [0.5.1] + bun-version: [0.5.1, canary] mysql-version: ["mysql:5.7", "mysql:8.0.18", "mysql:8.0.22"] use-compression: [0] use-tls: [0] + include: + - bun-version: "0.5.1" + mysql-version: "mysql:8.0.22" + use-compression: 1 + use-tls: 0 + - bun-version: "canary" + mysql-version: "mysql:8.0.22" + use-compression: 1 + use-tls: 0 name: Bun ${{ matrix.bun-version }} - DB ${{ matrix.mysql-version }} - SSL=${{matrix.use-tls}} Compression=${{matrix.use-compression}} From 52598e86db5a08ba373dda30e8d4bccfc1a2c26d Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 30 Jan 2023 14:31:07 +1100 Subject: [PATCH 2/6] actually pass compression flag to the test --- .github/workflows/ci-bun.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-bun.yml b/.github/workflows/ci-bun.yml index df02521e3c..3d2c017e49 100644 --- a/.github/workflows/ci-bun.yml +++ b/.github/workflows/ci-bun.yml @@ -68,4 +68,4 @@ jobs: - name: Run tests # todo: run full test suite once test createServer is implemented using Bun.listen - run: FILTER=test-select MYSQL_PORT=3306 bun run test \ No newline at end of file + run: MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} FILTER=test-select MYSQL_PORT=3306 bun run test \ No newline at end of file From 1c528dc8a88dd65a71b6aec51b54867cbafbdaf2 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 30 Jan 2023 14:34:25 +1100 Subject: [PATCH 3/6] debug compressed protocol --- lib/compressed_protocol.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/compressed_protocol.js b/lib/compressed_protocol.js index 67a7c39c32..b2378649f8 100644 --- a/lib/compressed_protocol.js +++ b/lib/compressed_protocol.js @@ -7,6 +7,7 @@ const zlib = require('zlib'); const PacketParser = require('./packet_parser.js'); function handleCompressedPacket(packet) { + console.log('Handle compressed!!!'); // eslint-disable-next-line consistent-this, no-invalid-this const connection = this; const deflatedLength = packet.readInt24(); @@ -14,6 +15,7 @@ function handleCompressedPacket(packet) { if (deflatedLength !== 0) { connection.inflateQueue.push(task => { + console.log('inflate Body:::', Array.from(body)); zlib.inflate(body, (err, data) => { if (err) { connection._handleNetworkError(err); @@ -64,6 +66,8 @@ function writeCompressed(buffer) { // to assemble uncompressed result sequentially (function(seqId) { connection.deflateQueue.push(task => { + console.log('deflate Body:::', Array.from(buffer)); + process.exit(0); zlib.deflate(buffer, (err, compressed) => { if (err) { connection._handleFatalError(err); @@ -102,6 +106,7 @@ function writeCompressed(buffer) { } function enableCompression(connection) { + console.log('Enabling compression!!!') connection._lastWrittenPacketId = 0; connection._lastReceivedPacketId = 0; From c6984a613301c11e471d5a75f4cfe319009ef05e Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 30 Jan 2023 14:35:44 +1100 Subject: [PATCH 4/6] debug connection parameters --- test/common.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/common.js b/test/common.js index d06f327957..f324e7215e 100644 --- a/test/common.js +++ b/test/common.js @@ -80,6 +80,8 @@ exports.createConnection = function(args) { connectTimeout: args && args.connectTimeout, }; + console.log('create connection:', params) + // previously we had an adapter logic to benchmark against mysqljs/mysql and libmariaclient const driver = require('../index.js'); const conn = driver.createConnection(params); From a4143fa6b318d396220ca9d9ce29c5c5d6108d54 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 30 Jan 2023 17:20:48 +1100 Subject: [PATCH 5/6] debug --- .github/workflows/ci-bun.yml | 2 +- test/integration/connection/test-select-1.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-bun.yml b/.github/workflows/ci-bun.yml index 3d2c017e49..1fdd612ed6 100644 --- a/.github/workflows/ci-bun.yml +++ b/.github/workflows/ci-bun.yml @@ -68,4 +68,4 @@ jobs: - name: Run tests # todo: run full test suite once test createServer is implemented using Bun.listen - run: MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} FILTER=test-select MYSQL_PORT=3306 bun run test \ No newline at end of file + run: MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} FILTER=test-select-1 MYSQL_PORT=3306 bun run test \ No newline at end of file diff --git a/test/integration/connection/test-select-1.js b/test/integration/connection/test-select-1.js index b7066bda6c..8e7edce20b 100644 --- a/test/integration/connection/test-select-1.js +++ b/test/integration/connection/test-select-1.js @@ -5,7 +5,6 @@ const common = require('../../common'); const connection = common.createConnection(); connection.query('SELECT 1', (err, rows, fields) => { - console.log('query callback', err, rows, fields); assert.ifError(err); assert.deepEqual(rows, [{ 1: 1 }]); assert.equal(fields[0].name, '1'); From 0ca4581b6aa5118d2414b411d2e8db3de91d635b Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 30 Jan 2023 17:25:46 +1100 Subject: [PATCH 6/6] use process.exit(1) instead of process.exit(-1) --- lib/compressed_protocol.js | 4 +--- test/common.js | 2 +- test/integration/connection/test-multiple-results.js | 2 +- test/unit/pool-cluster/test-connection-restore.js | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/compressed_protocol.js b/lib/compressed_protocol.js index b2378649f8..75ab4466b2 100644 --- a/lib/compressed_protocol.js +++ b/lib/compressed_protocol.js @@ -7,7 +7,7 @@ const zlib = require('zlib'); const PacketParser = require('./packet_parser.js'); function handleCompressedPacket(packet) { - console.log('Handle compressed!!!'); + console.log('Handle compressed packet!!!'); // eslint-disable-next-line consistent-this, no-invalid-this const connection = this; const deflatedLength = packet.readInt24(); @@ -66,8 +66,6 @@ function writeCompressed(buffer) { // to assemble uncompressed result sequentially (function(seqId) { connection.deflateQueue.push(task => { - console.log('deflate Body:::', Array.from(buffer)); - process.exit(0); zlib.deflate(buffer, (err, compressed) => { if (err) { connection._handleFatalError(err); diff --git a/test/common.js b/test/common.js index f324e7215e..98d72e32bc 100644 --- a/test/common.js +++ b/test/common.js @@ -34,7 +34,7 @@ exports.waitDatabaseReady = function(callback) { conn.once('error', err => { if (err.code !== 'PROTOCOL_CONNECTION_LOST' && err.code !== 'ETIMEDOUT') { console.log('Unexpected error waiting for connection', err); - process.exit(-1); + process.exit(1); } try { conn.close(); diff --git a/test/integration/connection/test-multiple-results.js b/test/integration/connection/test-multiple-results.js index e9be7febe4..316c43ff1f 100644 --- a/test/integration/connection/test-multiple-results.js +++ b/test/integration/connection/test-multiple-results.js @@ -130,7 +130,7 @@ function do_test(testIndex) { } if (err) { console.log(err); - process.exit(-1); + process.exit(1); } const arrOrColumn = function(c) { if (Array.isArray(c)) { diff --git a/test/unit/pool-cluster/test-connection-restore.js b/test/unit/pool-cluster/test-connection-restore.js index 11f7ab918d..07bb8a849d 100644 --- a/test/unit/pool-cluster/test-connection-restore.js +++ b/test/unit/pool-cluster/test-connection-restore.js @@ -1,7 +1,7 @@ 'use strict'; if (process.platform === 'win32') { - console.log('This test is known to fail on windows. FIXME: investi=gate why'); + console.log('This test is known to fail on windows. FIXME: investigate why'); process.exit(0); }