Files
MaxScale/maxctrl/test/service.js
Markus Mäkelä cf8028a5ce MXS-1300: Un-modularize the core
Making the core a module proved to bring more problems than it solved. For
the sake of simplicity in installation and code coverage reporting, the
core is now completely contained in the `lib/` directory.

Also added preliminary coverage reporting with nyc.
2017-07-23 08:21:00 +03:00

86 lines
3.4 KiB
JavaScript

require('../test_utils.js')()
var ctrl = require('../lib/core.js')
var opts = { extra_args: [ '--quiet'] }
describe("Service Commands", function() {
before(startMaxScale)
it('link servers to a service', function() {
return ctrl.execute('link service Read-Connection-Router server1 server2 server3 server4'.split(' '), opts)
.then(function() {
return request.get(host + 'services/Read-Connection-Router', {json: true})
})
.then(function(res) {
res.data.relationships.servers.data.length.should.equal(4)
res.data.relationships.servers.data[0].id.should.equal("server1")
res.data.relationships.servers.data[1].id.should.equal("server2")
res.data.relationships.servers.data[2].id.should.equal("server3")
res.data.relationships.servers.data[3].id.should.equal("server4")
})
})
it('link non-existent service to servers', function() {
return ctrl.execute('link service not-a-service server1 server2 server3 server4'.split(' '), opts)
.should.be.rejected
})
it('unlink servers from a service', function() {
return ctrl.execute('unlink service Read-Connection-Router server2 server3 server4'.split(' '), opts)
.then(function() {
return request.get(host + 'services/Read-Connection-Router', {json: true})
})
.then(function(res) {
res.data.relationships.servers.data.length.should.equal(1)
res.data.relationships.servers.data[0].id.should.equal("server1")
})
})
it('unlink non-existent service to servers', function() {
return ctrl.execute('unlink service not-a-service server1 server2 server3 server4'.split(' '), opts)
.should.be.rejected
})
it('alter service parameter', function() {
return ctrl.execute('alter service Read-Connection-Router user testuser'.split(' '), opts)
.then(function() {
return request.get(host + 'services/Read-Connection-Router', {json: true})
})
.then(function(res) {
res.data.attributes.parameters.user.should.equal("testuser")
})
})
it('alter non-existent service parameter', function() {
return ctrl.execute('alter service Read-Connection-Router turbocharge yes-please'.split(' '), opts)
.should.be.rejected
})
it('alter non-existent service', function() {
return ctrl.execute('alter service not-a-service user maxuser'.split(' '), opts)
.should.be.rejected
})
it('stop service', function() {
return ctrl.execute('stop service Read-Connection-Router'.split(' '), opts)
.then(function() {
return request.get(host + 'services/Read-Connection-Router', {json: true})
})
.then(function(res) {
res.data.attributes.state.should.equal("Stopped")
})
})
it('start service', function() {
return ctrl.execute('start service Read-Connection-Router'.split(' '), opts)
.then(function() {
return request.get(host + 'services/Read-Connection-Router', {json: true})
})
.then(function(res) {
res.data.attributes.state.should.equal("Started")
})
})
after(stopMaxScale)
});