Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS test cleanup x3 #651

Merged
merged 3 commits into from Jul 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion dev/run
Expand Up @@ -189,7 +189,8 @@ def setup_configs(ctx):
"backend_port": backend_port,
"fauxton_root": fauxton_root,
"uuid": "fake_uuid_for_dev",
"_default": ""
"_default": "",
"compaction_daemon": "{}"
}
write_config(ctx, node, env)

Expand Down
3 changes: 0 additions & 3 deletions test/javascript/tests/config.js
Expand Up @@ -11,9 +11,6 @@
// the License.

couchTests.config = function(debug) {
var db_name = get_random_db_name();
var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
db.createDb();
if (debug) debugger;

// test that /_config returns all the settings
Expand Down
6 changes: 6 additions & 0 deletions test/javascript/tests/delayed_commits.js
Expand Up @@ -32,6 +32,9 @@ couchTests.delayed_commits = function(debug) {
// other updates. If it crashes or is restarted you may lose the most
// recent commits.

// restartServer() requires a server to be up 15s before it restarts
sleep(15000);

T(db.save({_id:"1",a:2,b:4}).ok);
T(db.open("1") != null);

Expand All @@ -41,4 +44,7 @@ couchTests.delayed_commits = function(debug) {
// note if we waited > 1 sec before the restart, the doc would likely
// commit.
});

// cleanup
db.deleteDb();
};
2 changes: 2 additions & 0 deletions test/javascript/tests/proxyauth.js
Expand Up @@ -132,4 +132,6 @@ couchTests.proxyauth = function(debug) {

// cleanup
db.deleteDb();
usersDb.deleteDb();

};
7 changes: 6 additions & 1 deletion test/javascript/tests/reader_acl.js
Expand Up @@ -214,7 +214,12 @@ couchTests.reader_acl = function(debug) {
testFun // stick to the essentials and do it all in one
);

// cleanup
usersDb.deleteDb();
// have to delete the backside version now too :(
var req = CouchDB.newXhr();
req.open("DELETE", "http://127.0.0.1:15986/" + users_db_name, false);
req.send("");
CouchDB.maybeThrowError(req);

secretDb.deleteDb();
}
3 changes: 0 additions & 3 deletions test/javascript/tests/replication.js
Expand Up @@ -1715,9 +1715,6 @@ couchTests.replication = function(debug) {

// COUCHDB-885 - push replication of a doc with attachment causes a
// conflict in the target.
sourceDb = new CouchDB("test_suite_db_a");
targetDb = new CouchDB("test_suite_db_b");

populateSourceDb([]);
populateTargetDb([]);

Expand Down
2 changes: 2 additions & 0 deletions test/javascript/tests/rev_stemming.js
Expand Up @@ -117,5 +117,7 @@ couchTests.rev_stemming = function(debug) {
"should return a truncated revision list");

// cleanup
db_orig.deleteDb();
db.deleteDb();
dbB.deleteDb();
};
5 changes: 2 additions & 3 deletions test/javascript/tests/rewrite.js
Expand Up @@ -505,8 +505,7 @@ couchTests.rewrite = function(debug) {
TEquals(200, xhr.status);
}
});
// cleanup
db.deleteDb();
}

// cleanup
db.deleteDb();
}
3 changes: 3 additions & 0 deletions test/javascript/tests/rewrite_js.js
Expand Up @@ -336,5 +336,8 @@ couchTests.rewrite = function(debug) {
var url = "/"+dbName+"/_design/loop/_rewrite/loop";
var xhr = CouchDB.request("GET", url);
TEquals(400, xhr.status);

// cleanup
db.deleteDb();
}
}
5 changes: 5 additions & 0 deletions test/javascript/tests/security_validation.js
Expand Up @@ -325,4 +325,9 @@ couchTests.security_validation = function(debug) {
adminDbB.deleteDb();
}
authDb.deleteDb();
// have to clean up authDb on the backside :(
var req = CouchDB.newXhr();
req.open("DELETE", "http://127.0.0.1:15986/" + authDb_name, false);
req.send("");
CouchDB.maybeThrowError(req);
};
25 changes: 25 additions & 0 deletions test/javascript/tests/stats.js
Expand Up @@ -11,6 +11,10 @@
// the License.

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"});
Expand Down Expand Up @@ -44,10 +48,20 @@ couchTests.stats = function(debug) {
if(funcs.run) funcs.run(db);
var after = getStat(path);
if(funcs.test) funcs.test(before, after);
db.deleteDb();
}

if (debug) debugger;

/* Need to delete _users and _replicator or background activity
will mess with the results of this entire suite. */
(function() {
var users = new CouchDB("_users");
users.deleteDb();
var replicator = new CouchDB("_replicator");
replicator.deleteDb();
})();

(function() {
var db = newDb(false);
db.deleteDb();
Expand Down Expand Up @@ -116,6 +130,9 @@ couchTests.stats = function(debug) {
var post_files = getStat(["couchdb", "open_os_files"]);
TEquals(pre_dbs, post_dbs, "We have the same number of open dbs.");
TEquals(pre_files, post_files, "We have the same number of open files.");
for (var ctr = 0; ctr < dbs.length; ctr++) {
dbs[ctr].deleteDb();
}
};

run_on_modified_server(
Expand Down Expand Up @@ -331,4 +348,12 @@ couchTests.stats = function(debug) {
})();

// cleanup
/* Recreate the deleted _users and _replicator dbs */
(function() {
var users = new CouchDB("_users");
users.createDb();
var replicator = new CouchDB("_replicator");
replicator.createDb();
})();

};