8000 (mostly) restore pre-3.7 API behavior by jsteemann · Pull Request #11364 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

(mostly) restore pre-3.7 API behavior #11364

New issue

Have a question about this project? Sign up for a free GitHub acc 8000 ount to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions arangod/RestHandler/RestAdminClusterHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ RestStatus RestAdminClusterHandler::handlePutNumberOfServers() {
auto write = arangodb::agency::envelope<VPackBuilder>::create(builder).write();

VPackSlice numberOfCoordinators = body.get("numberOfCoordinators");
if (numberOfCoordinators.isNumber()) {
if (numberOfCoordinators.isNumber() || numberOfCoordinators.isNull()) {
write = std::move(write).set(targetPath->numberOfCoordinators()->str(),
numberOfCoordinators);
hasThingsToDo = true;
Expand All @@ -1331,7 +1331,7 @@ RestStatus RestAdminClusterHandler::handlePutNumberOfServers() {
}

VPackSlice numberOfDBServers = body.get("numberOfDBServers");
if (numberOfDBServers.isNumber()) {
if (numberOfDBServers.isNumber() || numberOfDBServers.isNull()) {
write = std::move(write).set(targetPath->numberOfDBServers()->str(), numberOfDBServers);
hasThingsToDo = true;
} else if (!numberOfDBServers.isNone()) {
Expand Down Expand Up @@ -1368,8 +1368,12 @@ RestStatus RestAdminClusterHandler::handlePutNumberOfServers() {
}

if (!hasThingsToDo) {
generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
"missing fields");
generateOk(rest::ResponseCode::OK, velocypack::Slice::noneSlice());
// TODO: the appropriate response would rather be
// generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
// "missing fields");
// but that would break API compatibility. Introduce this behavior
// in 4.0!!
return RestStatus::DONE;
}

Expand Down
89 changes: 89 additions & 0 deletions tests/js/client/shell/shell-numberof-servers-cluster.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*jshint globalstrict:false, strict:false, maxlen : 4000 */
/* global arango, assertFalse, assertEqual, assertNull */

////////////////////////////////////////////////////////////////////////////////
/// @brief tests for inventory
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Jan Steemann
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't care about that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't. I think we should do a global replace on all files. AFAIK Frank has a script for this, and I will ask him if he can run it once some of the huge PRs are merged.

////////////////////////////////////////////////////////////////////////////////

'use strict';
const jsunity = require('jsunity');

function numberOfServersSuite () {
return {
setUp : function () {
arango.PUT("/_admin/cluster/numberOfServers", { numberOfCoordinators: null, numberOfDBServers: null });
},

tearDown : function () {
arango.PUT("/_admin/cluster/numberOfServers", { numberOfCoordinators: null, numberOfDBServers: null });
},

testGet : function () {
let result = arango.GET("/_admin/cluster/numberOfServers");
assertFalse(result.error);
assertEqual(200, result.code);
assertNull(result.numberOfDBServers);
assertNull(result.numberOfCoordinators);
assertEqual([], result.cleanedServers);
},

testPutEmptyBody : function () {
let result = arango.PUT("/_admin/cluster/numberOfServers", {});
assertFalse(result.error);
assertEqual(200, result.code);
},

testPutNumberOfDBServers : function () {
let result = arango.PUT("/_admin/cluster/numberOfServers", { numberOfDBServers: 2 });
assertFalse(result.error);
assertEqual(200, result.code);

result = arango.GET("/_admin/cluster/numberOfServers");
assertFalse(result.error);
assertEqual(200, result.code);
assertEqual(2, result.numberOfDBServers);
assertNull(result.numberOfCoordinators);
assertEqual([], result.cleanedServers);
},

testPutNumberOfCoordinators : function () {
let result = arango.PUT("/_admin/cluster/numberOfServers", { numberOfCoordinators: 2 });
assertFalse(result.error);
assertEqual(200, result.code);

result = arango.GET("/_admin/cluster/numberOfServers");
assertFalse(result.error);
assertEqual(200, result.code);
assertNull(result.numberOfDBServers);
assertEqual(2, result.numberOfCoordinators);
assertEqual([], result.cleanedServers);
},

};
}

jsunity.run(numberOfServersSuite);
return jsunity.done();
0