MXS-1300: Fix deletion of monitors

The monitors should only be reused if they have the same name and they use
the same module. This way the only difference is in configuration.

Fixed MaxCtrl detection of bad options and altered monitor creation test
to expect correct results. Also improved some of the error messages.
This commit is contained in:
Markus Mäkelä
2017-08-03 20:24:55 +03:00
parent af847c29c3
commit e133e758a6
6 changed files with 26 additions and 23 deletions

View File

@ -195,9 +195,9 @@ module.exports = function() {
}
}, function(err) {
if (err.response && err.response.body) {
return error('Server responded with an error to resource request `' + resource + '`:' + JSON.stringify(err.response.body, null, 4))
return error('Server responded with status code ' + err.statusCode + ' to `' + err.response.request.method +' ' + resource + '`:' + JSON.stringify(err.response.body, null, 4))
} else if (err.statusCode) {
return error('Server responded with: ' + err.statusCode + 'to resource request `' + resource + '`')
return error('Server responded with status code ' + err.statusCode + ' to `' + err.response.request.method +' ' + resource + '`')
} else if (err.error) {
return error(JSON.stringify(err.error, null, 4))
} else {

View File

@ -19,6 +19,8 @@ const maxctrl_version = '1.0.0';
program
.version(maxctrl_version)
.strict()
.exitProcess(false)
.showHelpOnFail(false)
.group(['u', 'p', 'h', 's', 't', 'q', 'tsv'], 'Global Options:')
.option('u', {
alias:'user',
@ -96,6 +98,10 @@ module.exports.execute = function(argv, opts) {
return new Promise(function(resolve, reject) {
program
.parse(argv, {resolve: resolve, reject: reject})
.parse(argv, {resolve: resolve, reject: reject}, function(err, argv, output) {
if (err) {
reject(err)
}
})
})
}

View File

@ -7,16 +7,15 @@ describe("Create/Destroy Commands", function() {
before(startMaxScale)
it('create monitor', function() {
return doCommand('create monitor my-monitor mysqlmon')
.then(function() {
return request.get(host + 'monitors/my-monitor', {json: true})
.should.be.fulfilled
})
return verifyCommand('create monitor my-monitor mysqlmon', 'monitors/my-monitor')
.should.be.fulfilled
})
it('destroy monitor', function() {
return doCommand('destroy monitor my-monitor')
.should.be.fulfilled
.then(() => doCommand('show monitor my-monitor'))
.should.be.rejected
})
it('destroy the same monitor again', function() {
@ -40,15 +39,9 @@ describe("Create/Destroy Commands", function() {
})
it('create monitor with options', function() {
return stopMaxScale()
.then(startMaxScale)
.then(function() {
return doCommand('unlink monitor MySQL-Monitor server4')
})
.then(function() {
return verifyCommand('create monitor my-monitor mysqlmon --servers server4 --monitor-user maxuser --monitor-password maxpwd',
'monitors/my-monitor')
})
return doCommand('unlink monitor MySQL-Monitor server4')
.then(() => verifyCommand('create monitor my-monitor mysqlmon --servers server4 --monitor-user maxuser --monitor-password maxpwd',
'monitors/my-monitor'))
.then(function(res) {
res.data.relationships.servers.data.length.should.equal(1)
res.data.relationships.servers.data[0].id.should.equal("server4")