1
0
Fork 0

Make error handling in move shard tests more robust. (#7418)

* Make getCleanedOutServers error handling more robust.

* Fix two more instances of getCleanedOutServers.
This commit is contained in:
Max Neunhöffer 2018-11-22 22:53:07 +01:00 committed by GitHub
parent cfe7c02a05
commit 7bf63cdb95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 5 deletions

View File

@ -119,11 +119,21 @@ function MovingShardsSuite () {
} catch (err) {
console.error(
"Exception for POST /_admin/cluster/cleanOutServer:", err.stack);
return {};
return {cleanedServers:[]};
}
if (res.statusCode !== 200) {
return {cleanedServers:[]};
}
var body = res.body;
if (typeof body === "string") {
body = JSON.parse(body);
try {
body = JSON.parse(body);
} catch (err2) {
}
}
if (typeof body !== "object" || !body.hasOwnProperty("cleanedServers") ||
typeof body.cleanedServers !== "object") {
return {cleanedServers:[]};
}
return body;
}

View File

@ -174,11 +174,21 @@ function MovingShardsWithViewSuite (options) {
} catch (err) {
console.error(
"Exception for POST /_admin/cluster/cleanOutServer:", err.stack);
return {};
return {cleanedServers:[]};
}
if (res.statusCode !== 200) {
return {cleanedServers:[]};
}
var body = res.body;
if (typeof body === "string") {
body = JSON.parse(body);
try {
body = JSON.parse(body);
} catch (err2) {
}
}
if (typeof body !== "object" || !body.hasOwnProperty("cleanedServers") ||
typeof body.cleanedServers !== "object") {
return {cleanedServers:[]};
}
return body;
}

View File

@ -250,15 +250,23 @@ describe('Shard distribution', function () {
const envelope =
{ method: "GET", url: url + "/_admin/cluster/numberOfServers" };
let res = request(envelope);
if (res.statusCode !== 200) {
return {cleanedServers: []};
}
var body = res.body;
if (typeof body === "string") {
body = JSON.parse(body);
}
if (typeof body !== "object" ||
!body.hasOwnProperty("cleanedServers") ||
typeof body.cleanedServers !== "object") {
return {cleanedServers:[]};
}
return body;
} catch (err) {
console.error(
"Exception for POST /_admin/cluster/cleanOutServer:", err.stack);
return {};
return {cleanedServers: []};
}
};