MXS-2196: Fix most NPM unit test failures

The REST API and MaxCtrl tests relied upon the implicit sessions that were
created by the listeners. This can be corrected and improved by creating
an actual connection to MaxScale to check that a client session is indeed
created.
This commit is contained in:
Markus Mäkelä 2018-12-04 09:52:36 +02:00
parent cb18670013
commit 4b8393b2ee
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 20 additions and 1 deletions

View File

@ -24,7 +24,7 @@ var tests = [
'show server server1',
'show service RW-Split-Router',
'show monitor MariaDB-Monitor',
'show session 5',
'show sessions',
'show filter Hint',
'show module readwritesplit',
'show maxscale',

View File

@ -12,6 +12,7 @@
"ajv": "^5.5.2",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"mariadb": "^2.0.1-beta",
"mocha": "^5.2.0",
"request": "^2.87.0",
"request-promise-native": "^1.0.5"

View File

@ -1,6 +1,20 @@
// These tests use the server/test/maxscale_test.cnf configuration
require("../utils.js")()
const mariadb = require('mariadb');
var conn
function createConnection() {
return mariadb.createConnection({host: '127.0.0.1', port: 4006, user: 'maxuser', password: 'maxpwd'})
.then(c => {
conn = c
})
}
function closeConnection() {
conn.end()
conn = null
}
describe("Resource Collections", function() {
before(startMaxScale)
@ -36,6 +50,7 @@ describe("Resource Collections", function() {
describe("Individual Resources", function() {
before(startMaxScale)
before(createConnection)
var tests = [
"/servers/server1",
@ -63,11 +78,13 @@ describe("Individual Resources", function() {
});
})
after(closeConnection)
after(stopMaxScale)
});
describe("Resource Self Links", function() {
before(startMaxScale)
before(createConnection)
var tests = [
"/servers",
@ -108,5 +125,6 @@ describe("Resource Self Links", function() {
});
})
after(closeConnection)
after(stopMaxScale)
});