MXS-1300: Add basic maxctrl tests
Added basic tests for maxctrl. They simply test that the diagnostic commands work.
This commit is contained in:
parent
d938dcc701
commit
738dc48df7
@ -6,6 +6,14 @@ if (NPM_FOUND)
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
add_custom_target(maxctrl ALL DEPENDS ${CMAKE_BINARY_DIR}/maxctrl/maxctrl)
|
||||
install_script(${CMAKE_BINARY_DIR}/maxctrl/maxctrl core)
|
||||
|
||||
add_custom_target(test_maxctrl
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/test/run_npm_test.sh
|
||||
${CMAKE_SOURCE_DIR} # Path to MaxScale sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR} # Path to test sources
|
||||
${CMAKE_BINARY_DIR}/maxctrl-test/ # Location where tests are built and run
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
else()
|
||||
message(STATUS "Not building MaxCtrl: npm not found")
|
||||
endif()
|
||||
|
@ -5,7 +5,7 @@
|
||||
"repository": "https://github.com/mariadb-corporation/MaxScale",
|
||||
"main": "maxctrl.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "mocha --timeout 30000 --slow 10000"
|
||||
},
|
||||
"keywords": [
|
||||
"maxscale"
|
||||
@ -22,5 +22,10 @@
|
||||
"request": "^2.81.0",
|
||||
"request-promise-native": "^1.0.3",
|
||||
"yargs": "^8.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"chai-as-promised": "^6.0.0",
|
||||
"mocha": "^3.3.0"
|
||||
}
|
||||
}
|
||||
|
35
maxctrl/test/diagnostics.js
Normal file
35
maxctrl/test/diagnostics.js
Normal file
@ -0,0 +1,35 @@
|
||||
require('../test_utils.js')()
|
||||
|
||||
describe("Diagnostic commands", function() {
|
||||
before(startMaxScale)
|
||||
|
||||
var ctrl = require('../core.js')
|
||||
var tests = [
|
||||
'list servers',
|
||||
'list services',
|
||||
'list monitors',
|
||||
'list sessions',
|
||||
'list filters',
|
||||
'list modules',
|
||||
'list users',
|
||||
'list commands',
|
||||
'show server server1',
|
||||
'show service RW-Split-Router',
|
||||
'show monitor MySQL-Monitor',
|
||||
'show session 5',
|
||||
'show filter Hint',
|
||||
'show module readwritesplit',
|
||||
'show maxscale',
|
||||
]
|
||||
|
||||
tests.forEach(function(i) {
|
||||
it(i, function() {
|
||||
return ctrl.execute(i.split(' '), {
|
||||
extra_args: [ '--quiet']
|
||||
})
|
||||
.should.be.fulfilled
|
||||
});
|
||||
})
|
||||
|
||||
after(stopMaxScale)
|
||||
});
|
26
maxctrl/test_utils.js
Normal file
26
maxctrl/test_utils.js
Normal file
@ -0,0 +1,26 @@
|
||||
var child_process = require("child_process")
|
||||
|
||||
module.exports = function() {
|
||||
this.request = require("request-promise-native")
|
||||
this.chai = require("chai")
|
||||
this.assert = require("assert")
|
||||
this.chaiAsPromised = require("chai-as-promised")
|
||||
chai.use(chaiAsPromised)
|
||||
this.should = chai.should()
|
||||
this.expect = chai.expect
|
||||
|
||||
this.startMaxScale = function(done) {
|
||||
child_process.execFile("./start_maxscale.sh", function(err, stdout, stderr) {
|
||||
if (process.env.MAXSCALE_DIR == null) {
|
||||
throw new Error("MAXSCALE_DIR is not set");
|
||||
}
|
||||
|
||||
done()
|
||||
})
|
||||
};
|
||||
this.stopMaxScale = function(done) {
|
||||
child_process.execFile("./stop_maxscale.sh", function(err, stdout, stderr) {
|
||||
done()
|
||||
})
|
||||
};
|
||||
}
|
@ -21,7 +21,7 @@ pkill -9 '^maxscale$'
|
||||
rm -r $maxscaledir/lib/maxscale
|
||||
rm -r $maxscaledir/cache/maxscale
|
||||
rm -r $maxscaledir/run/maxscale
|
||||
rm /tmp/maxadmin.sock
|
||||
test -f /tmp/maxadmin.sock && rm /tmp/maxadmin.sock
|
||||
|
||||
mkdir -m 0755 -p $maxscaledir/lib/maxscale
|
||||
mkdir -m 0755 -p $maxscaledir/cache/maxscale
|
||||
|
Loading…
x
Reference in New Issue
Block a user