From 9e03189fb03b1fdbbc7dea6b0ba6ff1143f6be24 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Fri, 13 Jun 2014 11:31:14 +0200 Subject: [PATCH] added waitUnload as a test helper function --- js/common/modules/org/arangodb/test-helper.js | 22 +++++++++------ js/common/tests/shell-document.js | 28 ++++--------------- js/common/tests/shell-keygen-noncluster.js | 16 +++-------- 3 files changed, 23 insertions(+), 43 deletions(-) diff --git a/js/common/modules/org/arangodb/test-helper.js b/js/common/modules/org/arangodb/test-helper.js index ba35776256..e65e00b533 100644 --- a/js/common/modules/org/arangodb/test-helper.js +++ b/js/common/modules/org/arangodb/test-helper.js @@ -40,11 +40,6 @@ var processCsvFile = internal.processCsvFile; // --SECTION-- public variables // ----------------------------------------------------------------------------- -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup ArangoShell -/// @{ -//////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// /// @brief array query //////////////////////////////////////////////////////////////////////////////// @@ -56,13 +51,22 @@ exports.Helper = { processor(raw_row.toString().split(",")); } }); + }, + + waitUnload: function (collection) { + var arangodb = require("org/arangodb"); + var internal = require("internal"); + + collection.unload(); + internal.flushWal(); + + while (collection.status() !== arangodb.ArangoCollection.STATUS_UNLOADED) { + collection.unload(); + internal.wait(1); + } } }; -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - // ----------------------------------------------------------------------------- // --SECTION-- END-OF-FILE // ----------------------------------------------------------------------------- diff --git a/js/common/tests/shell-document.js b/js/common/tests/shell-document.js index 8e8a1956c7..0959ad5dd1 100644 --- a/js/common/tests/shell-document.js +++ b/js/common/tests/shell-document.js @@ -32,23 +32,7 @@ var arangodb = require("org/arangodb"); var ERRORS = arangodb.errors; var db = arangodb.db; var wait = require("internal").wait; -var flushWal = require("internal").flushWal; - -// ----------------------------------------------------------------------------- -// --SECTION-- helper functions -// ----------------------------------------------------------------------------- - -function waitUnload (collection) { - collection.unload(); - flushWal(); - - while (collection.status() != arangodb.ArangoCollection.STATUS_UNLOADED) { - collection.unload(); - wait(1); - } - - assertEqual(arangodb.ArangoCollection.STATUS_UNLOADED, collection.status()); -} +var testHelper = require("org/arangodb/test-helper").Helper; // ----------------------------------------------------------------------------- // --SECTION-- collection methods @@ -383,7 +367,7 @@ function CollectionDocumentSuite () { d1 = null; d2 = null; - waitUnload(collection); + testHelper.waitUnload(collection); collection.load(); @@ -416,7 +400,7 @@ function CollectionDocumentSuite () { d1 = null; d2 = null; - waitUnload(collection); + testHelper.waitUnload(collection); collection.load(); @@ -444,7 +428,7 @@ function CollectionDocumentSuite () { assertEqual(0, collection.count()); - waitUnload(collection); + testHelper.waitUnload(collection); collection.load(); @@ -480,7 +464,7 @@ function CollectionDocumentSuite () { assertEqual(1, collection.count()); - waitUnload(collection); + testHelper.waitUnload(collection); collection.load(); @@ -521,7 +505,7 @@ function CollectionDocumentSuite () { assertEqual(0, doc.value); doc = null; - waitUnload(collection); + testHelper.waitUnload(collection); collection.load(); diff --git a/js/common/tests/shell-keygen-noncluster.js b/js/common/tests/shell-keygen-noncluster.js index 3b1f75dcef..84c2f17295 100644 --- a/js/common/tests/shell-keygen-noncluster.js +++ b/js/common/tests/shell-keygen-noncluster.js @@ -30,6 +30,7 @@ var jsunity = require("jsunity"); var wait = require("internal").wait; var console = require("console"); var arangodb = require("org/arangodb"); +var testHelper = require("org/arangodb/test-helper").Helper; var ArangoCollection = arangodb.ArangoCollection; var db = arangodb.db; @@ -282,10 +283,7 @@ function AutoIncrementSuite () { var d4 = c.save({ }); assertEqual("13", d4._key); - c.unload(); - console.log("waiting for collection to unload"); - wait(5); - assertEqual(ArangoCollection.STATUS_UNLOADED, c.status()); + testHelper.waitUnload(c); d1 = c.save({ }); assertEqual("17", d1._key); @@ -319,10 +317,7 @@ function AutoIncrementSuite () { var d4 = c.save({ }); assertEqual("8", d4._key); - c.unload(); - console.log("waiting for collection to unload"); - wait(5); - assertEqual(ArangoCollection.STATUS_UNLOADED, c.status()); + testHelper.waitUnload(c); d1 = c.save({ }); assertEqual("10", d1._key); @@ -338,10 +333,7 @@ function AutoIncrementSuite () { d4 = c.save({ _key: "19567" }); assertEqual("19567", d4._key); - c.unload(); - console.log("waiting for collection to unload"); - wait(5); - assertEqual(ArangoCollection.STATUS_UNLOADED, c.status()); + testHelper.waitUnload(c); d1 = c.save({ }); assertEqual("19568", d1._key);