Skip to content

Commit 625b1dd

Browse files
committed
[misc] add SkySQL testing
1 parent 9b4b56a commit 625b1dd

28 files changed

+497
-196
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ matrix:
4444
include:
4545
- node_js: "12"
4646
env: DB=build SKIP_LEAK=1
47+
- node_js: "12"
48+
env: SKYSQL=true SKIP_LEAK=1
4749
- node_js: "10"
4850
env: DB=mariadb:10.4
4951
- node_js: "12"

.travis/script.sh

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,54 @@ set -e
77
# test different type of configuration
88
###################################################################################################################
99

10-
if [ "$DB" = "build" ] ; then
11-
.travis/build/build.sh
12-
docker build -t build:latest --label build .travis/build/
13-
fi
10+
if [ -n "$SKYSQL" ] ; then
11+
12+
if [ -z "$SKYSQL_TEST_HOST" ] ; then
13+
echo "No SkySQL configuration found !"
14+
exit 1
15+
fi
16+
17+
export TEST_USER=$SKYSQL_TEST_USER
18+
export TEST_HOST=$SKYSQL_TEST_HOST
19+
export TEST_PASSWORD=$SKYSQL_TEST_PASSWORD
20+
export TEST_PORT=$SKYSQL_TEST_PORT
21+
export TEST_SSL_CA=$SKYSQL_TEST_SSL_CA
22+
export TEST_BULK=false
1423

15-
export ENTRYPOINT=$PROJ_PATH/.travis/entrypoint
16-
if [ -n "$MAXSCALE_VERSION" ] ; then
17-
###################################################################################################################
18-
# launch Maxscale with one server
19-
###################################################################################################################
20-
export COMPOSE_FILE=.travis/maxscale-compose.yml
21-
export ENTRYPOINT=$PROJ_PATH/.travis/sql
22-
docker-compose -f ${COMPOSE_FILE} build
23-
docker-compose -f ${COMPOSE_FILE} up -d
2424
else
25-
docker-compose -f .travis/docker-compose.yml up -d
26-
fi
2725

28-
if [ -z "$SKIP_LEAK" ] ; then npm install node-memwatch; fi
26+
if [ "$DB" = "build" ] ; then
27+
.travis/build/build.sh
28+
docker build -t build:latest --label build .travis/build/
29+
fi
30+
31+
export ENTRYPOINT=$PROJ_PATH/.travis/entrypoint
32+
if [ -n "$MAXSCALE_VERSION" ] ; then
33+
###################################################################################################################
34+
# launch Maxscale with one server
35+
###################################################################################################################
36+
export COMPOSE_FILE=.travis/maxscale-compose.yml
37+
export ENTRYPOINT=$PROJ_PATH/.travis/sql
38+
docker-compose -f ${COMPOSE_FILE} build
39+
docker-compose -f ${COMPOSE_FILE} up -d
40+
else
41+
docker-compose -f .travis/docker-compose.yml up -d
42+
fi
2943

30-
node .travis/wait-for-docker-up.js
44+
if [ -z "$SKIP_LEAK" ] ; then npm install node-memwatch; fi
3145

32-
if [ -z "$MAXSCALE_VERSION" ] ; then
33-
docker-compose -f .travis/docker-compose.yml exec -u root db bash /pam/pam.sh
34-
sleep 1
35-
docker-compose -f .travis/docker-compose.yml stop db
36-
sleep 1
37-
docker-compose -f .travis/docker-compose.yml up -d
38-
docker-compose -f .travis/docker-compose.yml logs db
39-
node --version
4046
node .travis/wait-for-docker-up.js
47+
48+
if [ -z "$MAXSCALE_VERSION" ] ; then
49+
docker-compose -f .travis/docker-compose.yml exec -u root db bash /pam/pam.sh
50+
sleep 1
51+
docker-compose -f .travis/docker-compose.yml stop db
52+
sleep 1
53+
docker-compose -f .travis/docker-compose.yml up -d
54+
docker-compose -f .travis/docker-compose.yml logs db
55+
node --version
56+
node .travis/wait-for-docker-up.js
57+
fi
4158
fi
4259

4360
if [ -n "$LINT" ] ; then npm run test:lint; fi

lib/cmd/handshake/client-capabilities.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ module.exports.init = function (opts, info) {
6060
}
6161
}
6262

63+
if (opts.bulk) {
64+
if (info.serverCapabilities.high & Capabilities.MARIADB_CLIENT_STMT_BULK_OPERATIONS) {
65+
capabilitiesHigh |= Capabilities.MARIADB_CLIENT_STMT_BULK_OPERATIONS;
66+
}
67+
}
68+
6369
if (opts.permitConnectionWhenExpired) {
6470
capabilitiesLow |= Capabilities.CAN_HANDLE_EXPIRED_PASSWORDS;
6571
}

lib/cmd/handshake/handshake.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,31 @@ class Handshake extends Command {
2222
this.plugin = this;
2323
}
2424

25+
ensureOptionCompatibility(opts, info) {
26+
if (
27+
opts.multipleStatements &&
28+
(info.serverCapabilities.low & Capabilities.MULTI_STATEMENTS) === 0
29+
) {
30+
return this.throwNewError(
31+
"Option `multipleStatements` enable, but server doesn'permits multi-statment",
32+
true,
33+
info,
34+
'08S01',
35+
Errors.ER_CLIENT_OPTION_INCOMPATIBILITY
36+
);
37+
}
38+
39+
if (opts.permitLocalInfile && (info.serverCapabilities.low & Capabilities.LOCAL_FILES) === 0) {
40+
return this.throwNewError(
41+
"Option `permitLocalInfile` enable, but server doesn'permits using local file",
42+
true,
43+
info,
44+
'08S01',
45+
Errors.ER_CLIENT_OPTION_INCOMPATIBILITY
46+
);
47+
}
48+
}
49+
2550
parseHandshakeInit(packet, out, opts, info) {
2651
if (packet.peek() === 0xff) {
2752
//in case that some host is not permit to connect server
@@ -31,6 +56,7 @@ class Handshake extends Command {
3156
}
3257

3358
let handshake = new InitialHandshake(packet, info);
59+
this.ensureOptionCompatibility(opts, info);
3460
ClientCapabilities.init(opts, info);
3561

3662
if (opts.ssl) {

lib/connection.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,12 @@ function Connection(options) {
621621
* @return {boolean} indicating if must use rewrite or bulk
622622
*/
623623
const canUseBulk = (values) => {
624-
let useBulk = info.isMariaDB() && info.hasMinVersion(10, 2, 7) && opts.bulk;
624+
let useBulk =
625+
info.isMariaDB() &&
626+
info.hasMinVersion(10, 2, 7) &&
627+
opts.bulk &&
628+
(info.serverCapabilities.high & Capabilities.MARIADB_CLIENT_STMT_BULK_OPERATIONS) > 0;
629+
625630
if (useBulk) {
626631
//ensure that there is no stream object
627632
if (values !== undefined) {

lib/const/capabilities.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,8 @@ module.exports.SSL_VERIFY_SERVER_CERT = 1 << 30;
5757

5858
/* MariaDB extended capabilities */
5959

60+
/* Permit bulk insert*/
61+
module.exports.MARIADB_CLIENT_STMT_BULK_OPERATIONS = 1 << (34 - 32);
62+
6063
/* Clients supporting extended metadata */
6164
module.exports.MARIADB_CLIENT_EXTENDED_TYPE_INFO = 1 << (35 - 32);

lib/misc/errors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ module.exports.ER_CLOSING_POOL = 45037;
9898
module.exports.ER_TIMEOUT_NOT_SUPPORTED = 45038;
9999
module.exports.ER_INITIAL_TIMEOUT_ERROR = 45039;
100100
module.exports.ER_DUPLICATE_FIELD = 45040;
101+
module.exports.ER_CLIENT_OPTION_INCOMPATIBILITY = 45041;
101102

102103
const keys = Object.keys(module.exports);
103104
const errByNo = {};

test/conf.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ if (process.env.TEST_SOCKET_PATH) baseConfig['socketPath'] = process.env.TEST_SO
1818
if (process.env.TEST_DEBUG_LEN) baseConfig['debugLen'] = process.env.TEST_DEBUG_LEN;
1919
if (process.env.TEST_COLLATION) baseConfig['collation'] = process.env.TEST_COLLATION;
2020
if (process.env.TEST_LOG_PACKETS) baseConfig['logPackets'] = true;
21+
if (process.env.TEST_SSL_CA) baseConfig['ssl'] = {ca: process.env.TEST_SSL_CA };
22+
if (process.env.TEST_BULK) baseConfig['bulk'] = process.env.TEST_BULK;
2123

2224
module.exports.baseConfig = baseConfig;

test/integration/test-auth-plugin.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ describe('authentication plugin', () => {
3333
);
3434
})
3535
.then(() => {
36-
return shareConn.query("GRANT ALL on *.* to verificationEd25519AuthPlugin@'%'");
36+
return shareConn.query(
37+
'GRANT SELECT on `' +
38+
Conf.baseConfig.database +
39+
"`.* to verificationEd25519AuthPlugin@'%'"
40+
);
3741
})
3842
.then(() => {
3943
base
@@ -90,7 +94,7 @@ describe('authentication plugin', () => {
9094
shareConn
9195
.query('CREATE USER ' + windowsUser + " IDENTIFIED VIA named_pipe using 'test'")
9296
.then(() => {
93-
return shareConn.query('GRANT ALL on *.* to ' + windowsUser);
97+
return shareConn.query('GRANT SELECT on *.* to ' + windowsUser);
9498
})
9599
.then(() => {
96100
return shareConn.query('select @@version_compile_os,@@socket soc');
@@ -139,7 +143,7 @@ describe('authentication plugin', () => {
139143
)
140144
.catch((err) => {});
141145
shareConn
142-
.query("GRANT ALL on *.* to '" + unixUser + "'@'" + Conf.baseConfig.host + "'")
146+
.query("GRANT SELECT on *.* to '" + unixUser + "'@'" + Conf.baseConfig.host + "'")
143147
.then(() => {
144148
base
145149
.createConnection({ user: null, socketPath: res[0].soc })
@@ -165,7 +169,7 @@ describe('authentication plugin', () => {
165169
shareConn.query("INSTALL PLUGIN pam SONAME 'auth_pam'").catch((err) => {});
166170
shareConn.query("DROP USER IF EXISTS 'testPam'@'%'").catch((err) => {});
167171
shareConn.query("CREATE USER 'testPam'@'%' IDENTIFIED VIA pam USING 'mariadb'");
168-
shareConn.query("GRANT ALL ON *.* TO 'testPam'@'%' IDENTIFIED VIA pam");
172+
shareConn.query("GRANT SELECT ON *.* TO 'testPam'@'%' IDENTIFIED VIA pam");
169173
shareConn.query('FLUSH PRIVILEGES');
170174

171175
//password is unix password "myPwd"
@@ -195,7 +199,7 @@ describe('authentication plugin', () => {
195199
shareConn.query("INSTALL PLUGIN pam SONAME 'auth_pam'").catch((err) => {});
196200
shareConn.query("DROP USER IF EXISTS 'testPam'@'%'").catch((err) => {});
197201
shareConn.query("CREATE USER 'testPam'@'%' IDENTIFIED VIA pam USING 'mariadb'");
198-
shareConn.query("GRANT ALL ON *.* TO 'testPam'@'%' IDENTIFIED VIA pam");
202+
shareConn.query("GRANT SELECT ON *.* TO 'testPam'@'%' IDENTIFIED VIA pam");
199203
shareConn.query('FLUSH PRIVILEGES');
200204

201205
//password is unix password "myPwd"
@@ -217,17 +221,19 @@ describe('authentication plugin', () => {
217221
});
218222

219223
it('multi authentication plugin', function (done) {
220-
if (process.env.MAXSCALE_VERSION) this.skip();
224+
if (process.env.MAXSCALE_VERSION || process.env.SKYSQL) this.skip();
221225
if (!shareConn.info.isMariaDB() || !shareConn.info.hasMinVersion(10, 4, 3)) this.skip();
222-
shareConn.query("drop user IF EXISTS mysqltest1@'%'");
226+
shareConn.query("drop user IF EXISTS mysqltest1@'%'").catch((err) => {});
223227
shareConn
224228
.query(
225229
"CREATE USER mysqltest1@'%' IDENTIFIED " +
226230
"VIA ed25519 as password('!Passw0rd3') " +
227231
" OR mysql_native_password as password('!Passw0rd3Works')"
228232
)
229233
.then(() => {
230-
return shareConn.query("grant all on *.* to mysqltest1@'%'");
234+
return shareConn.query(
235+
'grant SELECT on `' + Conf.baseConfig.database + "`.* to mysqltest1@'%'"
236+
);
231237
})
232238
.then(() => {
233239
return base.createConnection({

0 commit comments

Comments
 (0)