diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-12-19 10:23:27 -0600 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-12-25 11:45:20 -0600 |
commit | b4fa539b603c67936250ffae222e4ac442d277a2 (patch) | |
tree | 1e5d2b8e90e6245729115ab55bfc85fafd72929f | |
parent | 4d73243379538c057c37a0a248283d53161d84bf (diff) | |
download | couchdb-b4fa539b603c67936250ffae222e4ac442d277a2.tar.gz |
Speedup JavaScript tests
We sleep for a bit more than a second for each test. Rather than using
return to skip a test we just mark the test as skipped so we don't
have to waste time. This saves about 25s on the test suite.
28 files changed, 92 insertions, 93 deletions
diff --git a/test/javascript/cli_runner.js b/test/javascript/cli_runner.js index dbaf1c216..5d7a98021 100644 --- a/test/javascript/cli_runner.js +++ b/test/javascript/cli_runner.js @@ -22,6 +22,10 @@ function runTest() { var count = 0; var start = new Date().getTime(); + if(couchTests.skip) { + quit(2); + } + for(var name in couchTests) { count++; } diff --git a/test/javascript/run b/test/javascript/run index 1fa605dec..ebcdef9b8 100755 --- a/test/javascript/run +++ b/test/javascript/run @@ -44,14 +44,17 @@ RUNNER = "test/javascript/cli_runner.js" def mkformatter(tests): longest = max([len(x) for x in tests]) green = "\033[32m" + orange = "\033[33m" red = "\033[31m" clear = "\033[0m" if not sys.stderr.isatty(): - green, read, clear = "", "", "" + green, orange, red, clear = "", "", "", "" - def _colorized(passed): - if passed: + def _colorized(rval): + if rval == 0: return green + "pass" + clear + elif rval == 2: + return orange + "skipped" + clear else: return red + "fail" + clear @@ -60,7 +63,7 @@ def mkformatter(tests): padding = (longest - len(test)) * " " sys.stderr.write(test + " " + padding) sys.stderr.flush() - elif isinstance(test, bool): + elif isinstance(test, int): if test: sys.stderr.write(_colorized(test) + os.linesep) else: @@ -86,7 +89,7 @@ def run_couchjs(test, fmt): line = line.decode() sys.stderr.write(line) p.wait() - fmt(p.returncode == 0) + fmt(p.returncode) return p.returncode @@ -163,7 +166,7 @@ def main(): fmt = mkformatter(tests) for test in tests: result = run_couchjs(test, fmt) - if result == 0: + if result == 0 or result == 2: passed += 1 else: failed += 1 diff --git a/test/javascript/tests-cluster/with-quorum/attachments_delete_overridden_quorum.js b/test/javascript/tests-cluster/with-quorum/attachments_delete_overridden_quorum.js index 1994a0ac2..79c070e9f 100644 --- a/test/javascript/tests-cluster/with-quorum/attachments_delete_overridden_quorum.js +++ b/test/javascript/tests-cluster/with-quorum/attachments_delete_overridden_quorum.js @@ -10,6 +10,7 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.attachments_delete_overridden_quorum= function(debug) { var db_name = get_random_db_name(); var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":3}); @@ -25,7 +26,7 @@ couchTests.attachments_delete_overridden_quorum= function(debug) { var rev = JSON.parse(xhr.responseText).rev; xhr = CouchDB.request("DELETE", "/" + db_name + "/dummy/foo.txt?rev=" + rev); - console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum. 202->"+xhr.status); + console.log("TODO: Clarify correct behaviour. Is not considering overridden quorum. 202->"+xhr.status); // TODO: Define correct behaviour //T(xhr.status == 202,"Should return 202 but returns "+xhr.status); diff --git a/test/javascript/tests-cluster/with-quorum/attachments_overridden_quorum.js b/test/javascript/tests-cluster/with-quorum/attachments_overridden_quorum.js index 22c8a4c87..f9deb15c1 100644 --- a/test/javascript/tests-cluster/with-quorum/attachments_overridden_quorum.js +++ b/test/javascript/tests-cluster/with-quorum/attachments_overridden_quorum.js @@ -11,6 +11,7 @@ // the License. //Test attachments operations with an overridden quorum parameter +couchTests.skip = true; couchTests.attachments_overriden_quorum= function(debug) { var db_name = get_random_db_name(); var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":3}); @@ -32,7 +33,7 @@ couchTests.attachments_overriden_quorum= function(debug) { body:"This is no base64 encoded text-2", headers:{"Content-Type": "text/plain;charset=utf-8"} }); - console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum. 202->"+xhr.status); + console.log("TODO: Clarify correct behaviour. Is not considering overridden quorum. 202->"+xhr.status); //TODO: Define correct behaviour //T(xhr.status == 202,"Should return 202"); diff --git a/test/javascript/tests-cluster/with-quorum/db_creation_overridden_quorum.js b/test/javascript/tests-cluster/with-quorum/db_creation_overridden_quorum.js index 14d319ccd..1e69cd8b4 100644 --- a/test/javascript/tests-cluster/with-quorum/db_creation_overridden_quorum.js +++ b/test/javascript/tests-cluster/with-quorum/db_creation_overridden_quorum.js @@ -11,6 +11,7 @@ // the License. // Do DB creation under cluster with quorum conditions but overriding write quorum. +couchTests.skip = true; couchTests.db_creation_overridden_quorum = function(debug) { if (debug) debugger; @@ -20,7 +21,7 @@ couchTests.db_creation_overridden_quorum = function(debug) { // DB Creation should return 202 - Accepted xhr = CouchDB.request("PUT", "/" + db_name + "/"); - console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum. 202->"+xhr.status) + console.log("TODO: Clarify correct behaviour. Is not considering overridden quorum. 202->"+xhr.status) //T(xhr.status == 202,"Should return 202"); // cleanup diff --git a/test/javascript/tests-cluster/with-quorum/doc_copy_overridden_quorum.js b/test/javascript/tests-cluster/with-quorum/doc_copy_overridden_quorum.js index 23fbc9754..1ceef9743 100644 --- a/test/javascript/tests-cluster/with-quorum/doc_copy_overridden_quorum.js +++ b/test/javascript/tests-cluster/with-quorum/doc_copy_overridden_quorum.js @@ -10,6 +10,7 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.doc_copy_overriden_quorum = function(debug) { var db_name = get_random_db_name(); var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":3}); @@ -23,7 +24,7 @@ couchTests.doc_copy_overriden_quorum = function(debug) { }); //TODO: Define correct behaviour //T(xhr.status=="202","Should return 202"); - console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum. 202->"+xhr.status); + console.log("TODO: Clarify correct behaviour. Is not considering overridden quorum. 202->"+xhr.status); db.deleteDb(); diff --git a/test/javascript/tests-cluster/without-quorum/attachments_delete.js b/test/javascript/tests-cluster/without-quorum/attachments_delete.js index d05fcaffa..48a33d2e8 100644 --- a/test/javascript/tests-cluster/without-quorum/attachments_delete.js +++ b/test/javascript/tests-cluster/without-quorum/attachments_delete.js @@ -10,6 +10,7 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.attachments_delete= function(debug) { var db_name = get_random_db_name(); var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"}); @@ -26,7 +27,7 @@ couchTests.attachments_delete= function(debug) { var rev = JSON.parse(xhr.responseText).rev; xhr = CouchDB.request("DELETE", "/" + db_name + "/dummy/foo.txt?rev=" + rev); - console.log("Skipped-TODO: Clarify correct behaviour. Is not considering quorum. 202->"+xhr.status); + console.log("TODO: Clarify correct behaviour. Is not considering quorum. 202->"+xhr.status); //TODO: Define correct behaviour //T(xhr.status == 202,"Should return 202 Accepted but returns "+xhr.status); diff --git a/test/javascript/tests-cluster/without-quorum/attachments_delete_overridden_quorum.js b/test/javascript/tests-cluster/without-quorum/attachments_delete_overridden_quorum.js index 906391ae1..c3b95f865 100644 --- a/test/javascript/tests-cluster/without-quorum/attachments_delete_overridden_quorum.js +++ b/test/javascript/tests-cluster/without-quorum/attachments_delete_overridden_quorum.js @@ -10,6 +10,7 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.attachments_delete_overridden_quorum= function(debug) { var db_name = get_random_db_name(); var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":1}); @@ -25,7 +26,7 @@ couchTests.attachments_delete_overridden_quorum= function(debug) { var rev = JSON.parse(xhr.responseText).rev; xhr = CouchDB.request("DELETE", "/" + db_name + "/dummy/foo.txt?rev=" + rev); - console.log("Skipped-TODO: Clarify correct behaviour. Is not considering quorum. 202->"+xhr.status); + console.log("TODO: Clarify correct behaviour. Is not considering quorum. 202->"+xhr.status); //TODO: Define correct behaviour //T(xhr.status == 200,"Should return 200 but returns "+xhr.status); diff --git a/test/javascript/tests-cluster/without-quorum/db_creation_overridden_quorum.js b/test/javascript/tests-cluster/without-quorum/db_creation_overridden_quorum.js index 6d5d798d1..7cee52ee0 100644 --- a/test/javascript/tests-cluster/without-quorum/db_creation_overridden_quorum.js +++ b/test/javascript/tests-cluster/without-quorum/db_creation_overridden_quorum.js @@ -11,6 +11,7 @@ // the License. // Do DB creation under cluster with quorum conditions but overriding write quorum. +couchTests.skip = true; couchTests.db_creation_overridden_quorum = function(debug) { if (debug) debugger; @@ -20,7 +21,7 @@ couchTests.db_creation_overridden_quorum = function(debug) { // DB Creation should return 201 - Created xhr = CouchDB.request("PUT", "/" + db_name + "/"); - console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum. 201->"+xhr.status) + console.log("TODO: Clarify correct behaviour. Is not considering overridden quorum. 201->"+xhr.status) //T(xhr.status == 201,"Should return 201"); //db.deleteDb(); diff --git a/test/javascript/tests-cluster/without-quorum/doc_copy_overridden_quorum.js b/test/javascript/tests-cluster/without-quorum/doc_copy_overridden_quorum.js index e72425d86..bf372cad2 100644 --- a/test/javascript/tests-cluster/without-quorum/doc_copy_overridden_quorum.js +++ b/test/javascript/tests-cluster/without-quorum/doc_copy_overridden_quorum.js @@ -10,6 +10,7 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.doc_copy_overriden_quorum = function(debug) { var db_name = get_random_db_name(); var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":1}); @@ -21,7 +22,7 @@ couchTests.doc_copy_overriden_quorum = function(debug) { var xhr = CouchDB.request("COPY", "/" + db_name + "/dummy", { headers: {"Destination":"dummy2"} }); - console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum. 201->"+xhr.status); + console.log("TODO: Clarify correct behaviour. Is not considering overridden quorum. 201->"+xhr.status); //TODO Defie correct behaviour //T(xhr.status=="201","Should return 201"); diff --git a/test/javascript/tests/etags_views.js b/test/javascript/tests/etags_views.js index 6c110f8c3..555fe663d 100644 --- a/test/javascript/tests/etags_views.js +++ b/test/javascript/tests/etags_views.js @@ -10,8 +10,9 @@ // License for the specific language governing permissions and limitations under // the License. +// TODO: https://issues.apache.org/jira/browse/COUCHDB-2859 +couchTests.skip = true; couchTests.etags_views = function(debug) { - return console.log('TODO: see https://issues.apache.org/jira/browse/COUCHDB-2859'); var db_name = get_random_db_name(); var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"true"}); db.createDb(); @@ -79,7 +80,7 @@ couchTests.etags_views = function(debug) { xhr = CouchDB.request("GET", "/" + db_name + "/_design/etags/_view/basicView?include_docs=true"); var etag2 = xhr.getResponseHeader("etag"); T(etag1 != etag2); - + // Verify that purges affect etags xhr = CouchDB.request("GET", "/" + db_name + "/_design/etags/_view/fooView"); var foo_etag = xhr.getResponseHeader("etag"); @@ -180,7 +181,7 @@ couchTests.etags_views = function(debug) { ); etag2 = xhr.getResponseHeader("etag"); T(etag1 != etag2, "POST to reduce view generates key-depdendent ETags"); - + // all docs xhr = CouchDB.request("GET", "/" + db_name + "/_all_docs"); T(xhr.status == 200); @@ -201,21 +202,21 @@ couchTests.etags_views = function(debug) { // list etag // in the list test for now - - // A new database should have unique _all_docs etags. - db.deleteDb(); + + // A new database should have unique _all_docs etags. + db.deleteDb(); db.createDb(); // TODO: when re-activating try having a new DB name - db.save({a: 1}); - xhr = CouchDB.request("GET", "/" + db_name + "/_all_docs"); - var etag = xhr.getResponseHeader("etag"); - db.deleteDb(); + db.save({a: 1}); + xhr = CouchDB.request("GET", "/" + db_name + "/_all_docs"); + var etag = xhr.getResponseHeader("etag"); + db.deleteDb(); db.createDb(); // TODO: when re-activating try having a new DB name - db.save({a: 2}); - xhr = CouchDB.request("GET", "/" + db_name + "/_all_docs"); + db.save({a: 2}); + xhr = CouchDB.request("GET", "/" + db_name + "/_all_docs"); var new_etag = xhr.getResponseHeader("etag"); T(etag != new_etag); // but still be cacheable - xhr = CouchDB.request("GET", "/" + db_name + "/_all_docs"); + xhr = CouchDB.request("GET", "/" + db_name + "/_all_docs"); T(new_etag == xhr.getResponseHeader("etag")); // cleanup diff --git a/test/javascript/tests/replicator_db_compact_rep_db.js b/test/javascript/tests/replicator_db_compact_rep_db.js index 8bd45f96e..e8ba326f7 100644 --- a/test/javascript/tests/replicator_db_compact_rep_db.js +++ b/test/javascript/tests/replicator_db_compact_rep_db.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_compact_rep_db = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_continuous.js b/test/javascript/tests/replicator_db_continuous.js index 63174e9ae..6d3714988 100644 --- a/test/javascript/tests/replicator_db_continuous.js +++ b/test/javascript/tests/replicator_db_continuous.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_continuous = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_credential_delegation.js b/test/javascript/tests/replicator_db_credential_delegation.js index 6401819d1..7ec7711e1 100644 --- a/test/javascript/tests/replicator_db_credential_delegation.js +++ b/test/javascript/tests/replicator_db_credential_delegation.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_credential_delegation = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_field_validation.js b/test/javascript/tests/replicator_db_field_validation.js index 9e7bb89ca..4442c8825 100644 --- a/test/javascript/tests/replicator_db_field_validation.js +++ b/test/javascript/tests/replicator_db_field_validation.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_field_validation = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_filtered.js b/test/javascript/tests/replicator_db_filtered.js index 7675b413f..4c1cfb3d1 100644 --- a/test/javascript/tests/replicator_db_filtered.js +++ b/test/javascript/tests/replicator_db_filtered.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_filtered = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_identical.js b/test/javascript/tests/replicator_db_identical.js index 15bedc698..a51fb6791 100644 --- a/test/javascript/tests/replicator_db_identical.js +++ b/test/javascript/tests/replicator_db_identical.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_identical = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_identical_continuous.js b/test/javascript/tests/replicator_db_identical_continuous.js index bafa19c02..37495ecbd 100644 --- a/test/javascript/tests/replicator_db_identical_continuous.js +++ b/test/javascript/tests/replicator_db_identical_continuous.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_identical_continuous = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_invalid_filter.js b/test/javascript/tests/replicator_db_invalid_filter.js index 38c7469fc..a974ad2d4 100644 --- a/test/javascript/tests/replicator_db_invalid_filter.js +++ b/test/javascript/tests/replicator_db_invalid_filter.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_invalid_filter = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_security.js b/test/javascript/tests/replicator_db_security.js index ffb5c4036..4994958fc 100644 --- a/test/javascript/tests/replicator_db_security.js +++ b/test/javascript/tests/replicator_db_security.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_security = function(debug) { - return console.log('TODO'); - var reset_dbs = function(dbs) { dbs.forEach(function(db) { db.deleteDb(); @@ -166,7 +165,7 @@ couchTests.replicator_db_security = function(debug) { names : ["benoitc"] } }).ok); - + run_on_modified_server([ { section: "admins", diff --git a/test/javascript/tests/replicator_db_simple.js b/test/javascript/tests/replicator_db_simple.js index 61fed8d89..ad0a692d4 100644 --- a/test/javascript/tests/replicator_db_simple.js +++ b/test/javascript/tests/replicator_db_simple.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_simple = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_successive.js b/test/javascript/tests/replicator_db_successive.js index c556bafe9..d2ff4df0f 100644 --- a/test/javascript/tests/replicator_db_successive.js +++ b/test/javascript/tests/replicator_db_successive.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_successive = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_survives.js b/test/javascript/tests/replicator_db_survives.js index 2fa69da93..e44156d54 100644 --- a/test/javascript/tests/replicator_db_survives.js +++ b/test/javascript/tests/replicator_db_survives.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_survives = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_swap_rep_db.js b/test/javascript/tests/replicator_db_swap_rep_db.js index a8021343b..4eac484c2 100644 --- a/test/javascript/tests/replicator_db_swap_rep_db.js +++ b/test/javascript/tests/replicator_db_swap_rep_db.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_swap_rep_db = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_update_security.js b/test/javascript/tests/replicator_db_update_security.js index 78d02af36..73c28f93d 100644 --- a/test/javascript/tests/replicator_db_update_security.js +++ b/test/javascript/tests/replicator_db_update_security.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_update_security = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_user_ctx.js b/test/javascript/tests/replicator_db_user_ctx.js index 353e2ed9e..06ca78139 100644 --- a/test/javascript/tests/replicator_db_user_ctx.js +++ b/test/javascript/tests/replicator_db_user_ctx.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_user_ctx = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/replicator_db_write_auth.js b/test/javascript/tests/replicator_db_write_auth.js index 97453953c..2ac27c235 100644 --- a/test/javascript/tests/replicator_db_write_auth.js +++ b/test/javascript/tests/replicator_db_write_auth.js @@ -10,9 +10,8 @@ // License for the specific language governing permissions and limitations under // the License. +couchTests.skip = true; couchTests.replicator_db_survives = function(debug) { - return console.log('TODO'); - if (debug) debugger; var populate_db = replicator_db.populate_db; diff --git a/test/javascript/tests/stats.js b/test/javascript/tests/stats.js index be9d4d239..3a89ddd7d 100644 --- a/test/javascript/tests/stats.js +++ b/test/javascript/tests/stats.js @@ -10,11 +10,10 @@ // License for the specific language governing permissions and limitations under // the License. +// test has become very flaky - needs complete rewrite +couchTests.skip = true; couchTests.stats = function(debug) { - // test has become very flaky - needs complete rewrite - return console.log('TODO'); - function newDb(doSetup) { var db_name = get_random_db_name(); var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"}); @@ -65,14 +64,14 @@ couchTests.stats = function(debug) { (function() { var db = newDb(false); db.deleteDb(); - + var before = getStat(["couchdb", "open_databases"]); db.createDb(); var after = getStat(["couchdb", "open_databases"]); TEquals(before+8, after, "Creating a db increments open db count."); db.deleteDb(); })(); - + runTest(["couchdb", "open_databases"], { setup: function() {restartServer();}, run: function(db) {db.open("123");}, @@ -80,7 +79,7 @@ couchTests.stats = function(debug) { T(before<after, "Opening a db increases open db count."); } }); - + runTest(["couchdb", "open_databases"], { setup: function(db) {restartServer(); db.open("123");}, run: function(db) {db.deleteDb();}, @@ -88,16 +87,16 @@ couchTests.stats = function(debug) { T(before>after, "Deleting a db decrements open db count."); } }); - - /* Improvements in LRU has made this test difficult... + + /* Improvements in LRU has made this test difficult... (function() { restartServer(); var max = 5; - + var testFun = function() { var pre_dbs = getStat(["couchdb", "open_databases"]) || 0; var pre_files = getStat(["couchdb", "open_os_files"]) || 0; - + var triggered = false; var db = null; var dbs = []; @@ -117,15 +116,15 @@ couchTests.stats = function(debug) { db.save({"a": "1"}); } T(triggered, "We managed to force a all_dbs_active error."); - + var open_dbs = getStat(["couchdb", "open_databases"]); TEquals(open_dbs > 0, true, "We actually opened some dbs."); TEquals(max, open_dbs, "We only have max db's open."); - + for (var i = 0; i < dbs.length; i++) { dbs[i].deleteDb(); } - + var post_dbs = getStat(["couchdb", "open_databases"]); var post_files = getStat(["couchdb", "open_os_files"]); TEquals(pre_dbs, post_dbs, "We have the same number of open dbs."); @@ -134,14 +133,14 @@ couchTests.stats = function(debug) { dbs[ctr].deleteDb(); } }; - + run_on_modified_server( [{section: "couchdb", key: "max_dbs_open", value: "40"}], testFun ); })(); */ - + // Just fetching the before value is the extra +1 in test runTest(["couchdb", "httpd", "requests"], { run: function() {CouchDB.request("GET", "/");}, @@ -149,7 +148,7 @@ couchTests.stats = function(debug) { TEquals(before+2, after, "Request counts are incremented properly."); } }); - + runTest(["couchdb", "database_reads"], { setup: function(db) {db.save({"_id": "test"});}, run: function(db) {db.open("test");}, @@ -157,7 +156,7 @@ couchTests.stats = function(debug) { T(before<after, "Reading a doc increments docs reads."); } }); - + runTest(["couchdb", "database_reads"], { setup: function(db) {db.save({"_id": "test"});}, run: function(db) {db.request("GET", "/");}, @@ -165,7 +164,7 @@ couchTests.stats = function(debug) { TEquals(before, after, "Only doc reads increment doc reads."); } }); - + runTest(["couchdb", "database_reads"], { setup: function(db) {db.save({"_id": "test"});}, run: function(db) {db.open("test", {"open_revs": "all"});}, @@ -173,14 +172,14 @@ couchTests.stats = function(debug) { T(before<after, "Reading doc revs increments docs reads."); } }); - + runTest(["couchdb", "database_writes"], { run: function(db) {db.save({"a": "1"});}, test: function(before, after) { T(before<after, "Saving docs incrememnts doc writes."); } }); - + runTest(["couchdb", "database_writes"], { run: function(db) { CouchDB.request("POST", "/" + db.name + "", { @@ -192,7 +191,7 @@ couchTests.stats = function(debug) { T(before<after, "POST'ing new docs increments doc writes."); } }); - + runTest(["couchdb", "database_writes"], { setup: function(db) {db.save({"_id": "test"});}, run: function(db) {var doc = db.open("test"); db.save(doc);}, @@ -200,7 +199,7 @@ couchTests.stats = function(debug) { T(before<after, "Updating docs incrememnts doc writes."); } }); - + runTest(["couchdb", "database_writes"], { setup: function(db) {db.save({"_id": "test"});}, run: function(db) {var doc = db.open("test"); db.deleteDoc(doc);}, @@ -208,7 +207,7 @@ couchTests.stats = function(debug) { T(before<after, "Deleting docs increments doc writes."); } }); - + runTest(["couchdb", "database_writes"], { setup: function(db) {db.save({"_id": "test"});}, run: function(db) { @@ -220,7 +219,7 @@ couchTests.stats = function(debug) { T(before<after, "Copying docs increments doc writes."); } }); - + runTest(["couchdb", "database_writes"], { run: function(db) { CouchDB.request("PUT", "/" + db.name + "/bin_doc2/foo2.txt", { @@ -232,7 +231,7 @@ couchTests.stats = function(debug) { T(before<after, "Create with attachment increments doc writes."); } }); - + runTest(["couchdb", "database_writes"], { setup: function(db) {db.save({"_id": "test"});}, run: function(db) { @@ -246,21 +245,21 @@ couchTests.stats = function(debug) { T(before<after, "Adding attachment increments doc writes."); } }); - + runTest(["couchdb", "httpd", "bulk_requests"], { run: function(db) {db.bulkSave(makeDocs(5));}, test: function(before, after) { TEquals(before+1, after, "The bulk_requests counter is incremented."); } }); - + runTest(["couchdb", "httpd", "view_reads"], { run: function(db) {doView(db);}, test: function(before, after) { T(before<after, "Reading a view increments view reads."); } }); - + runTest(["couchdb", "httpd", "view_reads"], { setup: function(db) {db.save({"_id": "test"});}, run: function(db) {db.open("test");}, @@ -268,35 +267,35 @@ couchTests.stats = function(debug) { TEquals(before, after, "Reading a doc doesn't increment view reads."); } }); - + // Relies on getting the stats values being GET requests. runTest(["couchdb", "httpd_request_methods", "GET"], { test: function(before, after) { TEquals(before+1, after, "Get requests are incremented properly."); } }); - + runTest(["couchdb", "httpd_request_methods", "GET"], { run: function() {CouchDB.request("POST", "/");}, test: function(before, after) { TEquals(before+1, after, "POST requests don't affect GET counter."); } }); - + runTest(["couchdb", "httpd_request_methods", "POST"], { run: function() {CouchDB.request("POST", "/");}, test: function(before, after) { TEquals(before+1, after, "POST requests are incremented properly."); } }); - + runTest(["couchdb", "httpd_status_codes", "404"], { run: function() {CouchDB.request("GET", "/nonexistant_db");}, test: function(before, after) { TEquals(before+1, after, "Increments 404 counter on db not found."); } }); - + runTest(["couchdb", "httpd_status_codes", "404"], { run: function() {CouchDB.request("GET", "/");}, test: function(before, after) { |