couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1036380 - in /couchdb/branches/1.0.x: THANKS src/couchdb/couch_db.erl test/etap/113-replication-attachment-comp.t
Date Thu, 18 Nov 2010 10:07:34 GMT
Author: fdmanana
Date: Thu Nov 18 10:07:33 2010
New Revision: 1036380

URL: http://svn.apache.org/viewvc?rev=1036380&view=rev
Log:
Merged revision 1032673 from trunk:

Preserve attachment identity length when doing local to local replications.
Closes COUCHDB-930.
Patch by Juuso Väänänen. Thanks.


Modified:
    couchdb/branches/1.0.x/THANKS
    couchdb/branches/1.0.x/src/couchdb/couch_db.erl
    couchdb/branches/1.0.x/test/etap/113-replication-attachment-comp.t

Modified: couchdb/branches/1.0.x/THANKS
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/THANKS?rev=1036380&r1=1036379&r2=1036380&view=diff
==============================================================================
--- couchdb/branches/1.0.x/THANKS (original)
+++ couchdb/branches/1.0.x/THANKS Thu Nov 18 10:07:33 2010
@@ -66,6 +66,7 @@ suggesting improvements or submitting ch
  * Lim Yue Chuan <shasderias@gmail.com>
  * David Davis <xantus@xantus.org>
  * Dale Harvey <dale@arandomurl.com>
+ * Juuso Väänänen <juuso@vaananen.org>
  * Benjamin Young <byoung@bigbluehat.com>
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/branches/1.0.x/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_db.erl?rev=1036380&r1=1036379&r2=1036380&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/couchdb/couch_db.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_db.erl Thu Nov 18 10:07:33 2010
@@ -816,11 +816,12 @@ flush_att(Fd, #att{data={Fd0, _}}=Att) w
     % already written to our file, nothing to write
     Att;
 
-flush_att(Fd, #att{data={OtherFd,StreamPointer}, md5=InMd5}=Att) ->
+flush_att(Fd, #att{data={OtherFd,StreamPointer}, md5=InMd5,
+    disk_len=InDiskLen} = Att) ->
     {NewStreamData, Len, _IdentityLen, Md5, IdentityMd5} =
             couch_stream:copy_to_new_stream(OtherFd, StreamPointer, Fd),
     check_md5(IdentityMd5, InMd5),
-    Att#att{data={Fd, NewStreamData}, md5=Md5, att_len=Len, disk_len=Len};
+    Att#att{data={Fd, NewStreamData}, md5=Md5, att_len=Len, disk_len=InDiskLen};
 
 flush_att(Fd, #att{data=Data}=Att) when is_binary(Data) ->
     with_stream(Fd, Att, fun(OutputStream) ->

Modified: couchdb/branches/1.0.x/test/etap/113-replication-attachment-comp.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/113-replication-attachment-comp.t?rev=1036380&r1=1036379&r2=1036380&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/113-replication-attachment-comp.t (original)
+++ couchdb/branches/1.0.x/test/etap/113-replication-attachment-comp.t Thu Nov 18 10:07:33
2010
@@ -30,7 +30,7 @@ test_db_b_name() ->
 
 main(_) ->
     test_util:init_code_path(),
-    etap:plan(30),
+    etap:plan(45),
     case (catch test()) of
         ok ->
             etap:end_tests();
@@ -102,6 +102,33 @@ test() ->
     check_server_can_decompress_att(test_db_b_name()),
     check_att_stubs(test_db_a_name(), test_db_b_name()),
 
+    %
+    % test local replication
+    %
+
+    delete_db(test_db_a_name()),
+    delete_db(test_db_b_name()),
+    create_db(test_db_a_name()),
+    create_db(test_db_b_name()),
+
+    % enable compression
+    couch_config:set("attachments", "compression_level", "8"),
+    couch_config:set("attachments", "compressible_types", "text/*"),
+
+    % store doc with text attachment in DB A
+    put_text_att(test_db_a_name()),
+
+    % disable attachment compression
+    couch_config:set("attachments", "compression_level", "0"),
+
+    % do local-local replication
+    do_local_replication(test_db_a_name(), test_db_b_name()),
+
+    % verify that DB B has the attachment stored in compressed form
+    check_att_is_compressed(test_db_b_name()),
+    check_server_can_decompress_att(test_db_b_name()),
+    check_att_stubs(test_db_a_name(), test_db_b_name()),
+
     timer:sleep(3000), % to avoid mochiweb socket closed exceptions
     delete_db(test_db_a_name()),
     delete_db(test_db_b_name()),
@@ -152,6 +179,23 @@ do_push_replication(SourceDbName, Target
     etap:is(RepOk, true, "Push replication completed with success"),
     ok.
 
+do_local_replication(SourceDbName, TargetDbName) ->
+    RepObj = {[
+        {<<"source">>, SourceDbName},
+        {<<"target">>, TargetDbName}
+    ]},
+    {ok, {{_, Code, _}, _Headers, Body}} = http:request(
+        post,
+        {rep_url(), [],
+        "application/json", list_to_binary(couch_util:json_encode(RepObj))},
+        [],
+        [{sync, true}]),
+    etap:is(Code, 200, "Local replication successfully triggered"),
+    Json = couch_util:json_decode(Body),
+    RepOk = couch_util:get_nested_json_value(Json, [<<"ok">>]),
+    etap:is(RepOk, true, "Local replication completed with success"),
+    ok.
+
 check_att_is_compressed(DbName) ->
     {ok, {{_, Code, _}, Headers, Body}} = http:request(
         get,



Mime
View raw message