1
0
Fork 0

Reorganise unit tests.

In JS framework we now find the available test files by directory
listing. This means one can simply drop a file in the right
directory to add a test.

We use a naming convention for filenames which is explained
in the README files in the corresponding directories.

Old unit tests do not yet use this but do use the new names and
should still work as usual.
This commit is contained in:
Max Neunhoeffer 2014-02-21 11:24:31 +01:00
parent 019bb7716f
commit 3cb1784430
24 changed files with 153 additions and 142 deletions

View File

@ -0,0 +1,12 @@
Conventions for testing framework:
==================================
All files in this directory whose name starts with "api-"
and ends with ".js" automatically take part in http
or https server tests, with the exception of
"api-replication-spec.js".
If the filename contains the string "-cluster-", then it is
only executed when testing in cluster mode. If the filename
contains the string "-noncluster-", then it is only executed
when testing in single instance mode.

View File

@ -386,10 +386,10 @@ SHELL_COMMON = \
################################################################################
SHELL_SERVER_ONLY = \
@top_srcdir@/js/server/tests/cluster.js \
@top_srcdir@/js/server/tests/compaction.js \
@top_srcdir@/js/server/tests/transactions.js \
@top_srcdir@/js/server/tests/routing.js \
@top_srcdir@/js/server/tests/shell-sharding-helpers.js \
@top_srcdir@/js/server/tests/shell-compaction.js \
@top_srcdir@/js/server/tests/shell-transactions.js \
@top_srcdir@/js/server/tests/shell-routing.js \
@top_srcdir@/js/server/tests/shell-any.js \
@top_srcdir@/js/server/tests/shell-bitarray-index.js \
@top_srcdir@/js/server/tests/shell-database.js \
@ -485,15 +485,15 @@ SHELL_SERVER_AHUACATL = @top_srcdir@/js/server/tests/ahuacatl-ranges.js \
@top_srcdir@/js/server/tests/ahuacatl-operators.js
SHELL_SERVER_AHUACATL_EXTENDED = \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-1.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-2.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-3.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-4.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-5.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-6.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-7.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-8.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-9.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-01.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-02.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-03.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-04.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-05.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-06.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-07.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-08.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-09.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-10.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-11.js \
@top_srcdir@/js/server/tests/ahuacatl-ranges-combined-12.js \
@ -530,7 +530,7 @@ unittests-shell-server-ahuacatl:
SHELL_CLIENT_ONLY = \
@top_srcdir@/js/client/tests/shell-endpoints.js \
@top_srcdir@/js/client/tests/shell-fm.js \
@top_srcdir@/js/client/tests/client.js
@top_srcdir@/js/client/tests/shell-client.js
SHELL_CLIENT = $(SHELL_COMMON) $(SHELL_CLIENT_ONLY)
@ -661,7 +661,7 @@ unittests-replication-server:
@rm -rf "$(VOCDIR)"
@mkdir -p "$(VOCDIR)/databases"
$(VALGRIND) @builddir@/bin/arangod "$(VOCDIR)" $(SERVER_OPT) --server.endpoint tcp://$(VOCHOST):$(VOCPORT) --javascript.unit-tests @top_srcdir@/js/common/tests/shell-replication.js || test "x$(FORCE)" == "x1"
$(VALGRIND) @builddir@/bin/arangod "$(VOCDIR)" $(SERVER_OPT) --server.endpoint tcp://$(VOCHOST):$(VOCPORT) --javascript.unit-tests @top_srcdir@/js/common/tests/replication.js || test "x$(FORCE)" == "x1"
@rm -rf "$(VOCDIR)"
@echo
@ -675,7 +675,7 @@ unittests-replication-client:
@echo "================================================================================"
@echo
$(VALGRIND) @builddir@/bin/arangosh $(CLIENT_OPT) --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint tcp://$(VOCHOST):$(VOCPORT) --javascript.unit-tests @top_srcdir@/js/common/tests/shell-replication.js || test "x$(FORCE)" == "x1"
$(VALGRIND) @builddir@/bin/arangosh $(CLIENT_OPT) --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint tcp://$(VOCHOST):$(VOCPORT) --javascript.unit-tests @top_srcdir@/js/common/tests/replication.js || test "x$(FORCE)" == "x1"
sleep 2
kill `cat $(PIDFILE)`
@ -892,7 +892,7 @@ unittests-authentication:
@echo "================================================================================"
@echo
$(VALGRIND) @builddir@/bin/arangosh $(CLIENT_OPT) --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint tcp://$(VOCHOST):$(VOCPORT) --javascript.unit-tests @top_srcdir@/js/client/tests/shell-auth.js || test "x$(FORCE)" == "x1"
$(VALGRIND) @builddir@/bin/arangosh $(CLIENT_OPT) --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint tcp://$(VOCHOST):$(VOCPORT) --javascript.unit-tests @top_srcdir@/js/client/tests/auth.js || test "x$(FORCE)" == "x1"
sleep 2
kill `cat $(PIDFILE)`

11
js/client/tests/README Normal file
View File

@ -0,0 +1,11 @@
Conventions for testing framework:
==================================
All files in this directory whose name starts with "shell-"
and ends with ".js" automatically take part in client
shell tests (target "shell_client").
If the filename contains the string "-cluster-", then it is
only executed when testing in cluster mode. If the filename
contains the string "-noncluster-", then it is only executed
when testing in single instance mode.

12
js/common/tests/README Normal file
View File

@ -0,0 +1,12 @@
Conventions for testing framework:
==================================
All files in this directory whose name starts with "shell-"
and ends with ".js" automatically take part in client and
server shell tests (targets "shell_client" and "shell_server"
and "shell_server_only").
If the filename contains the string "-cluster-", then it is
only executed when testing in cluster mode. If the filename
contains the string "-noncluster-", then it is only executed
when testing in single instance mode.

View File

@ -243,123 +243,68 @@ function makePath (path) {
return fs.join.apply(null,path.split("/"));
}
var tests_shell_common =
[ makePath("js/common/tests/shell-require.js"),
makePath("js/common/tests/shell-aqlfunctions.js"),
makePath("js/common/tests/shell-attributes.js"),
makePath("js/common/tests/shell-base64.js"),
makePath("js/common/tests/shell-collection.js"),
makePath("js/common/tests/shell-collection-volatile.js"),
makePath("js/common/tests/shell-crypto.js"),
makePath("js/common/tests/shell-database.js"),
makePath("js/common/tests/shell-document.js"),
makePath("js/common/tests/shell-download.js"),
makePath("js/common/tests/shell-edge.js"),
makePath("js/common/tests/shell-fs.js"),
makePath("js/common/tests/shell-graph-traversal.js"),
makePath("js/common/tests/shell-graph-algorithms.js"),
makePath("js/common/tests/shell-graph-measurement.js"),
makePath("js/common/tests/shell-keygen.js"),
makePath("js/common/tests/shell-simple-query.js"),
makePath("js/common/tests/shell-statement.js"),
makePath("js/common/tests/shell-transactions.js"),
makePath("js/common/tests/shell-unload.js"),
makePath("js/common/tests/shell-users.js"),
makePath("js/common/tests/shell-index.js"),
makePath("js/common/tests/shell-index-geo.js"),
makePath("js/common/tests/shell-cap-constraint.js"),
makePath("js/common/tests/shell-unique-constraint.js"),
makePath("js/common/tests/shell-hash-index.js"),
makePath("js/common/tests/shell-fulltext.js"),
makePath("js/common/tests/shell-graph.js")
];
var foundTests = false;
var tests_shell_server_only =
[
makePath("js/server/tests/cluster.js"),
makePath("js/server/tests/compaction.js"),
makePath("js/server/tests/transactions.js"),
makePath("js/server/tests/routing.js"),
makePath("js/server/tests/shell-any.js"),
makePath("js/server/tests/shell-bitarray-index.js"),
makePath("js/server/tests/shell-database.js"),
makePath("js/server/tests/shell-foxx.js"),
makePath("js/server/tests/shell-foxx-repository.js"),
makePath("js/server/tests/shell-foxx-model.js"),
makePath("js/server/tests/shell-foxx-base-middleware.js"),
makePath("js/server/tests/shell-foxx-template-middleware.js"),
makePath("js/server/tests/shell-foxx-format-middleware.js"),
makePath("js/server/tests/shell-foxx-preprocessor.js"),
makePath("js/server/tests/shell-skiplist-index.js"),
makePath("js/server/tests/shell-skiplist-rm-performance.js"),
makePath("js/server/tests/shell-skiplist-correctness.js")
];
var tests_shell_common;
var tests_shell_server_only;
var tests_shell_client_only;
var tests_shell_server;
var tests_shell_client;
var tests_shell_server_ahuacatl;
var tests_shell_server_ahuacatl_extended;
var tests_shell_server = tests_shell_common.concat(tests_shell_server_only);
function findTests () {
if (foundTests) {
return;
}
tests_shell_common = _.filter(fs.list(makePath("js/common/tests")),
function (p) {
return p.substr(0,6) === "shell-" &&
p.substr(-3) === ".js";
}).map(
function(x) {
return fs.join(makePath("js/common/tests"),x);
}).sort();
tests_shell_server_only = _.filter(fs.list(makePath("js/server/tests")),
function (p) {
return p.substr(0,6) === "shell-" &&
p.substr(-3) === ".js";
}).map(
function(x) {
return fs.join(makePath("js/server/tests"),x);
}).sort();
tests_shell_client_only = _.filter(fs.list(makePath("js/client/tests")),
function (p) {
return p.substr(0,6) === "shell-" &&
p.substr(-3) === ".js";
}).map(
function(x) {
return fs.join(makePath("js/client/tests"),x);
}).sort();
tests_shell_server_ahuacatl = _.filter(fs.list(makePath("js/server/tests")),
function (p) {
return p.substr(0,9) === "ahuacatl-" &&
p.substr(-3) === ".js" &&
p.indexOf("ranges-combined") === -1;
}).map(
function(x) {
return fs.join(makePath("js/server/tests"),x);
}).sort();
tests_shell_server_ahuacatl_extended =
_.filter(fs.list(makePath("js/server/tests")),
function (p) {
return p.substr(0,9) === "ahuacatl-" &&
p.substr(-3) === ".js" &&
p.indexOf("ranges-combined") !== -1;
}).map(
function(x) {
return fs.join(makePath("js/server/tests"),x);
}).sort();
var tests_shell_server_ahuacatl =
[
makePath("js/server/tests/ahuacatl-ranges.js"),
makePath("js/server/tests/ahuacatl-queries-optimiser.js"),
makePath("js/server/tests/ahuacatl-queries-optimiser-in.js"),
makePath("js/server/tests/ahuacatl-queries-optimiser-limit.js"),
makePath("js/server/tests/ahuacatl-queries-optimiser-sort.js"),
makePath("js/server/tests/ahuacatl-queries-optimiser-ref.js"),
makePath("js/server/tests/ahuacatl-escaping.js"),
makePath("js/server/tests/ahuacatl-functions.js"),
makePath("js/server/tests/ahuacatl-variables.js"),
makePath("js/server/tests/ahuacatl-bind.js"),
makePath("js/server/tests/ahuacatl-complex.js"),
makePath("js/server/tests/ahuacatl-logical.js"),
makePath("js/server/tests/ahuacatl-arithmetic.js"),
makePath("js/server/tests/ahuacatl-relational.js"),
makePath("js/server/tests/ahuacatl-ternary.js"),
makePath("js/server/tests/ahuacatl-parse.js"),
makePath("js/server/tests/ahuacatl-hash.js"),
makePath("js/server/tests/ahuacatl-skiplist.js"),
makePath("js/server/tests/ahuacatl-cross.js"),
makePath("js/server/tests/ahuacatl-graph.js"),
makePath("js/server/tests/ahuacatl-edges.js"),
makePath("js/server/tests/ahuacatl-refaccess-variable.js"),
makePath("js/server/tests/ahuacatl-refaccess-attribute.js"),
makePath("js/server/tests/ahuacatl-queries-simple.js"),
makePath("js/server/tests/ahuacatl-queries-variables.js"),
makePath("js/server/tests/ahuacatl-queries-geo.js"),
makePath("js/server/tests/ahuacatl-queries-fulltext.js"),
makePath("js/server/tests/ahuacatl-queries-collection.js"),
makePath("js/server/tests/ahuacatl-queries-noncollection.js"),
makePath("js/server/tests/ahuacatl-subquery.js"),
makePath("js/server/tests/ahuacatl-operators.js")
];
var tests_shell_server_ahuacatl_extended =
[
makePath("js/server/tests/ahuacatl-ranges-combined-1.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-2.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-3.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-4.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-5.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-6.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-7.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-8.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-9.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-10.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-11.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-12.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-13.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-14.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-15.js"),
makePath("js/server/tests/ahuacatl-ranges-combined-16.js")
];
var tests_shell_client_only =
[
makePath("js/client/tests/shell-endpoints.js"),
makePath("js/client/tests/shell-fm.js"),
makePath("js/client/tests/client.js")
];
var tests_shell_client = tests_shell_common.concat(tests_shell_client_only);
tests_shell_server = tests_shell_common.concat(tests_shell_server_only);
tests_shell_client = tests_shell_common.concat(tests_shell_client_only);
foundTests = true;
}
function runThere (options, instanceInfo, file) {
var r;
@ -419,10 +364,16 @@ function performTests(options, testList) {
for (i = 0; i < testList.length; i++) {
te = testList[i];
print("\nTrying",te,"...");
var r = runThere(options, instanceInfo, te);
results[te] = r;
if (r !== true && !options.force) {
break;
if ((te.indexOf("-cluster-") === -1 || options.cluster) &&
(te.indexOf("-noncluster-") === -1 || options.cluster === false)) {
var r = runThere(options, instanceInfo, te);
results[te] = r;
if (r !== true && !options.force) {
break;
}
}
else {
print("Skipped because of cluster/non-cluster.");
}
}
print("Shutting down...");
@ -432,14 +383,17 @@ function performTests(options, testList) {
}
testFuncs.shell_server = function (options) {
findTests();
return performTests(options, tests_shell_server);
};
testFuncs.shell_server_only = function (options) {
findTests();
return performTests(options, tests_shell_server_only);
};
testFuncs.shell_server_ahuacatl = function(options) {
findTests();
if (!options.skipAhuacatl) {
if (options.skipRanges) {
return performTests(options, tests_shell_server_ahuacatl);
@ -451,6 +405,7 @@ testFuncs.shell_server_ahuacatl = function(options) {
};
testFuncs.shell_client = function(options) {
findTests();
var topDir = findTopDir();
var instanceInfo = startInstance("tcp",options);
var results = {};
@ -459,10 +414,16 @@ testFuncs.shell_client = function(options) {
for (i = 0; i < tests_shell_client.length; i++) {
te = tests_shell_client[i];
print("\nTrying",te,"...");
var r = runInArangosh(options, instanceInfo, te);
results[te] = r;
if (r !== 0 && !options.force) {
break;
if ((te.indexOf("-cluster-") === -1 || options.cluster) &&
(te.indexOf("-noncluster-") === -1 || options.cluster === false)) {
var r = runInArangosh(options, instanceInfo, te);
results[te] = r;
if (r !== 0 && !options.force) {
break;
}
}
else {
print("Skipped because of cluster/non-cluster.");
}
}
print("Shutting down...");
@ -835,7 +796,7 @@ testFuncs.authentication = function (options) {
["--server.disable-authentication", "false"]);
var results = {};
results.auth = runInArangosh(options, instanceInfo,
fs.join("js","client","tests","shell-auth.js"));
fs.join("js","client","tests","auth.js"));
print("Shutting down...");
shutdownInstance(instanceInfo,options);
print("done.");
@ -920,7 +881,6 @@ testFuncs.authentication_parameters = function (options) {
var allTests =
[
"make",
"config",
"boost",
"shell_server",
@ -932,7 +892,6 @@ var allTests =
"arangob",
"importing",
"upgrade",
// "dfdb", needs input redirection, but is not a good test anyway
"foxx_manager",
"authentication",
"authentication_parameters"

17
js/server/tests/README Normal file
View File

@ -0,0 +1,17 @@
Conventions for testing framework:
==================================
All files in this directory whose name starts with "shell-"
and ends with ".js" automatically take part in server
shell tests (targets "shell_server" and "shell-server-only").
All files in this directory whose name starts with "ahuacatl-"
and ends with ".js" automatically take part in server ahuacatl
tests (target "shell_server_ahuacatl"). Those, whose filename
contains the string "ranges-combined" are only taken if the
flag "skipRanges" in the test options is set to false.
If the filename contains the string "-cluster-", then it is
only executed when testing in cluster mode. If the filename
contains the string "-noncluster-", then it is only executed
when testing in single instance mode.