From 9b78e1555d73c888fedaa0b9d256abaeaadbe41a Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Wed, 9 Sep 2009 16:53:49 +0000 Subject: choice of uuid algos for better insert perf. Closes COUCHDB-465. Thanks rnewson, bitdiddle git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@813051 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/uuids.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'share') diff --git a/share/www/script/test/uuids.js b/share/www/script/test/uuids.js index 3b7533be..50621678 100644 --- a/share/www/script/test/uuids.js +++ b/share/www/script/test/uuids.js @@ -59,4 +59,45 @@ couchTests.uuids = function(debug) { // ensure we return a 405 on POST xhr = CouchDB.request("POST", "/_uuids?count=1000"); T(xhr.status == 405); + + // Test sequential uuids + var seq_testfun = function() { + xhr = CouchDB.request("GET", "/_uuids?count=1000"); + T(xhr.status == 200); + result = JSON.parse(xhr.responseText); + for(var i = 1; i < result.uuids.length; i++) { + T(result.uuids[i].length == 32); + T(result.uuids[i-1] < result.uuids[i], "Sequential uuids are ordered."); + } + }; + + run_on_modified_server([{ + "section": "uuids", + "key": "algorithm", + "value": "sequential", + }], + seq_testfun + ); + + // Test utc_random uuids + var utc_testfun = function() { + xhr = CouchDB.request("GET", "/_uuids?count=1000"); + T(xhr.status == 200); + result = JSON.parse(xhr.responseText); + for(var i = 1; i < result.uuids.length; i++) { + T(result.uuids[i].length == 32); + var u1 = result.uuids[i-1].substr(0, 13); + var u2 = result.uuids[i].substr(0, 13); + T(u1 < u2, "UTC uuids are roughly ordered."); + } + }; + + run_on_modified_server([{ + "section": "uuids", + "key": "algorithm", + "value": "utc_random" + }], + utc_testfun + ); + }; -- cgit v1.2.3