1
0
Fork 0
arangodb/tests/js/server/aql/aql-optimizer-plans.js

87 lines
2.6 KiB
JavaScript

/*jshint globalstrict:false, strict:false, maxlen: 500 */
/*global assertEqual, AQL_EXECUTE, fail */
////////////////////////////////////////////////////////////////////////////////
/// @brief tests for cost estimation
///
/// @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 internal = require("internal");
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////
function optimizerPlansTestSuite () {
var c;
return {
setUp : function () {
internal.debugClearFailAt();
db._drop("UnitTestsCollection");
c = db._create("UnitTestsCollection");
for (var i = 0; i < 150; ++i) {
c.save({ _key: "test" + i, value: i });
}
},
tearDown : function () {
internal.debugClearFailAt();
db._drop("UnitTestsCollection");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test OOM in createPlans
////////////////////////////////////////////////////////////////////////////////
testCreatePlansOom : function () {
if (! internal.debugCanUseFailAt()) {
return;
}
internal.debugSetFailAt("Optimizer::createPlansOom");
try {
AQL_EXECUTE("FOR i IN 1..10 FILTER i == 1 || i == 2 RETURN i");
fail();
}
catch (err) {
assertEqual(internal.errors.ERROR_DEBUG.code, err.errorNum);
}
}
};
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////
jsunity.run(optimizerPlansTestSuite);
return jsunity.done();