Skip to content

Commit 530f16c

Browse files
committed
[misc] add maxscale CI testing
1 parent ff26150 commit 530f16c

File tree

10 files changed

+67
-61
lines changed

10 files changed

+67
-61
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616
env:
1717
TEST_DB_HOST: mariadb.example.com
1818
TEST_DB_PORT: 3306
19-
TEST_DB_USER: root
19+
TEST_DB_USER: testuser
2020
TEST_DB_PASSWORD: "heyPassw-!*20oRd"
2121
TEST_DB_DATABASE: testn
2222
jobs:
@@ -32,7 +32,7 @@ jobs:
3232
outputs:
3333
matrix: ${{ steps.set-matrix.outputs.final-matrix }}
3434
steps:
35-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v6
3636
- id: set-matrix
3737
name: build matrix
3838
uses: mariadb-corporation/connector-ci-build-matrix@main
@@ -49,13 +49,12 @@ jobs:
4949
runs-on: ${{ matrix.os }}
5050
continue-on-error: ${{ matrix.continue-on-error || false }}
5151
steps:
52-
- uses: actions/checkout@v4
52+
- uses: actions/checkout@v6
5353

5454
- name: Setup Test Environment
5555
id: setup-env
5656
uses: mariadb-corporation/connector-ci-setup@master
5757
with:
58-
node-version: ${{ matrix.node }}
5958
db-type: ${{ matrix.db-type }}
6059
db-tag: ${{ matrix.db-tag }}
6160
test-db-password: ${{ env.TEST_DB_PASSWORD }}
@@ -65,8 +64,9 @@ jobs:
6564
registry-user: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_USER || (secrets.DOCKER_TOKEN != '' && secrets.DOCKER_LOGIN || '') }}
6665
registry-password: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_TOKEN || secrets.DOCKER_TOKEN }}
6766
os: ${{ matrix.os }}
67+
maxscale-tag: ${{ matrix.maxscale-tag || ''}}
6868

69-
- uses: actions/setup-node@v4
69+
- uses: actions/setup-node@v6
7070
if: ${{ !matrix.deno }}
7171
with:
7272
node-version: ${{ matrix.node }}

test/base.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export function isMaxscale(shareConn) {
2121
globalThis.maxscaleVersion = shareConn.info.maxscaleVersion;
2222
if (!maxscaleVersion) {
2323
// maxscale before 23.08
24-
return getEnv('DB_TYPE') === 'maxscale' || getEnv('srv') === 'maxscale';
24+
let maxscaletag = getEnv('maxscale-tag');
25+
return maxscaletag != null && maxscaletag != '';
2526
}
2627
}
2728
return true;

test/integration/auth-plugin.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,17 @@ describe.concurrent('authentication plugin', () => {
652652
} catch (e) {
653653
strictPasswordValidation = false;
654654
}
655+
if (!strictPasswordValidation) {
656+
try {
657+
const res = await shareConn.query(
658+
"SELECT * FROM information_schema.PLUGINS WHERE PLUGIN_NAME = 'simple_password_check' " +
659+
"AND PLUGIN_STATUS = 'ACTIVE'"
660+
);
661+
if (res.length > 0) strictPasswordValidation = true;
662+
} catch (e) {
663+
// ignore
664+
}
665+
}
655666

656667
await shareConn.query('drop user verifParsec' + getHostSuffix()).catch(() => {});
657668
await shareConn.query(

test/integration/batch.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import os from 'node:os';
99
import path from 'node:path';
1010
import Conf from '../conf.js';
1111
import ColumnDef from '../../lib/cmd/column-definition.js';
12-
import { createConnection, getEnv, utf8Collation } from '../base.js';
12+
import { createConnection, getEnv, isMaxscale, utf8Collation } from '../base.js';
1313
import { assert, describe, test, beforeAll, afterAll, beforeEach } from 'vitest';
1414

1515
const str = utf8Collation() ? "abcdefghijkflmn'opqrtuvwx🤘💪" : 'abcdefghijkflmn\'opqrtuvwxyz"';
@@ -1429,6 +1429,7 @@ describe.sequential(
14291429

14301430
test('technical option fullResult', async ({ skip }) => {
14311431
if (!shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(5, 6, 0)) return skip();
1432+
14321433
await shareConn.query('DROP TABLE IF EXISTS bufLength');
14331434
await shareConn.query('create table bufLength (val varchar(32))');
14341435
await shareConn.query('FLUSH TABLES');
@@ -1455,14 +1456,16 @@ describe.sequential(
14551456
assert.deepEqual(res, { affectedRows: 4, insertId: 0n, warningStatus: 0 });
14561457
await conn.end();
14571458

1459+
const supportBulkUnitResults = (shareConn.info.clientCapabilities & Capabilities.BULK_UNIT_RESULTS) > 0n;
1460+
14581461
const connBulk = await createConnection({ bulk: true });
14591462
res = await connBulk.batch('INSERT INTO bufLength VALUES (?)', [
14601463
['abc'],
14611464
['cde'],
14621465
[1],
14631466
[new Date('2001-12-31 23:59:58')]
14641467
]);
1465-
if (shareConn.info.hasMinVersion(11, 5, 1) || !shareConn.info.isMariaDB()) {
1468+
if (supportBulkUnitResults || !shareConn.info.isMariaDB()) {
14661469
assert.deepEqual(res, [
14671470
{ affectedRows: 1, insertId: 0n, warningStatus: 0 },
14681471
{ affectedRows: 1, insertId: 0n, warningStatus: 0 },

test/integration/change-user.test.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ describe.concurrent('change user', () => {
4343

4444
test('mysql change user error', async ({ skip }) => {
4545
if (shareConn.info.isMariaDB()) return skip();
46+
if (isMaxscale(shareConn)) return skip();
4647
let logged = false;
4748
const conn = await createConnection({
4849
logger: {
@@ -81,6 +82,7 @@ describe.concurrent('change user', () => {
8182

8283
test('basic change user using callback', async ({ skip }) => {
8384
if (!shareConn.info.isMariaDB()) return skip();
85+
if (isMaxscale(shareConn)) return skip();
8486
const conn = createCallbackConnection();
8587
await new Promise((resolve, reject) => {
8688
conn.connect((err) => {
@@ -111,6 +113,7 @@ describe.concurrent('change user', () => {
111113

112114
test('wrong charset', async ({ skip }) => {
113115
if (!shareConn.info.isMariaDB()) return skip();
116+
if (isMaxscale(shareConn)) return skip();
114117
const conn = await createConnection();
115118
try {
116119
await conn.changeUser({
@@ -127,6 +130,7 @@ describe.concurrent('change user', () => {
127130

128131
test('wrong collation in charset', async ({ skip }) => {
129132
if (!shareConn.info.isMariaDB()) return skip();
133+
if (isMaxscale(shareConn)) return skip();
130134
const tmpLogFile = path.join(os.tmpdir(), 'wrongCollation.txt');
131135
try {
132136
fs.unlinkSync(tmpLogFile);
@@ -167,6 +171,7 @@ describe.concurrent('change user', () => {
167171

168172
test('wrong collation', async ({ skip }) => {
169173
if (!shareConn.info.isMariaDB()) return skip();
174+
if (isMaxscale(shareConn)) return skip();
170175
const conn = await createConnection();
171176
try {
172177
await conn.changeUser({
@@ -183,6 +188,7 @@ describe.concurrent('change user', () => {
183188

184189
test('basic change user using callback no function', async ({ skip }) => {
185190
if (!shareConn.info.isMariaDB()) return skip();
191+
if (isMaxscale(shareConn)) return skip();
186192
const conn = createCallbackConnection();
187193
await new Promise((resolve, reject) => {
188194
conn.connect((err) => {
@@ -204,6 +210,7 @@ describe.concurrent('change user', () => {
204210

205211
test('callback change user without option', async ({ skip }) => {
206212
if (!shareConn.info.isMariaDB()) return skip();
213+
if (isMaxscale(shareConn)) return skip();
207214
await new Promise((resolve, reject) => {
208215
const conn = createCallbackConnection();
209216
conn.connect((err) => {
@@ -225,7 +232,7 @@ describe.concurrent('change user', () => {
225232

226233
test('basic change user using promise', async ({ skip }) => {
227234
if (!shareConn.info.isMariaDB()) return skip();
228-
235+
if (isMaxscale(shareConn)) return skip();
229236
const conn = await createConnection();
230237
await conn.changeUser({
231238
user: 'ChangeUser',
@@ -248,7 +255,7 @@ describe.concurrent('change user', () => {
248255

249256
test('change user using connection attributes', async ({ skip }) => {
250257
if (!shareConn.info.isMariaDB()) return skip();
251-
258+
if (isMaxscale(shareConn)) return skip();
252259
const conn = await createConnection({ connectAttributes: { param1: 'test' } });
253260
await conn.changeUser({
254261
user: 'ChangeUser',
@@ -272,7 +279,7 @@ describe.concurrent('change user', () => {
272279

273280
test('basic change user using promise non node.js encoding', async ({ skip }) => {
274281
if (!shareConn.info.isMariaDB()) return skip();
275-
282+
if (isMaxscale(shareConn)) return skip();
276283
const conn = await createConnection();
277284
await conn.changeUser({
278285
user: 'ChangeUser',
@@ -296,6 +303,7 @@ describe.concurrent('change user', () => {
296303

297304
test('change user with collation', async ({ skip }) => {
298305
if (!shareConn.info.isMariaDB()) return skip();
306+
if (isMaxscale(shareConn)) return skip();
299307
const conn = await createConnection();
300308
await conn.changeUser({
301309
user: 'ChangeUser',
@@ -311,6 +319,7 @@ describe.concurrent('change user', () => {
311319

312320
test('MySQL change user disabled', async ({ skip }) => {
313321
if (shareConn.info.isMariaDB()) return skip();
322+
if (isMaxscale(shareConn)) return skip();
314323
try {
315324
await shareConn.changeUser({ user: 'ChangeUser' });
316325
throw new Error('must have thrown an error');
@@ -321,6 +330,7 @@ describe.concurrent('change user', () => {
321330

322331
test('autocommit state after changing user', async ({ skip }) => {
323332
if (!shareConn.info.isMariaDB()) return skip();
333+
if (isMaxscale(shareConn)) return skip();
324334
const conn = await createConnection();
325335
assert.equal(conn.info.status & ServerStatus.STATUS_AUTOCOMMIT, 2);
326336
await conn.query('SET autocommit=1');
@@ -344,6 +354,7 @@ describe.concurrent('change user', () => {
344354

345355
test('collation index > 255', async ({ skip }) => {
346356
if (!shareConn.info.isMariaDB()) return skip(); // requires mariadb 10.2+
357+
if (isMaxscale(shareConn)) return skip();
347358
const conn = await createConnection();
348359
const res = await conn.query('SELECT @@COLLATION_CONNECTION as c');
349360
assert.notEqual(res[0].c, 'utf8mb4_unicode_520_nopad_ci');

test/integration/connection.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,14 @@ describe.concurrent('connection', () => {
335335

336336
test('connection.destroy() when executing', async () => {
337337
const conn = await createConnection();
338-
conn.query('SELECT 1');
339-
conn.destroy();
338+
conn.query('SELECT 1').catch((err) => {});
339+
await conn.destroy();
340340
}, 10000);
341341

342342
test('connection.close alias', async () => {
343343
const conn = await createConnection({ keepAliveDelay: 100 });
344-
conn.query('SELECT 1');
345-
conn.close();
344+
conn.query('SELECT 1').catch((err) => {});
345+
await conn.close();
346346
}, 10000);
347347

348348
test('connection.destroy() during query execution', async ({ skip }) => {

test/integration/file.test.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as basePromise from '../../promise.js';
77
import * as baseCallback from '../../callback.js';
88
import Conf from '../conf.js';
99
import { assert, describe, test, beforeAll, afterAll, beforeEach, afterEach } from 'vitest';
10-
import { createConnection, createPool, createCallbackConnection, createPoolCallback } from '../base.js';
10+
import { createConnection, createPool, createCallbackConnection, createPoolCallback, isMaxscale } from '../base.js';
1111

1212
describe('sql file import', () => {
1313
let maxAllowedSize;
@@ -46,7 +46,8 @@ describe('sql file import', () => {
4646
}
4747
});
4848

49-
test('simple file import with direct connection options', async function () {
49+
test('simple file import with direct connection options', async ({ skip }) => {
50+
if (isMaxscale(shareConn)) return skip();
5051
await basePromise.importFile(
5152
Object.assign({}, Conf.baseConfig, { file: __dirname + '/../tools/data-dump.sql', database: 'fimp' })
5253
);
@@ -212,7 +213,8 @@ describe('sql file import', () => {
212213
});
213214
});
214215

215-
test('simple file import without callback', async () => {
216+
test('simple file import without callback', async ({ skip }) => {
217+
if (isMaxscale(shareConn)) return skip();
216218
baseCallback.importFile(
217219
Object.assign({}, Conf.baseConfig, { file: __dirname + '/../tools/data-dump.sql', database: 'fimp' })
218220
);
@@ -236,7 +238,8 @@ describe('sql file import', () => {
236238
});
237239
}, 30000);
238240

239-
test('simple file import with direct connection options', async () => {
241+
test('simple file import with direct connection options', async ({skip}) => {
242+
if (isMaxscale(shareConn)) return skip();
240243
await new Promise((resolve, reject) => {
241244
baseCallback.importFile(
242245
Object.assign({}, Conf.baseConfig, { file: __dirname + '/../tools/data-dump.sql', database: 'fimp' }),

test/integration/pool.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ describe.concurrent('Pool', () => {
580580

581581
await new Promise(function (resolver, rejecter) {
582582
pool.on('error', (err) => {
583+
console.log('error: ' + err);
583584
assert.isTrue(err.message.includes('Error during pool initialization'));
584585
assert.isNotNull(err.cause);
585586
assert.isTrue(

test/integration/redirection.test.js

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Proxy from '../tools/proxy.js';
77
import Conf from '../conf.js';
88
import { isMaxscale, isMaxscaleMinVersion, createConnection } from '../base.js';
99
import { assert, describe, test, beforeAll, afterAll } from 'vitest';
10+
import { skip } from 'node:test';
1011

1112
describe.concurrent('redirection', () => {
1213
let shareConn;
@@ -18,7 +19,8 @@ describe.concurrent('redirection', () => {
1819
shareConn = null;
1920
});
2021

21-
test('basic redirection', async function () {
22+
test('basic redirection', async ({ skip }) => {
23+
if (isMaxscale(shareConn)) return skip();
2224
const proxy = new Proxy({
2325
port: Conf.baseConfig.port,
2426
host: Conf.baseConfig.host,
@@ -49,43 +51,8 @@ describe.concurrent('redirection', () => {
4951
}
5052
});
5153

52-
test('maxscale redirection', async ({ skip }) => {
53-
// need maxscale 23.08+
54-
if (!isMaxscale(shareConn) || !isMaxscaleMinVersion(shareConn, 23, 8, 0)) return skip();
55-
const proxy = new Proxy({
56-
port: Conf.baseConfig.port,
57-
host: Conf.baseConfig.host,
58-
resetAfterUse: false
59-
});
60-
await proxy.start();
61-
62-
try {
63-
await shareConn.query(`set @@global.redirect_url="mariadb://${Conf.baseConfig.host}:${Conf.baseConfig.port}"`);
64-
} catch (e) {
65-
proxy.close();
66-
return skip();
67-
}
68-
let conn = await createConnection({ host: 'localhost', port: proxy.port(), permitRedirect: true });
69-
try {
70-
assert.equal(Conf.baseConfig.host, conn.info.host);
71-
assert.equal(Conf.baseConfig.port, conn.info.port);
72-
console.log(await conn.query('Select 1'));
73-
await conn.end();
74-
console.log('*****************************************************************************');
75-
let conn2 = await createConnection({ host: 'localhost', port: proxy.port() });
76-
assert.equal(Conf.baseConfig.port, conn2.info.port);
77-
console.log(await conn2.query('Select 2'));
78-
console.log('*****************************************************************************');
79-
await conn2.end();
80-
} finally {
81-
proxy.close();
82-
try {
83-
shareConn.query('set @@global.redirect_url=""');
84-
} catch (e) {}
85-
}
86-
});
87-
88-
test('redirection during pipelining', async function () {
54+
test('redirection during pipelining', async ({ skip }) => {
55+
if (isMaxscale(shareConn)) return skip();
8956
const proxy = new Proxy({
9057
port: Conf.baseConfig.port,
9158
host: Conf.baseConfig.host,
@@ -114,14 +81,20 @@ describe.concurrent('redirection', () => {
11481
}
11582
});
11683

117-
test('redirection during transaction', async function () {
84+
test('redirection during transaction', async ({ skip}) => {
85+
if (isMaxscale(shareConn)) return skip();
11886
const proxy = new Proxy({
11987
port: Conf.baseConfig.port,
12088
host: Conf.baseConfig.host,
12189
resetAfterUse: false
12290
});
12391
await proxy.start();
124-
let conn = await createConnection({ host: 'localhost', port: proxy.port(), permitRedirect: true });
92+
let conn = await createConnection({
93+
host: 'localhost',
94+
port: proxy.port(),
95+
permitRedirect: true,
96+
debug: true,
97+
debugLen: 1024 });
12598
try {
12699
assert.equal(proxy.port(), conn.info.port);
127100
let permitRedirection = true;

0 commit comments

Comments
 (0)