From cdf43ab5a1d5ea21e42302c848fe4f07150e6947 Mon Sep 17 00:00:00 2001 From: "Damien F. Katz" Date: Thu, 9 Apr 2009 21:37:23 +0000 Subject: Fix for attachment sparseness bug COUCHDB-220 by giving each attachment it's own stream and calling set_min_buffer instead of ensure_buffer. Also fixed spurious couch_file crash messages by putting the statistics decrement code into a seperate monitoring process. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@763816 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/attachments.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'share/www/script/test') diff --git a/share/www/script/test/attachments.js b/share/www/script/test/attachments.js index 4b43e31a..d9560bce 100644 --- a/share/www/script/test/attachments.js +++ b/share/www/script/test/attachments.js @@ -142,5 +142,38 @@ couchTests.attachments= function(debug) { var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc4/attachment.txt"); T(xhr.status == 200); T(xhr.responseText == "This is a string"); + + + // Attachment sparseness COUCHDB-220 + + var docs = [] + for (var i = 0; i < 5; i++) { + var doc = { + _id: (i).toString(), + _attachments:{ + "foo.txt": { + content_type:"text/plain", + data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ=" + } + } + } + docs.push(doc) + } + + db.bulkSave(docs); + + var before = db.info().disk_size; + + // Compact it. + T(db.compact().ok); + T(db.last_req.status == 202); + // compaction isn't instantaneous, loop until done + while (db.info().compact_running) {}; + + var after = db.info().disk_size; + + // Compaction should reduce the database slightly, but not + // orders of magnitude (unless attachments introduce sparseness) + T(after > before * 0.1, "before: " + before + " after: " + after); }; -- cgit v1.2.3