From b280c59aa7ae41d78249a6563ff54555cc6b35c3 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 25 Sep 2015 11:50:33 +0200 Subject: [PATCH] Split tests that don't work in clusters. --- .../tests/shell-transactions-noncluster.js | 169 ++++++++++++++++++ js/common/tests/shell-transactions.js | 73 -------- 2 files changed, 169 insertions(+), 73 deletions(-) create mode 100644 js/common/tests/shell-transactions-noncluster.js diff --git a/js/common/tests/shell-transactions-noncluster.js b/js/common/tests/shell-transactions-noncluster.js new file mode 100644 index 0000000000..ce24872470 --- /dev/null +++ b/js/common/tests/shell-transactions-noncluster.js @@ -0,0 +1,169 @@ +/*jshint globalstrict:false, strict:false */ +/*global assertEqual, fail */ + +//////////////////////////////////////////////////////////////////////////////// +/// @brief tests for client/server side transaction invocation +/// +/// @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 +//////////////////////////////////////////////////////////////////////////////// + +var jsunity = require("jsunity"); +var arangodb = require("org/arangodb"); +var internal = require("internal"); +var ERRORS = arangodb.errors; +var db = arangodb.db; + +// ----------------------------------------------------------------------------- +// --SECTION-- transactions tests +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test suite +/// these tests won't work in the cluster since no cluster transactions are +/// available +//////////////////////////////////////////////////////////////////////////////// + +function TransactionsImplicitCollectionsSuite () { + 'use strict'; + + var cn1 = "UnitTestsTransaction1"; + var cn2 = "UnitTestsTransaction2"; + var c1 = null; + var c2 = null; + + return { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief set up +//////////////////////////////////////////////////////////////////////////////// + + setUp : function () { + db._drop(cn1); + db._drop(cn2); + c1 = db._create(cn1); + c2 = db._create(cn2); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief tear down +//////////////////////////////////////////////////////////////////////////////// + + tearDown : function () { + c1 = null; + c2 = null; + db._drop(cn1); + db._drop(cn2); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief uses an implicitly declared collection for writing +//////////////////////////////////////////////////////////////////////////////// + + testUseForWriting : function () { + try { + db._executeTransaction({ + collections: { }, + action: "function (params) { var db = require('internal').db; db._collection(params.cn1).truncate(); }", + params: { cn1: cn1 } + }); + fail(); + } + catch (err) { + assertEqual(ERRORS.ERROR_TRANSACTION_UNREGISTERED_COLLECTION.code, err.errorNum); + } + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief uses an implicitly declared collection for writing +//////////////////////////////////////////////////////////////////////////////// + + testUseReadForWriting : function () { + try { + db._executeTransaction({ + collections: { read: cn1 }, + action: "function (params) { var db = require('internal').db; db._collection(params.cn1).truncate(); }", + params: { cn1: cn1 } + }); + fail(); + } + catch (err) { + assertEqual(ERRORS.ERROR_TRANSACTION_UNREGISTERED_COLLECTION.code, err.errorNum); + } + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief uses an implicitly declared collection for writing +//////////////////////////////////////////////////////////////////////////////// + + testUseOtherForWriting : function () { + try { + db._executeTransaction({ + collections: { write: cn2 }, + action: "function (params) { var db = require('internal').db; db._collection(params.cn1).truncate(); }", + params: { cn1: cn1 } + }); + fail(); + } + catch (err) { + assertEqual(ERRORS.ERROR_TRANSACTION_UNREGISTERED_COLLECTION.code, err.errorNum); + } + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief uses an implicitly declared collection for writing +//////////////////////////////////////////////////////////////////////////////// + + testUseOtherForWriteAllowImplicit : function () { + try { + db._executeTransaction({ + collections: { read: cn1, allowImplicit : true }, + action: "function (params) { var db = require('internal').db; db._collection(params.cn2).truncate(); }", + params: { cn2: cn2 } + }); + fail(); + } + catch (err) { + assertEqual(ERRORS.ERROR_TRANSACTION_UNREGISTERED_COLLECTION.code, err.errorNum); + } + } + + }; +} + +// ----------------------------------------------------------------------------- +// --SECTION-- main +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief executes the test suite +//////////////////////////////////////////////////////////////////////////////// + +jsunity.run(TransactionsImplicitCollectionsSuite); + +return jsunity.done(); + +// Local Variables: +// mode: outline-minor +// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)" +// End: diff --git a/js/common/tests/shell-transactions.js b/js/common/tests/shell-transactions.js index 6d7bf031f4..59019c4d32 100644 --- a/js/common/tests/shell-transactions.js +++ b/js/common/tests/shell-transactions.js @@ -301,60 +301,6 @@ function TransactionsImplicitCollectionsSuite () { } }, -//////////////////////////////////////////////////////////////////////////////// -/// @brief uses an implicitly declared collection for writing -//////////////////////////////////////////////////////////////////////////////// - - testUseForWriting : function () { - try { - db._executeTransaction({ - collections: { }, - action: "function (params) { var db = require('internal').db; db._collection(params.cn1).truncate(); }", - params: { cn1: cn1 } - }); - fail(); - } - catch (err) { - assertEqual(ERRORS.ERROR_TRANSACTION_UNREGISTERED_COLLECTION.code, err.errorNum); - } - }, - -//////////////////////////////////////////////////////////////////////////////// -/// @brief uses an implicitly declared collection for writing -//////////////////////////////////////////////////////////////////////////////// - - testUseReadForWriting : function () { - try { - db._executeTransaction({ - collections: { read: cn1 }, - action: "function (params) { var db = require('internal').db; db._collection(params.cn1).truncate(); }", - params: { cn1: cn1 } - }); - fail(); - } - catch (err) { - assertEqual(ERRORS.ERROR_TRANSACTION_UNREGISTERED_COLLECTION.code, err.errorNum); - } - }, - -//////////////////////////////////////////////////////////////////////////////// -/// @brief uses an implicitly declared collection for writing -//////////////////////////////////////////////////////////////////////////////// - - testUseOtherForWriting : function () { - try { - db._executeTransaction({ - collections: { write: cn2 }, - action: "function (params) { var db = require('internal').db; db._collection(params.cn1).truncate(); }", - params: { cn1: cn1 } - }); - fail(); - } - catch (err) { - assertEqual(ERRORS.ERROR_TRANSACTION_UNREGISTERED_COLLECTION.code, err.errorNum); - } - }, - //////////////////////////////////////////////////////////////////////////////// /// @brief uses an explicitly declared collection for reading //////////////////////////////////////////////////////////////////////////////// @@ -455,26 +401,7 @@ function TransactionsImplicitCollectionsSuite () { catch (err) { assertEqual(ERRORS.ERROR_TRANSACTION_UNREGISTERED_COLLECTION.code, err.errorNum); } - }, - -//////////////////////////////////////////////////////////////////////////////// -/// @brief uses an implicitly declared collection for writing -//////////////////////////////////////////////////////////////////////////////// - - testUseOtherForWriteAllowImplicit : function () { - try { - db._executeTransaction({ - collections: { read: cn1, allowImplicit : true }, - action: "function (params) { var db = require('internal').db; db._collection(params.cn2).truncate(); }", - params: { cn2: cn2 } - }); - fail(); - } - catch (err) { - assertEqual(ERRORS.ERROR_TRANSACTION_UNREGISTERED_COLLECTION.code, err.errorNum); - } } - }; }