1
0
Fork 0

cleanup after testrun, lintify

This commit is contained in:
Wilfried Goesgens 2017-09-12 14:48:20 +02:00
parent 5c6997ce04
commit 0a9b9e6025
7 changed files with 1557 additions and 1515 deletions

View File

@ -1,214 +1,215 @@
/*jshint globalstrict:false, strict:false */
/*global assertEqual, assertNotEqual,
print, print_plain, COMPARE_STRING, NORMALIZE_STRING,
help, start_pager, stop_pager, start_pretty_print, stop_pretty_print, start_color_print, stop_color_print */
/* jshint globalstrict:false, strict:false */
/* global assertEqual, assertNotEqual,
print, print_plain, COMPARE_STRING, NORMALIZE_STRING,
help, start_pager, stop_pager, start_pretty_print, stop_pretty_print, start_color_print, stop_color_print */
////////////////////////////////////////////////////////////////////////////////
/// @brief tests for client-specific functionality
///
/// @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
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief tests for client-specific functionality
// /
// / @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 db = require("@arangodb").db;
var jsunity = require('jsunity');
var db = require('@arangodb').db;
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test suite
// //////////////////////////////////////////////////////////////////////////////
function clientTestSuite () {
'use strict';
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief set up
// //////////////////////////////////////////////////////////////////////////////
setUp : function () {
setUp: function () {
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief tear down
// //////////////////////////////////////////////////////////////////////////////
tearDown : function () {
tearDown: function () {
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test global help function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test global help function
// //////////////////////////////////////////////////////////////////////////////
testHelp : function () {
testHelp: function () {
help();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test start_pager function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test start_pager function
// //////////////////////////////////////////////////////////////////////////////
testPagerStart : function () {
testPagerStart: function () {
start_pager();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test stop_pager function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test stop_pager function
// //////////////////////////////////////////////////////////////////////////////
testPagerStop : function () {
testPagerStop: function () {
stop_pager();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test start_pager function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test start_pager function
// //////////////////////////////////////////////////////////////////////////////
testPagerStartStart : function () {
testPagerStartStart: function () {
start_pager();
start_pager();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test stop_pager function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test stop_pager function
// //////////////////////////////////////////////////////////////////////////////
testPagerStopStop : function () {
testPagerStopStop: function () {
stop_pager();
stop_pager();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test start_pretty_print function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test start_pretty_print function
// //////////////////////////////////////////////////////////////////////////////
testPrettyStart : function () {
testPrettyStart: function () {
start_pretty_print();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test stop_pretty_print function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test stop_pretty_print function
// //////////////////////////////////////////////////////////////////////////////
testPrettyStop : function () {
testPrettyStop: function () {
stop_pretty_print();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test start_color_print function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test start_color_print function
// //////////////////////////////////////////////////////////////////////////////
testColorStart : function () {
testColorStart: function () {
start_color_print();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test start_color_print function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test start_color_print function
// //////////////////////////////////////////////////////////////////////////////
testColorStartArg : function () {
testColorStartArg: function () {
start_color_print();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test stop_color_print function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test stop_color_print function
// //////////////////////////////////////////////////////////////////////////////
testColorStop : function () {
testColorStop: function () {
stop_color_print();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test print function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test print function
// //////////////////////////////////////////////////////////////////////////////
testPrint : function () {
testPrint: function () {
print(true);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test print_plain function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test print_plain function
// //////////////////////////////////////////////////////////////////////////////
testPrintPlain : function () {
testPrintPlain: function () {
print_plain(true);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test COMPARE_STRING function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test COMPARE_STRING function
// //////////////////////////////////////////////////////////////////////////////
testICU_Compare : function () {
var nfc = "Gr\u00FC\u00DF Gott.";
var nfd = "Gru\u0308\u00DF Gott.";
testICU_Compare: function () {
var nfc = 'Gr\u00FC\u00DF Gott.';
var nfd = 'Gru\u0308\u00DF Gott.';
assertNotEqual(nfc, nfd);
assertNotEqual(COMPARE_STRING(nfc, nfd), true);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test NORMALIZE_STRING function
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test NORMALIZE_STRING function
// //////////////////////////////////////////////////////////////////////////////
testICU_Normalize : function () {
var nfc = "Gr\u00FC\u00DF Gott.";
var nfd = "Gru\u0308\u00DF Gott.";
testICU_Normalize: function () {
var nfc = 'Gr\u00FC\u00DF Gott.';
var nfd = 'Gru\u0308\u00DF Gott.';
assertNotEqual(nfc, nfd);
assertEqual(NORMALIZE_STRING(nfd), nfc);
assertEqual(NORMALIZE_STRING(nfd), "Grüß Gott.");
assertEqual(NORMALIZE_STRING(nfd), 'Grüß Gott.');
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test skiplist sorting
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test skiplist sorting
// //////////////////////////////////////////////////////////////////////////////
testICU_Compare_Skiplist_Sorting : function () {
db._drop("ICU_SORTED");
db._create("ICU_SORTED");
db.ICU_SORTED.ensureSkiplist("test");
db.ICU_SORTED.save({ test : "äää" });
db.ICU_SORTED.save({ test : "aaa" });
db.ICU_SORTED.save({ test : "aab" });
db.ICU_SORTED.save({ test : "äaa" });
db.ICU_SORTED.save({ test : "äää" });
db.ICU_SORTED.save({ test : "Aaa" });
testICU_Compare_Skiplist_Sorting: function () {
db._drop('ICU_SORTED');
db._create('ICU_SORTED');
db.ICU_SORTED.ensureSkiplist('test');
db.ICU_SORTED.save({ test: 'äää' });
db.ICU_SORTED.save({ test: 'aaa' });
db.ICU_SORTED.save({ test: 'aab' });
db.ICU_SORTED.save({ test: 'äaa' });
db.ICU_SORTED.save({ test: 'äää' });
db.ICU_SORTED.save({ test: 'Aaa' });
var y = db.ICU_SORTED.range("test", "A", "z") ;
var y = db.ICU_SORTED.range('test', 'A', 'z');
assertEqual(y.next().test, "Aaa");
assertEqual(y.next().test, "aaa");
assertEqual(y.next().test, "äaa");
assertEqual(y.next().test, "äää");
assertEqual(y.next().test, "äää");
assertEqual(y.next().test, "aab");
assertEqual(y.next().test, 'Aaa');
assertEqual(y.next().test, 'aaa');
assertEqual(y.next().test, 'äaa');
assertEqual(y.next().test, 'äää');
assertEqual(y.next().test, 'äää');
assertEqual(y.next().test, 'aab');
db._drop('ICU_SORTED');
}
};
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief executes the test suite
// //////////////////////////////////////////////////////////////////////////////
jsunity.run(clientTestSuite);

View File

@ -1,4 +1,4 @@
/* global describe, it, beforeEach, afterEach, before, after*/
/* global describe, it, beforeEach, afterEach */
'use strict';
const FoxxManager = require('@arangodb/foxx/manager');
@ -42,6 +42,12 @@ describe('Foxx Manager', function () {
db._drop(setupTeardownCol);
} catch (e) {
}
try {
// some tests create these:
db._drop('testmount_setup');
} catch (e) {
}
});
it('should contains in _apps', function () {
@ -95,6 +101,16 @@ describe('Foxx Manager', function () {
db._drop(setupTeardownCol);
} catch (e) {
}
try {
// some tests create these:
db._drop('testmount_setup');
} catch (e) {
}
try {
// some tests create these:
db._drop('testmount_setup');
} catch (e) {
}
});
it('should not contains in _apps', function () {
@ -146,6 +162,11 @@ describe('Foxx Manager', function () {
db._drop(setupTeardownCol);
} catch (e) {
}
try {
// some tests create these:
db._drop('testmount_setup');
} catch (e) {
}
});
it('should update it checksum in _apps', function () {
@ -189,6 +210,11 @@ describe('Foxx Manager', function () {
FoxxManager.uninstall(mount, {force: false});
} catch (e) {
}
try {
// some tests create these:
db._drop('testmount_setup');
} catch (e) {
}
});
it('should not contains in _apps', function () {
@ -271,6 +297,11 @@ describe('Foxx Manager', function () {
FoxxManager.uninstall(mount, {force: false});
} catch (e) {
}
try {
// some tests create these:
db._drop('testmount_setup');
} catch (e) {
}
});
it('should contains in _apps', function () {

View File

@ -1,82 +1,81 @@
/*jshint globalstrict:false, strict:false */
/*global assertEqual, assertTrue, assertFalse, assertNotNull */
/* jshint globalstrict:false, strict:false */
/* global assertEqual, assertTrue, assertFalse, assertNotNull */
////////////////////////////////////////////////////////////////////////////////
/// @brief test the document interface
///
/// @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 Dr. Frank Celler
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test the document interface
// /
// / @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 Dr. Frank Celler
// / @author Copyright 2012, triAGENS GmbH, Cologne, Germany
// //////////////////////////////////////////////////////////////////////////////
var jsunity = require("jsunity");
var arangodb = require("@arangodb");
var jsunity = require('jsunity');
var arangodb = require('@arangodb');
var db = arangodb.db;
var internal = require("internal");
var internal = require('internal');
var wait = internal.wait;
var print = internal.print;
var ArangoCollection = arangodb.ArangoCollection;
var mmfilesEngine = false;
if (db._engine().name === "mmfiles") {
if (db._engine().name === 'mmfiles') {
mmfilesEngine = true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite: buckets
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test suite: buckets
// //////////////////////////////////////////////////////////////////////////////
function EdgeIndexBucketsSuite () {
var vn = "UnitTestsCollectionVertex";
var vn = 'UnitTestsCollectionVertex';
var vertex = null;
var en1 = "UnitTestsCollectionEdge1";
var en1 = 'UnitTestsCollectionEdge1';
var edge1 = null;
var en2 = "UnitTestsCollectionEdge2";
var en2 = 'UnitTestsCollectionEdge2';
var edge2 = null;
var en3 = "UnitTestsCollectionEdge3";
var en3 = 'UnitTestsCollectionEdge3';
var edge3 = null;
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief set up
// //////////////////////////////////////////////////////////////////////////////
setUp : function () {
setUp: function () {
db._drop(en1);
db._drop(en2);
db._drop(en3);
var options = {};
if (mmfilesEngine){
if (mmfilesEngine) {
options = { indexBuckets: 1 };
}
edge1 = db._createEdgeCollection(en1, options);
if (mmfilesEngine){
if (mmfilesEngine) {
options = { indexBuckets: 16 };
}
edge2 = db._createEdgeCollection(en2, options);
if (mmfilesEngine){
if (mmfilesEngine) {
options = { indexBuckets: 128 };
}
edge3 = db._createEdgeCollection(en3, options);
@ -85,31 +84,34 @@ function EdgeIndexBucketsSuite () {
vertex = db._create(vn);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief tear down
// //////////////////////////////////////////////////////////////////////////////
tearDown : function () {
tearDown: function () {
edge1.drop();
edge2.drop();
edge3.drop();
edge1 = null;
edge2 = null;
edge3 = null;
vertex.drop();
wait(0.0);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief compare results with different buckets
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief compare results with different buckets
// //////////////////////////////////////////////////////////////////////////////
testSaveEdgeBuckets : function () {
var i, j, n = 50;
testSaveEdgeBuckets: function () {
var i;
var j;
var n = 50;
for (i = 0; i < n; ++i) {
for (j = 0; j < n; ++j) {
edge1.save(vn + "/v" + i, vn + "/v" + j, { });
edge2.save(vn + "/v" + i, vn + "/v" + j, { });
edge3.save(vn + "/v" + i, vn + "/v" + j, { });
edge1.save(vn + '/v' + i, vn + '/v' + j, { });
edge2.save(vn + '/v' + i, vn + '/v' + j, { });
edge3.save(vn + '/v' + i, vn + '/v' + j, { });
}
}
@ -133,32 +135,34 @@ function EdgeIndexBucketsSuite () {
edge3 = db._collection(en3);
for (i = 0; i < n; ++i) {
assertEqual(n, edge1.outEdges(vn + "/v" + i).length);
assertEqual(n, edge2.outEdges(vn + "/v" + i).length);
assertEqual(n, edge3.outEdges(vn + "/v" + i).length);
assertEqual(n, edge1.outEdges(vn + '/v' + i).length);
assertEqual(n, edge2.outEdges(vn + '/v' + i).length);
assertEqual(n, edge3.outEdges(vn + '/v' + i).length);
assertEqual(n, edge1.inEdges(vn + "/v" + i).length);
assertEqual(n, edge2.inEdges(vn + "/v" + i).length);
assertEqual(n, edge3.inEdges(vn + "/v" + i).length);
assertEqual(n, edge1.inEdges(vn + '/v' + i).length);
assertEqual(n, edge2.inEdges(vn + '/v' + i).length);
assertEqual(n, edge3.inEdges(vn + '/v' + i).length);
assertEqual((n * 2) - 1, edge1.edges(vn + "/v" + i).length);
assertEqual((n * 2) - 1, edge2.edges(vn + "/v" + i).length);
assertEqual((n * 2) - 1, edge3.edges(vn + "/v" + i).length);
}
assertEqual((n * 2) - 1, edge1.edges(vn + '/v' + i).length);
assertEqual((n * 2) - 1, edge2.edges(vn + '/v' + i).length);
assertEqual((n * 2) - 1, edge3.edges(vn + '/v' + i).length);
}
},
////////////////////////////////////////////////////////////////////////////////
/// @brief compare results with different buckets
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief compare results with different buckets
// //////////////////////////////////////////////////////////////////////////////
testRemoveEdgeBuckets : function () {
var i, j, n = 40;
testRemoveEdgeBuckets: function () {
var i;
var j;
var n = 40;
for (i = 0; i < n; ++i) {
for (j = 0; j < n; ++j) {
edge1.save(vn + "/v" + i, vn + "/v" + j, { _key: i + "-" + j });
edge2.save(vn + "/v" + i, vn + "/v" + j, { _key: i + "-" + j });
edge3.save(vn + "/v" + i, vn + "/v" + j, { _key: i + "-" + j });
}
edge1.save(vn + '/v' + i, vn + '/v' + j, { _key: i + '-' + j });
edge2.save(vn + '/v' + i, vn + '/v' + j, { _key: i + '-' + j });
edge3.save(vn + '/v' + i, vn + '/v' + j, { _key: i + '-' + j });
}
}
// remove a few random documents
@ -188,7 +192,7 @@ function EdgeIndexBucketsSuite () {
edge2 = db._collection(en2);
edge3 = db._collection(en3);
edge1.toArray().forEach(function(doc) {
edge1.toArray().forEach(function (doc) {
var from = doc._from;
var to = doc._to;
var ref;
@ -214,12 +218,11 @@ function EdgeIndexBucketsSuite () {
};
}
function EdgeIndexSuite () {
var vn = "UnitTestsCollectionVertex";
var vn = 'UnitTestsCollectionVertex';
var vertex = null;
var en = "UnitTestsCollectionEdge";
var en = 'UnitTestsCollectionEdge';
var edge = null;
var v1 = null;
@ -227,26 +230,26 @@ function EdgeIndexSuite () {
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief set up
// //////////////////////////////////////////////////////////////////////////////
setUp : function () {
setUp: function () {
db._drop(en);
edge = db._createEdgeCollection(en);
db._drop(vn);
vertex = db._create(vn);
v1 = vertex.save({ a : 1 });
v2 = vertex.save({ a : 2 });
v1 = vertex.save({ a: 1 });
v2 = vertex.save({ a: 2 });
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief tear down
// //////////////////////////////////////////////////////////////////////////////
tearDown : function () {
tearDown: function () {
edge.drop();
vertex.drop();
edge = null;
@ -254,77 +257,84 @@ function EdgeIndexSuite () {
wait(0.0);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test batch size limit
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test batch size limit
// //////////////////////////////////////////////////////////////////////////////
testIndexBatchsizeLimit : function () {
[20, 900, 1000, 1100, 2000].forEach( function(n){
testIndexBatchsizeLimit: function () {
[20, 900, 1000, 1100, 2000].forEach(function (n) {
var toKeys = [];
for (var i = 0; i < n; ++i) {
var to = "b" + n + "/"+i;
edge.insert({_from : "a/" + n, _to : to});
toKeys.push(to);
var to = 'b' + n + '/' + i;
edge.insert({
_from: 'a/' + n,
_to: to
});
toKeys.push(to);
}
assertEqual(n,edge.byExample({ _from : "a/" + n }).toArray().length, "compare 1");
assertEqual(n,edge.byExample({ _from : "a/" + n }).toArray().length, "compare 2");
var rv = edge.byExample({ _from : "a/" + n }).toArray();
assertEqual(n,rv.length, "compare 3");
assertEqual(n, edge.byExample({
_from: 'a/' + n
}).toArray().length, 'compare 1');
//assert equal values
if(n <= 1001){
var keys = rv.map(function(x){ return x._to; });
keys.sort();
toKeys.sort();
keys.forEach(function(x,i){
assertEqual(x,toKeys[i], "compare exact values");
});
assertEqual(n, edge.byExample({
_from: 'a/' + n
}).toArray().length, 'compare 2');
var rv = edge.byExample({ _from: 'a/' + n }).toArray();
assertEqual(n, rv.length, 'compare 3');
// assert equal values
if (n <= 1001) {
var keys = rv.map(function (x) { return x._to; });
keys.sort();
toKeys.sort();
keys.forEach(function (x, i) {
assertEqual(x, toKeys[i], 'compare exact values');
});
}
});
},
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index presence
// //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief test index presence
////////////////////////////////////////////////////////////////////////////////
testIndexPresence : function () {
testIndexPresence: function () {
var indexes = edge.getIndexes();
assertEqual(2, indexes.length);
assertEqual("edge", indexes[1].type);
assertEqual([ "_from", "_to" ], indexes[1].fields);
assertEqual('edge', indexes[1].type);
assertEqual([ '_from', '_to' ], indexes[1].fields);
assertFalse(indexes[1].unique);
assertFalse(indexes[1].sparse);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test index selectivity
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index selectivity
// //////////////////////////////////////////////////////////////////////////////
testIndexSelectivityEmpty : function () {
testIndexSelectivityEmpty: function () {
var edgeIndex = edge.getIndexes()[1];
assertTrue(edgeIndex.hasOwnProperty("selectivityEstimate"));
assertTrue(edgeIndex.hasOwnProperty('selectivityEstimate'));
assertEqual(1, edgeIndex.selectivityEstimate);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test index selectivity
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index selectivity
// //////////////////////////////////////////////////////////////////////////////
testIndexSelectivityOneDoc : function () {
testIndexSelectivityOneDoc: function () {
edge.save(v1, v2, { });
var edgeIndex = edge.getIndexes()[1];
assertTrue(edgeIndex.hasOwnProperty("selectivityEstimate"));
assertTrue(edgeIndex.hasOwnProperty('selectivityEstimate'));
assertEqual(1, edgeIndex.selectivityEstimate);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test index selectivity
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index selectivity
// //////////////////////////////////////////////////////////////////////////////
testIndexSelectivityDuplicateDocs : function () {
testIndexSelectivityDuplicateDocs: function () {
var i, c, edgeIndex, expectedSelectivity;
for (i = 0; i < 1000; ++i) {
@ -348,57 +358,54 @@ function EdgeIndexSuite () {
expectedSelectivity = (c === 0 ? 1 : 1 / c);
// allow for some floating-point deviations
assertTrue(Math.abs(expectedSelectivity - edgeIndex.selectivityEstimate) <= 0.001);
}
}
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test index selectivity
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index selectivity
// //////////////////////////////////////////////////////////////////////////////
testIndexSelectivityUniqueDocs : function () {
testIndexSelectivityUniqueDocs: function () {
for (var i = 0; i < 1000; ++i) {
edge.save(vn + "/from" + i, vn + "/to" + i, { });
edge.save(vn + '/from' + i, vn + '/to' + i, { });
var edgeIndex = edge.getIndexes()[1];
assertTrue(1, edgeIndex.selectivityEstimate);
}
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test index selectivity
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index selectivity
// //////////////////////////////////////////////////////////////////////////////
testIndexSelectivityUniqueDocsFrom : function () {
testIndexSelectivityUniqueDocsFrom: function () {
for (var i = 0; i < 1000; ++i) {
edge.save(vn + "/from" + i, vn + "/1", { });
edge.save(vn + '/from' + i, vn + '/1', { });
var edgeIndex = edge.getIndexes()[1];
var expectedSelectivity = (1 + (1 / (i + 1))) * 0.5;
assertTrue(Math.abs(expectedSelectivity - edgeIndex.selectivityEstimate) <= 0.001);
}
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test index selectivity
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index selectivity
// //////////////////////////////////////////////////////////////////////////////
testIndexSelectivityRepeatingDocs : function () {
testIndexSelectivityRepeatingDocs: function () {
for (var i = 0; i < 1000; ++i) {
if (i > 0) {
var edgeIndex = edge.getIndexes()[1];
var expectedSelectivity = (1 + (Math.min(i, 20) / i)) * 0.5;
assertTrue(Math.abs(expectedSelectivity - edgeIndex.selectivityEstimate) <= 0.001);
}
edge.save(vn + "/from" + (i % 20), vn + "/to" + i, { });
edge.save(vn + '/from' + (i % 20), vn + '/to' + i, { });
}
}
};
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief executes the test suite
// //////////////////////////////////////////////////////////////////////////////
jsunity.run(EdgeIndexSuite);
jsunity.run(EdgeIndexBucketsSuite);

View File

@ -1,55 +1,54 @@
/*jshint globalstrict:false, strict:false */
/*global assertEqual, assertTrue, assertEqual, assertNotEqual, fail */
/* jshint globalstrict:false, strict:false */
/* global assertEqual, assertTrue, assertEqual, assertNotEqual, fail */
////////////////////////////////////////////////////////////////////////////////
/// @brief test the collection interface
///
/// @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 Dr. Frank Celler
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test the collection interface
// /
// / @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 Dr. Frank Celler
// / @author Copyright 2012, triAGENS GmbH, Cologne, Germany
// //////////////////////////////////////////////////////////////////////////////
var jsunity = require("jsunity");
var jsunity = require('jsunity');
var arangodb = require("@arangodb");
var internal = require("internal");
var arangodb = require('@arangodb');
var internal = require('internal');
var db = arangodb.db;
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite: FiguresSuite
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test suite: FiguresSuite
// //////////////////////////////////////////////////////////////////////////////
function FiguresSuite () {
'use strict';
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief figures
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief figures
// //////////////////////////////////////////////////////////////////////////////
testFigures : function () {
var collection = "example";
testFigures: function () {
var collection = 'testFigures';
db._drop(collection);
var c1 = db._create(collection);
@ -65,7 +64,7 @@ function FiguresSuite () {
assertEqual(0, f.dead.size);
assertEqual(0, f.dead.deletion);
var d1 = c1.save({ hello : 1 });
var d1 = c1.save({ hello: 1 });
internal.wal.flush(true, true);
@ -89,7 +88,7 @@ function FiguresSuite () {
assertEqual(0, f.dead.size);
assertEqual(0, f.dead.deletion);
var d2 = c1.save({ hello : 2 });
var d2 = c1.save({ hello: 2 });
internal.wal.flush(true, true);
tries = 0;
@ -159,12 +158,12 @@ function FiguresSuite () {
db._drop(collection);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief check figures
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief check figures
// //////////////////////////////////////////////////////////////////////////////
testFiguresAfterOperations : function () {
var cnName = "example";
testFiguresAfterOperations: function () {
var cnName = 'FiguresAfterOperations';
db._drop(cnName);
var collection = db._create(cnName);
@ -172,9 +171,9 @@ function FiguresSuite () {
collection.load();
var figures;
collection.save({ _key : "a1" });
collection.save({ _key : "a2" });
collection.save({ _key : "a3" });
collection.save({ _key: 'a1' });
collection.save({ _key: 'a2' });
collection.save({ _key: 'a3' });
internal.wal.flush(true, true);
var tries = 0;
@ -191,17 +190,15 @@ function FiguresSuite () {
// insert a few duplicates
try {
collection.save({ _key : "a1" });
collection.save({ _key: 'a1' });
fail();
} catch (e1) {
}
catch (e1) {
}
try {
collection.save({ _key : "a2" });
collection.save({ _key: 'a2' });
fail();
}
catch (e2) {
} catch (e2) {
}
// we should see the same figures
@ -212,8 +209,8 @@ function FiguresSuite () {
assertEqual(0, figures.dead.count);
// now remove some documents
collection.remove("a2");
collection.remove("a3");
collection.remove('a2');
collection.remove('a3');
// we should see two live docs less
internal.wal.flush(true, true);
@ -230,7 +227,7 @@ function FiguresSuite () {
assertEqual(2, figures.dead.count);
// replacing one document does not change alive, but increases dead!
collection.replace("a1", { });
collection.replace('a1', { });
internal.wal.flush(true, true);
tries = 0;
@ -247,10 +244,9 @@ function FiguresSuite () {
// this doc does not exist. should not change the figures
try {
collection.replace("a2", { });
collection.replace('a2', { });
fail();
}
catch (e3) {
} catch (e3) {
}
internal.wal.flush(true, true);
@ -258,17 +254,16 @@ function FiguresSuite () {
assertEqual(1, figures.alive.count);
assertEqual(3, figures.dead.count);
collection.unload();
collection.drop();
}
};
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suites
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief executes the test suites
// //////////////////////////////////////////////////////////////////////////////
jsunity.run(FiguresSuite);
return jsunity.done();

File diff suppressed because it is too large Load Diff

View File

@ -1,125 +1,124 @@
/*jshint globalstrict:false, strict:false, maxlen: 500 */
/*global assertEqual, AQL_EXECUTE */
/* jshint globalstrict:false, strict:false, maxlen: 500 */
/* global assertEqual, AQL_EXECUTE */
////////////////////////////////////////////////////////////////////////////////
/// @brief tests for index usage
///
/// @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
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief tests for index usage
// /
// / @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 db = require("@arangodb").db;
var jsunity = require('jsunity');
var db = require('@arangodb').db;
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test suite
// //////////////////////////////////////////////////////////////////////////////
function optimizerEdgeIndexTestSuite () {
var c;
var e;
return {
setUp : function () {
db._drop("UnitTestsCollection");
db._drop("UnitTestsEdgeCollection");
c = db._create("UnitTestsCollection");
e = db._createEdgeCollection("UnitTestsEdgeCollection");
setUp: function () {
db._drop('UnitTestsCollection');
db._drop('UnitTestsEdgeCollection');
db._create('UnitTestsCollection');
e = db._createEdgeCollection('UnitTestsEdgeCollection');
for (var i = 0; i < 2000; i += 100) {
var j;
for (j = 0; j < i; ++j) {
e.save("UnitTestsCollection/from" + i, "UnitTestsCollection/nono", { value: i + "-" + j });
e.save('UnitTestsCollection/from' + i, 'UnitTestsCollection/nono', { value: i + '-' + j });
}
for (j = 0; j < i; ++j) {
e.save("UnitTestsCollection/nono", "UnitTestsCollection/to" + i, { value: i + "-" + j });
e.save('UnitTestsCollection/nono', 'UnitTestsCollection/to' + i, { value: i + '-' + j });
}
}
},
tearDown : function () {
db._drop("UnitTestsCollection");
tearDown: function () {
db._drop('UnitTestsCollection');
db._drop('UnitTestsEdgeCollection');
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test continuous index scan
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test continuous index scan
// //////////////////////////////////////////////////////////////////////////////
testFindContinuous : function () {
testFindContinuous: function () {
for (var i = 0; i < 20; ++i) {
var query = "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/nono' && i._to == 'UnitTestsCollection/to" + i + "' LIMIT 1 RETURN i._key";
var query = 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/nono" && i._to == "UnitTestsCollection/to' + i + '" LIMIT 1 RETURN i._key';
var results = AQL_EXECUTE(query);
assertEqual(0, results.json.length, query);
}
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test index usage
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index usage
// //////////////////////////////////////////////////////////////////////////////
testFindNone : function () {
testFindNone: function () {
var queries = [
"FOR i IN " + e.name() + " FILTER i._from == '' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from0' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from2' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._from == '/' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._from == '--foobar--' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._to == '' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/from0' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/from1' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/from2' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._to == '/' RETURN i._key",
"FOR i IN " + e.name() + " FILTER i._to == '--foobar--' RETURN i._key"
'FOR i IN ' + e.name() + ' FILTER i._from == "" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from0" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from2" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._from == "/" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._from == "--foobar--" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._to == "" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/from0" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/from1" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/from2" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._to == "/" RETURN i._key',
'FOR i IN ' + e.name() + ' FILTER i._to == "--foobar--" RETURN i._key'
];
queries.forEach(function(query) {
queries.forEach(function (query) {
var results = AQL_EXECUTE(query);
assertEqual([ ], results.json, query);
assertEqual(0, results.stats.scannedFull);
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test index usage
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index usage
// //////////////////////////////////////////////////////////////////////////////
testFindFrom : function () {
testFindFrom: function () {
var queries = [
[ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from100' RETURN i._key", 100 ],
[ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from200' RETURN i._key", 200 ],
[ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1000' RETURN i._key", 1000 ],
[ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1100' RETURN i._key", 1100 ],
[ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1900' RETURN i._key", 1900 ]
[ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from100" RETURN i._key', 100 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from200" RETURN i._key', 200 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1000" RETURN i._key', 1000 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1100" RETURN i._key', 1100 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1900" RETURN i._key', 1900 ]
];
queries.forEach(function(query) {
queries.forEach(function (query) {
var results = AQL_EXECUTE(query[0]);
assertEqual(query[1], results.json.length, query[0]);
assertEqual(0, results.stats.scannedFull);
@ -127,20 +126,20 @@ function optimizerEdgeIndexTestSuite () {
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test index usage
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index usage
// //////////////////////////////////////////////////////////////////////////////
testFindTo : function () {
testFindTo: function () {
var queries = [
[ "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/to100' RETURN i._key", 100 ],
[ "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/to200' RETURN i._key", 200 ],
[ "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/to1000' RETURN i._key", 1000 ],
[ "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/to1100' RETURN i._key", 1100 ],
[ "FOR i IN " + e.name() + " FILTER i._to == 'UnitTestsCollection/to1900' RETURN i._key", 1900 ]
[ 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/to100" RETURN i._key', 100 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/to200" RETURN i._key', 200 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/to1000" RETURN i._key', 1000 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/to1100" RETURN i._key', 1100 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._to == "UnitTestsCollection/to1900" RETURN i._key', 1900 ]
];
queries.forEach(function(query) {
queries.forEach(function (query) {
var results = AQL_EXECUTE(query[0]);
assertEqual(query[1], results.json.length, query[0]);
assertEqual(0, results.stats.scannedFull);
@ -148,20 +147,20 @@ function optimizerEdgeIndexTestSuite () {
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test index usage
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test index usage
// //////////////////////////////////////////////////////////////////////////////
testFindFromTo : function () {
testFindFromTo: function () {
var queries = [
[ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from100' && i._to == 'UnitTestsCollection/nono' RETURN i._key", 100 ],
[ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from200' && i._to == 'UnitTestsCollection/nono' RETURN i._key", 200 ],
[ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1000' && i._to == 'UnitTestsCollection/nono' RETURN i._key", 1000 ],
[ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1100' && i._to == 'UnitTestsCollection/nono' RETURN i._key", 1100 ],
[ "FOR i IN " + e.name() + " FILTER i._from == 'UnitTestsCollection/from1900' && i._to == 'UnitTestsCollection/nono' RETURN i._key", 1900 ]
[ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from100" && i._to == "UnitTestsCollection/nono" RETURN i._key', 100 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from200" && i._to == "UnitTestsCollection/nono" RETURN i._key', 200 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1000" && i._to == "UnitTestsCollection/nono" RETURN i._key', 1000 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1100" && i._to == "UnitTestsCollection/nono" RETURN i._key', 1100 ],
[ 'FOR i IN ' + e.name() + ' FILTER i._from == "UnitTestsCollection/from1900" && i._to == "UnitTestsCollection/nono" RETURN i._key', 1900 ]
];
queries.forEach(function(query) {
queries.forEach(function (query) {
var results = AQL_EXECUTE(query[0]);
assertEqual(query[1], results.json.length, query[0]);
assertEqual(0, results.stats.scannedFull);

View File

@ -1,31 +1,31 @@
/*jshint globalstrict:false, strict:false */
/* jshint globalstrict:false, strict:false */
////////////////////////////////////////////////////////////////////////////////
/// @brief tests for Foxx console
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2015 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 Alan Plum
/// @author Copyright 2015, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief tests for Foxx console
// /
// / @file
// /
// / DISCLAIMER
// /
// / Copyright 2015 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 Alan Plum
// / @author Copyright 2015, triAGENS GmbH, Cologne, Germany
// //////////////////////////////////////////////////////////////////////////////
var jsunity = require('jsunity');
var expect = require('chai').expect;
@ -37,21 +37,22 @@ var internal = require('internal');
var AssertionError = require('assert').AssertionError;
var mountPath = '##TEST##';
var foxxlogCol = '_foxxlog';
function clear () {
'use strict';
if (!db._foxxlog) {
return [];
}
return db._query(
qb.for('entry').in('_foxxlog')
qb.for('entry').in(foxxlogCol)
.filter(qb.eq('entry.mount', qb.str(mountPath)))
.remove('entry').in('_foxxlog')
.remove('entry').in(foxxlogCol)
).toArray();
}
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief test suite
// //////////////////////////////////////////////////////////////////////////////
function ConsoleTestSuite () {
'use strict';
@ -59,26 +60,26 @@ function ConsoleTestSuite () {
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief set up
// //////////////////////////////////////////////////////////////////////////////
setUp: function () {
console = new Console(mountPath);
clear();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief tear down
// //////////////////////////////////////////////////////////////////////////////
tearDown: function () {
clear();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tests
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief tests
// //////////////////////////////////////////////////////////////////////////////
testConsoleLogLogsMessage: function () {
clear();
@ -135,7 +136,11 @@ function ConsoleTestSuite () {
testConsoleDirUsesInspect: function () {
const args = [
'lol',
{_PRINT: function (ctx) {ctx.output += 'hello';}}
{
_PRINT: function (ctx) {
ctx.output += 'hello';
}
}
];
args.forEach(function (arg) {
clear();
@ -279,11 +284,20 @@ function ConsoleTestSuite () {
};
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
// / @brief executes the test suite
// //////////////////////////////////////////////////////////////////////////////
jsunity.run(ConsoleTestSuite);
return jsunity.done();
let rc = jsunity.done();
db._useDatabase('_system');
try {
db._drop(foxxlogCol, {
isSystem: true
});
} catch (x) {
}
return rc;