8000 fix invalid handling of `_lastValue` in case of multiple coordinators by jsteemann · Pull Request #7734 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

fix invalid handling of _lastValue in case of multiple coordinators #7734

New issue

Have a question about this project? Sign up for a free GitHub account 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
merged 6 commits into from
Dec 12, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
make JS conditions simpler to understand
  • Loading branch information
jsteemann committed Dec 12, 2018
commit 2492ef45ca2ea4da94e7c5cb7132c589cac4d999
35 changes: 18 additions & 17 deletions tests/js/common/shell/shell-keygen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*jshint globalstrict:false, strict:false */
/*global assertEqual, assertTrue, assertEqual, assertMatch, fail, ArangoClusterComm */
/*global arango, assertEqual, assertTrue, assertEqual, assertMatch, fail, ArangoClusterComm */

////////////////////////////////////////////////////////////////////////////////
/// @brief test the traditional key generators
Expand Down Expand Up @@ -33,12 +33,17 @@ var jsunity = require("jsunity");
var arangodb = require("@arangodb");
var db = arangodb.db;
var ERRORS = arangodb.errors;
let cluster;
let cluster = false; // default to false
// quick hack to check if we are arangod or arangosh
if (typeof ArangoClusterComm === "object") {
cluster = require("@arangodb/cluster");
// arangod
cluster = require("@arangodb/cluster").isCluster();
} else {
cluster = {};
// arangosh
if (arango) {
let role = arango.GET("/_admin/server/role").role;
cluster = (role === "COORDINATOR");
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -69,15 +74,14 @@ function TraditionalSuite () {
try {
c.save({ _key: "1234" }); // no user keys allowed
fail();
}
catch (err) {
} catch (err) {
assertTrue(err.errorNum === ERRORS.ERROR_ARANGO_DOCUMENT_KEY_UNEXPECTED.code ||
err.errorNum === ERRORS.ERROR_CLUSTER_MUST_NOT_SPECIFY_KEY.code);
}
},

testCreateInvalidKeyNonDefaultSharding2 : function () {
if (!cluster || !cluster.isCluster || !cluster.isCluster()) {
if (!cluster) {
return;
}

Expand All @@ -86,15 +90,14 @@ function TraditionalSuite () {
try {
c.save({ _key: "1234" }); // no user keys allowed
fail();
}
catch (err) {
} catch (err) {
assertTrue(err.errorNum === ERRORS.ERROR_ARANGO_DOCUMENT_KEY_UNEXPECTED.code ||
err.errorNum === ERRORS.ERROR_CLUSTER_MUST_NOT_SPECIFY_KEY.code);
}
},

testCreateKeyNonDefaultSharding : function () {
if (!cluster || !cluster.isCluster || !cluster.isCluster()) {
if (!cluster) {
return;
}

Expand All @@ -115,8 +118,7 @@ function TraditionalSuite () {
try {
c.save({ _key: "1234" }); // no user keys allowed
fail();
}
catch (err) {
} catch (err) {
assertTrue(err.errorNum === ERRORS.ERROR_ARANGO_DOCUMENT_KEY_UNEXPECTED.code ||
err.errorNum === ERRORS.ERROR_CLUSTER_MUST_NOT_SPECIFY_KEY.code);
}
Expand All @@ -132,8 +134,7 @@ function TraditionalSuite () {
try {
c.save({ _key: "öä .mds 3 -6" }); // invalid key
fail();
}
catch (err) {
} catch (err) {
assertEqual(ERRORS.ERROR_ARANGO_DOCUMENT_KEY_BAD.code, err.errorNum);
}
},
Expand Down Expand Up @@ -218,7 +219,7 @@ function TraditionalSuite () {
},

testAutoincrementGeneratorInCluster : function () {
if (!cluster || !cluster.isCluster || !cluster.isCluster()) {
if (!cluster) {
return;
}

Expand Down Expand Up @@ -273,7 +274,7 @@ function TraditionalSuite () {
lastKey = key;
}

if (!cluster && !cluster.isCluster && !cluster.isCluster()) {
if (!cluster) {
assertEqual(lastKey, c.properties().keyOptions.lastValue);
}
},
Expand All @@ -295,7 +296,7 @@ function TraditionalSuite () {
lastKey = key;
}

if (!cluster && !cluster.isCluster && !cluster.isCluster()) {
if (!cluster) {
let hex = c.properties().keyOptions.lastValue.toString(16);
assertEqual(lastKey, Array(16 + 1 - hex.length).join("0") + hex);
}
Expand Down
0