MXS-1220: Expand REST API test suite

Added tests for services and extended the monitor test suite to test
actions on monitors.
This commit is contained in:
Markus Mäkelä
2017-05-05 10:52:43 +03:00
parent 0e57bec4ef
commit 16e597d43e
2 changed files with 85 additions and 0 deletions

View File

@ -105,3 +105,31 @@ describe("Monitor Relationships", function() {
after(stopMaxScale)
})
describe("Monitor Actions", function() {
before(startMaxScale)
it("stop monitor", function() {
return request.put(base_url + "/monitors/MySQL-Monitor/stop")
.then(function() {
return request.get(base_url + "/monitors/MySQL-Monitor")
})
.then(function(resp) {
var mon = JSON.parse(resp)
mon.data.attributes.state.should.be.equal("Stopped")
})
});
it("start monitor", function() {
return request.put(base_url + "/monitors/MySQL-Monitor/start")
.then(function() {
return request.get(base_url + "/monitors/MySQL-Monitor")
})
.then(function(resp) {
var mon = JSON.parse(resp)
mon.data.attributes.state.should.be.equal("Running")
})
});
after(stopMaxScale)
})

View File

@ -0,0 +1,57 @@
require("../utils.js")()
describe("Service", function() {
before(startMaxScale)
it("change service parameter", function() {
return request.get(base_url + "/services/RW-Split-Router")
.then(function(resp) {
var svc = JSON.parse(resp)
svc.data.attributes.parameters.enable_root_user = true
return request.put(base_url + "/services/RW-Split-Router", {json: svc})
})
.then(function(resp) {
var svc = resp
svc.data.attributes.parameters.enable_root_user.should.be.true
})
});
it("remove service relationship", function() {
return request.get(base_url + "/services/RW-Split-Router")
.then(function(resp) {
var svc = JSON.parse(resp)
delete svc.data.relationships
return request.put(base_url + "/services/RW-Split-Router", {json: svc})
})
.then(function(resp) {
var svc = resp
svc.data.relationships.should.be.empty
})
});
it("add service relationship", function() {
return request.get(base_url + "/services/RW-Split-Router")
.then(function(resp) {
var svc = JSON.parse(resp)
svc.data.relationships = {
servers: {
data: [
{id: "server1", type: "servers"},
{id: "server2", type: "servers"},
{id: "server3", type: "servers"},
{id: "server4", type: "servers"},
]
}
}
return request.put(base_url + "/services/RW-Split-Router", {json: svc})
})
.then(function(resp) {
var svc = resp
svc.data.relationships.servers.data[0].id.should.be.equal("server1")
})
});
after(stopMaxScale)
});