Skip to content

build: enable compression for Bun unit tests #1812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/ci-bun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Expand Down Expand Up @@ -59,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
run: MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} FILTER=test-select MYSQL_PORT=3306 bun run test
5 changes: 5 additions & 0 deletions lib/compressed_protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ 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();
const body = packet.readBuffer();

if (deflatedLength !== 0) {
connection.inflateQueue.push(task => {
console.log('inflate Body:::', Array.from(body));
zlib.inflate(body, (err, data) => {
if (err) {
connection._handleNetworkError(err);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -102,6 +106,7 @@ function writeCompressed(buffer) {
}

function enableCompression(connection) {
console.log('Enabling compression!!!')
connection._lastWrittenPacketId = 0;
connection._lastReceivedPacketId = 0;

Expand Down
2 changes: 2 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ exports.createConnection = function(args) {
connectTimeout: args && args.connectTimeout,
};

console.log('create connection:', params)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information

This logs sensitive data returned by [an access to MYSQL_PASSWORD](1) as clear text. This logs sensitive data returned by [an access to password](2) as clear text. This logs sensitive data returned by [an access to MYSQL_PASSWORD](3) as clear text. This logs sensitive data returned by [an access to password](4) as clear text. This logs sensitive data returned by [an access to password](5) as clear text.

// previously we had an adapter logic to benchmark against mysqljs/mysql and libmariaclient
const driver = require('../index.js');
const conn = driver.createConnection(params);
Expand Down