http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/94ae4be2/test/couch_doc_json_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_doc_json_tests.erl b/test/couch_doc_json_tests.erl
index 64dea96..287a901 100644
--- a/test/couch_doc_json_tests.erl
+++ b/test/couch_doc_json_tests.erl
@@ -16,376 +16,376 @@
 -include_lib("couch/include/couch_db.hrl").
 
 
-setup() ->
-    {ok, Pid} = test_util:start_config(?CONFIG_CHAIN),
-    config:set("attachments", "compression_level", "0", false),
-    Pid.
+%% setup() ->
+%%     {ok, Pid} = test_util:start_config(?CONFIG_CHAIN),
+%%     config:set("attachments", "compression_level", "0", false),
+%%     Pid.
 
-teardown(_) ->
-    test_util:stop_config().
+%% teardown(_) ->
+%%     test_util:stop_config().
 
 
-json_doc_test_() ->
-    {
-        setup,
-        fun setup/0, fun teardown/1,
-        [
-            {
-                "Document from JSON",
-                [
-                    from_json_success_cases(),
-                    from_json_error_cases()
-                ]
-            },
-            {
-                "Document to JSON",
-                [
-                    to_json_success_cases()
-                ]
-            }
-        ]
-    }.
+%% json_doc_test_() ->
+%%     {
+%%         setup,
+%%         fun setup/0, fun teardown/1,
+%%         [
+%%             {
+%%                 "Document from JSON",
+%%                 [
+%%                     from_json_success_cases(),
+%%                     from_json_error_cases()
+%%                 ]
+%%             },
+%%             {
+%%                 "Document to JSON",
+%%                 [
+%%                     to_json_success_cases()
+%%                 ]
+%%             }
+%%         ]
+%%     }.
 
-from_json_success_cases() ->
-    Cases = [
-        {
-            {[]},
-            #doc{},
-            "Return an empty document for an empty JSON object."
-        },
-        {
-            {[{<<"_id">>, <<"zing!">>}]},
-            #doc{id = <<"zing!">>},
-            "Parses document ids."
-        },
-        {
-            {[{<<"_id">>, <<"_design/foo">>}]},
-            #doc{id = <<"_design/foo">>},
-            "_design/document ids."
-        },
-        {
-            {[{<<"_id">>, <<"_local/bam">>}]},
-            #doc{id = <<"_local/bam">>},
-            "_local/document ids."
-        },
-        {
-            {[{<<"_rev">>, <<"4-230234">>}]},
-            #doc{revs = {4, [<<"230234">>]}},
-            "_rev stored in revs."
-        },
-        {
-            {[{<<"soap">>, 35}]},
-            #doc{body = {[{<<"soap">>, 35}]}},
-            "Non underscore prefixed fields stored in body."
-        },
-        {
-            {[{<<"_attachments">>, {[
-                {<<"my_attachment.fu">>, {[
-                    {<<"stub">>, true},
-                    {<<"content_type">>, <<"application/awesome">>},
-                    {<<"length">>, 45}
-                ]}},
-                {<<"noahs_private_key.gpg">>, {[
-                    {<<"data">>, <<"SSBoYXZlIGEgcGV0IGZpc2gh">>},
-                    {<<"content_type">>, <<"application/pgp-signature">>}
-                ]}}
-            ]}}]},
-            #doc{atts = [
-                #att{
-                    name = <<"my_attachment.fu">>,
-                    data = stub,
-                    type = <<"application/awesome">>,
-                    att_len = 45,
-                    disk_len = 45,
-                    revpos = nil
-                },
-                #att{
-                    name = <<"noahs_private_key.gpg">>,
-                    data = <<"I have a pet fish!">>,
-                    type = <<"application/pgp-signature">>,
-                    att_len = 18,
-                    disk_len = 18,
-                    revpos = 0
-                }
-            ]},
-            "Attachments are parsed correctly."
-        },
-        {
-            {[{<<"_deleted">>, true}]},
-            #doc{deleted = true},
-            "_deleted controls the deleted field."
-        },
-        {
-            {[{<<"_deleted">>, false}]},
-            #doc{},
-            "{\"_deleted\": false} is ok."
-        },
-        {
-            {[
-                 {<<"_revisions">>,
-                  {[{<<"start">>, 4},
-                    {<<"ids">>, [<<"foo1">>, <<"phi3">>, <<"omega">>]}]}},
-                 {<<"_rev">>, <<"6-something">>}
-             ]},
-            #doc{revs = {4, [<<"foo1">>, <<"phi3">>, <<"omega">>]}},
-            "_revisions attribute are preferred to _rev."
-        },
-        {
-            {[{<<"_revs_info">>, dropping}]},
-            #doc{},
-            "Drops _revs_info."
-        },
-        {
-            {[{<<"_local_seq">>, dropping}]},
-            #doc{},
-            "Drops _local_seq."
-        },
-        {
-            {[{<<"_conflicts">>, dropping}]},
-            #doc{},
-            "Drops _conflicts."
-        },
-        {
-            {[{<<"_deleted_conflicts">>, dropping}]},
-            #doc{},
-            "Drops _deleted_conflicts."
-        }
-    ],
-    lists:map(
-        fun({EJson, Expect, Msg}) ->
-            {Msg, ?_assertMatch(Expect, couch_doc:from_json_obj(EJson))}
-        end,
-        Cases).
+%% from_json_success_cases() ->
+%%     Cases = [
+%%         {
+%%             {[]},
+%%             #doc{},
+%%             "Return an empty document for an empty JSON object."
+%%         },
+%%         {
+%%             {[{<<"_id">>, <<"zing!">>}]},
+%%             #doc{id = <<"zing!">>},
+%%             "Parses document ids."
+%%         },
+%%         {
+%%             {[{<<"_id">>, <<"_design/foo">>}]},
+%%             #doc{id = <<"_design/foo">>},
+%%             "_design/document ids."
+%%         },
+%%         {
+%%             {[{<<"_id">>, <<"_local/bam">>}]},
+%%             #doc{id = <<"_local/bam">>},
+%%             "_local/document ids."
+%%         },
+%%         {
+%%             {[{<<"_rev">>, <<"4-230234">>}]},
+%%             #doc{revs = {4, [<<"230234">>]}},
+%%             "_rev stored in revs."
+%%         },
+%%         {
+%%             {[{<<"soap">>, 35}]},
+%%             #doc{body = {[{<<"soap">>, 35}]}},
+%%             "Non underscore prefixed fields stored in body."
+%%         },
+%%         {
+%%             {[{<<"_attachments">>, {[
+%%                 {<<"my_attachment.fu">>, {[
+%%                     {<<"stub">>, true},
+%%                     {<<"content_type">>, <<"application/awesome">>},
+%%                     {<<"length">>, 45}
+%%                 ]}},
+%%                 {<<"noahs_private_key.gpg">>, {[
+%%                     {<<"data">>, <<"SSBoYXZlIGEgcGV0IGZpc2gh">>},
+%%                     {<<"content_type">>, <<"application/pgp-signature">>}
+%%                 ]}}
+%%             ]}}]},
+%%             #doc{atts = [
+%%                 #att{
+%%                     name = <<"my_attachment.fu">>,
+%%                     data = stub,
+%%                     type = <<"application/awesome">>,
+%%                     att_len = 45,
+%%                     disk_len = 45,
+%%                     revpos = nil
+%%                 },
+%%                 #att{
+%%                     name = <<"noahs_private_key.gpg">>,
+%%                     data = <<"I have a pet fish!">>,
+%%                     type = <<"application/pgp-signature">>,
+%%                     att_len = 18,
+%%                     disk_len = 18,
+%%                     revpos = 0
+%%                 }
+%%             ]},
+%%             "Attachments are parsed correctly."
+%%         },
+%%         {
+%%             {[{<<"_deleted">>, true}]},
+%%             #doc{deleted = true},
+%%             "_deleted controls the deleted field."
+%%         },
+%%         {
+%%             {[{<<"_deleted">>, false}]},
+%%             #doc{},
+%%             "{\"_deleted\": false} is ok."
+%%         },
+%%         {
+%%             {[
+%%                  {<<"_revisions">>,
+%%                   {[{<<"start">>, 4},
+%%                     {<<"ids">>, [<<"foo1">>, <<"phi3">>, <<"omega">>]}]}},
+%%                  {<<"_rev">>, <<"6-something">>}
+%%              ]},
+%%             #doc{revs = {4, [<<"foo1">>, <<"phi3">>, <<"omega">>]}},
+%%             "_revisions attribute are preferred to _rev."
+%%         },
+%%         {
+%%             {[{<<"_revs_info">>, dropping}]},
+%%             #doc{},
+%%             "Drops _revs_info."
+%%         },
+%%         {
+%%             {[{<<"_local_seq">>, dropping}]},
+%%             #doc{},
+%%             "Drops _local_seq."
+%%         },
+%%         {
+%%             {[{<<"_conflicts">>, dropping}]},
+%%             #doc{},
+%%             "Drops _conflicts."
+%%         },
+%%         {
+%%             {[{<<"_deleted_conflicts">>, dropping}]},
+%%             #doc{},
+%%             "Drops _deleted_conflicts."
+%%         }
+%%     ],
+%%     lists:map(
+%%         fun({EJson, Expect, Msg}) ->
+%%             {Msg, ?_assertMatch(Expect, couch_doc:from_json_obj(EJson))}
+%%         end,
+%%         Cases).
 
-from_json_error_cases() ->
-    Cases = [
-        {
-            [],
-            {bad_request, "Document must be a JSON object"},
-            "arrays are invalid"
-        },
-        {
-            4,
-            {bad_request, "Document must be a JSON object"},
-            "integers are invalid"
-        },
-        {
-            true,
-            {bad_request, "Document must be a JSON object"},
-            "literals are invalid"
-        },
-        {
-            {[{<<"_id">>, {[{<<"foo">>, 5}]}}]},
-            {bad_request, <<"Document id must be a string">>},
-            "Document id must be a string."
-        },
-        {
-            {[{<<"_id">>, <<"_random">>}]},
-            {bad_request,
-             <<"Only reserved document ids may start with underscore.">>},
-            "Disallow arbitrary underscore prefixed docids."
-        },
-        {
-            {[{<<"_rev">>, 5}]},
-            {bad_request, <<"Invalid rev format">>},
-            "_rev must be a string"
-        },
-        {
-            {[{<<"_rev">>, "foobar"}]},
-            {bad_request, <<"Invalid rev format">>},
-            "_rev must be %d-%s"
-        },
-        {
-            {[{<<"_rev">>, "foo-bar"}]},
-            "Error if _rev's integer expection is broken."
-        },
-        {
-            {[{<<"_revisions">>, {[{<<"start">>, true}]}}]},
-            {doc_validation, "_revisions.start isn't an integer."},
-            "_revisions.start must be an integer."
-        },
-        {
-            {[{<<"_revisions">>, {[{<<"start">>, 0}, {<<"ids">>, 5}]}}]},
-            {doc_validation, "_revisions.ids isn't a array."},
-            "_revions.ids must be a list."
-        },
-        {
-            {[{<<"_revisions">>, {[{<<"start">>, 0}, {<<"ids">>, [5]}]}}]},
-            {doc_validation, "RevId isn't a string"},
-            "Revision ids must be strings."
-        },
-        {
-            {[{<<"_something">>, 5}]},
-            {doc_validation, <<"Bad special document member: _something">>},
-            "Underscore prefix fields are reserved."
-        }
-    ],
+%% from_json_error_cases() ->
+%%     Cases = [
+%%         {
+%%             [],
+%%             {bad_request, "Document must be a JSON object"},
+%%             "arrays are invalid"
+%%         },
+%%         {
+%%             4,
+%%             {bad_request, "Document must be a JSON object"},
+%%             "integers are invalid"
+%%         },
+%%         {
+%%             true,
+%%             {bad_request, "Document must be a JSON object"},
+%%             "literals are invalid"
+%%         },
+%%         {
+%%             {[{<<"_id">>, {[{<<"foo">>, 5}]}}]},
+%%             {bad_request, <<"Document id must be a string">>},
+%%             "Document id must be a string."
+%%         },
+%%         {
+%%             {[{<<"_id">>, <<"_random">>}]},
+%%             {bad_request,
+%%              <<"Only reserved document ids may start with underscore.">>},
+%%             "Disallow arbitrary underscore prefixed docids."
+%%         },
+%%         {
+%%             {[{<<"_rev">>, 5}]},
+%%             {bad_request, <<"Invalid rev format">>},
+%%             "_rev must be a string"
+%%         },
+%%         {
+%%             {[{<<"_rev">>, "foobar"}]},
+%%             {bad_request, <<"Invalid rev format">>},
+%%             "_rev must be %d-%s"
+%%         },
+%%         {
+%%             {[{<<"_rev">>, "foo-bar"}]},
+%%             "Error if _rev's integer expection is broken."
+%%         },
+%%         {
+%%             {[{<<"_revisions">>, {[{<<"start">>, true}]}}]},
+%%             {doc_validation, "_revisions.start isn't an integer."},
+%%             "_revisions.start must be an integer."
+%%         },
+%%         {
+%%             {[{<<"_revisions">>, {[{<<"start">>, 0}, {<<"ids">>, 5}]}}]},
+%%             {doc_validation, "_revisions.ids isn't a array."},
+%%             "_revions.ids must be a list."
+%%         },
+%%         {
+%%             {[{<<"_revisions">>, {[{<<"start">>, 0}, {<<"ids">>, [5]}]}}]},
+%%             {doc_validation, "RevId isn't a string"},
+%%             "Revision ids must be strings."
+%%         },
+%%         {
+%%             {[{<<"_something">>, 5}]},
+%%             {doc_validation, <<"Bad special document member: _something">>},
+%%             "Underscore prefix fields are reserved."
+%%         }
+%%     ],
 
-    lists:map(fun
-        ({EJson, Expect, Msg}) ->
-            Error = (catch couch_doc:from_json_obj(EJson)),
-            {Msg, ?_assertMatch(Expect, Error)};
-        ({EJson, Msg}) ->
-            try
-                couch_doc:from_json_obj(EJson),
-                {"Conversion failed to raise an exception", ?_assert(false)}
-            catch
-                _:_ -> {Msg, ?_assert(true)}
-            end
-    end, Cases).
+%%     lists:map(fun
+%%         ({EJson, Expect, Msg}) ->
+%%             Error = (catch couch_doc:from_json_obj(EJson)),
+%%             {Msg, ?_assertMatch(Expect, Error)};
+%%         ({EJson, Msg}) ->
+%%             try
+%%                 couch_doc:from_json_obj(EJson),
+%%                 {"Conversion failed to raise an exception", ?_assert(false)}
+%%             catch
+%%                 _:_ -> {Msg, ?_assert(true)}
+%%             end
+%%     end, Cases).
 
-to_json_success_cases() ->
-    Cases = [
-        {
-            #doc{},
-            {[{<<"_id">>, <<"">>}]},
-            "Empty docs are {\"_id\": \"\"}"
-        },
-        {
-            #doc{id = <<"foo">>},
-            {[{<<"_id">>, <<"foo">>}]},
-            "_id is added."
-        },
-        {
-            #doc{revs = {5, ["foo"]}},
-            {[{<<"_id">>, <<>>}, {<<"_rev">>, <<"5-foo">>}]},
-            "_rev is added."
-        },
-        {
-            [revs],
-            #doc{revs = {5, [<<"first">>, <<"second">>]}},
-            {[
-                 {<<"_id">>, <<>>},
-                 {<<"_rev">>, <<"5-first">>},
-                 {<<"_revisions">>, {[
-                     {<<"start">>, 5},
-                     {<<"ids">>, [<<"first">>, <<"second">>]}
-                 ]}}
-             ]},
-            "_revisions include with revs option"
-        },
-        {
-            #doc{body = {[{<<"foo">>, <<"bar">>}]}},
-            {[{<<"_id">>, <<>>}, {<<"foo">>, <<"bar">>}]},
-            "Arbitrary fields are added."
-        },
-        {
-            #doc{deleted = true, body = {[{<<"foo">>, <<"bar">>}]}},
-            {[{<<"_id">>, <<>>}, {<<"foo">>, <<"bar">>}, {<<"_deleted">>, 
true}]},
-            "Deleted docs no longer drop body members."
-        },
-        {
-            #doc{meta = [
-                {revs_info, 4, [{<<"fin">>, deleted}, {<<"zim">>, missing}]}
-            ]},
-            {[
-                 {<<"_id">>, <<>>},
-                 {<<"_revs_info">>, [
-                     {[{<<"rev">>, <<"4-fin">>}, {<<"status">>, 
<<"deleted">>}]},
-                     {[{<<"rev">>, <<"3-zim">>}, {<<"status">>, 
<<"missing">>}]}
-                 ]}
-             ]},
-            "_revs_info field is added correctly."
-        },
-        {
-            #doc{meta = [{local_seq, 5}]},
-            {[{<<"_id">>, <<>>}, {<<"_local_seq">>, 5}]},
-            "_local_seq is added as an integer."
-        },
-        {
-            #doc{meta = [{conflicts, [{3, <<"yep">>}, {1, <<"snow">>}]}]},
-            {[
-                {<<"_id">>, <<>>},
-                {<<"_conflicts">>, [<<"3-yep">>, <<"1-snow">>]}
-            ]},
-            "_conflicts is added as an array of strings."
-        },
-        {
-            #doc{meta = [{deleted_conflicts, [{10923, 
<<"big_cowboy_hat">>}]}]},
-            {[
-                 {<<"_id">>, <<>>},
-                 {<<"_deleted_conflicts">>, [<<"10923-big_cowboy_hat">>]}
-             ]},
-            "_deleted_conflicsts is added as an array of strings."
-        },
-        {
-            #doc{atts = [
-                #att{
-                    name = <<"big.xml">>,
-                    type = <<"xml/sucks">>,
-                    data = fun() -> ok end,
-                    revpos = 1,
-                    att_len = 400,
-                    disk_len = 400
-                },
-                #att{
-                    name = <<"fast.json">>,
-                    type = <<"json/ftw">>,
-                    data = <<"{\"so\": \"there!\"}">>,
-                    revpos = 1,
-                    att_len = 16,
-                    disk_len = 16
-                }
-            ]},
-            {[
-                 {<<"_id">>, <<>>},
-                 {<<"_attachments">>, {[
-                       {<<"big.xml">>, {[
-                           {<<"content_type">>, <<"xml/sucks">>},
-                           {<<"revpos">>, 1},
-                           {<<"length">>, 400},
-                           {<<"stub">>, true}
-                       ]}},
-                       {<<"fast.json">>, {[
-                           {<<"content_type">>, <<"json/ftw">>},
-                           {<<"revpos">>, 1},
-                           {<<"length">>, 16},
-                           {<<"stub">>, true}
-                       ]}}
-                ]}}
-            ]},
-            "Attachments attached as stubs only include a length."
-        },
-        {
-            [attachments],
-            #doc{atts = [
-                #att{
-                    name = <<"stuff.txt">>,
-                    type = <<"text/plain">>,
-                    data = fun() -> <<"diet pepsi">> end,
-                    revpos = 1,
-                    att_len = 10,
-                    disk_len = 10
-                },
-                #att{
-                    name = <<"food.now">>,
-                    type = <<"application/food">>,
-                    revpos = 1,
-                    data = <<"sammich">>
-                }
-            ]},
-            {[
-                {<<"_id">>, <<>>},
-                {<<"_attachments">>, {[
-                   {<<"stuff.txt">>, {[
-                       {<<"content_type">>, <<"text/plain">>},
-                       {<<"revpos">>, 1},
-                       {<<"data">>, <<"ZGlldCBwZXBzaQ==">>}
-                   ]}},
-                   {<<"food.now">>, {[
-                       {<<"content_type">>, <<"application/food">>},
-                       {<<"revpos">>, 1},
-                       {<<"data">>, <<"c2FtbWljaA==">>}
-                   ]}}
-                ]}}
-            ]},
-            "Attachments included inline with attachments option."
-        }
-    ],
+%% to_json_success_cases() ->
+%%     Cases = [
+%%         {
+%%             #doc{},
+%%             {[{<<"_id">>, <<"">>}]},
+%%             "Empty docs are {\"_id\": \"\"}"
+%%         },
+%%         {
+%%             #doc{id = <<"foo">>},
+%%             {[{<<"_id">>, <<"foo">>}]},
+%%             "_id is added."
+%%         },
+%%         {
+%%             #doc{revs = {5, ["foo"]}},
+%%             {[{<<"_id">>, <<>>}, {<<"_rev">>, <<"5-foo">>}]},
+%%             "_rev is added."
+%%         },
+%%         {
+%%             [revs],
+%%             #doc{revs = {5, [<<"first">>, <<"second">>]}},
+%%             {[
+%%                  {<<"_id">>, <<>>},
+%%                  {<<"_rev">>, <<"5-first">>},
+%%                  {<<"_revisions">>, {[
+%%                      {<<"start">>, 5},
+%%                      {<<"ids">>, [<<"first">>, <<"second">>]}
+%%                  ]}}
+%%              ]},
+%%             "_revisions include with revs option"
+%%         },
+%%         {
+%%             #doc{body = {[{<<"foo">>, <<"bar">>}]}},
+%%             {[{<<"_id">>, <<>>}, {<<"foo">>, <<"bar">>}]},
+%%             "Arbitrary fields are added."
+%%         },
+%%         {
+%%             #doc{deleted = true, body = {[{<<"foo">>, <<"bar">>}]}},
+%%             {[{<<"_id">>, <<>>}, {<<"foo">>, <<"bar">>}, {<<"_deleted">>, 
true}]},
+%%             "Deleted docs no longer drop body members."
+%%         },
+%%         {
+%%             #doc{meta = [
+%%                 {revs_info, 4, [{<<"fin">>, deleted}, {<<"zim">>, missing}]}
+%%             ]},
+%%             {[
+%%                  {<<"_id">>, <<>>},
+%%                  {<<"_revs_info">>, [
+%%                      {[{<<"rev">>, <<"4-fin">>}, {<<"status">>, 
<<"deleted">>}]},
+%%                      {[{<<"rev">>, <<"3-zim">>}, {<<"status">>, 
<<"missing">>}]}
+%%                  ]}
+%%              ]},
+%%             "_revs_info field is added correctly."
+%%         },
+%%         {
+%%             #doc{meta = [{local_seq, 5}]},
+%%             {[{<<"_id">>, <<>>}, {<<"_local_seq">>, 5}]},
+%%             "_local_seq is added as an integer."
+%%         },
+%%         {
+%%             #doc{meta = [{conflicts, [{3, <<"yep">>}, {1, <<"snow">>}]}]},
+%%             {[
+%%                 {<<"_id">>, <<>>},
+%%                 {<<"_conflicts">>, [<<"3-yep">>, <<"1-snow">>]}
+%%             ]},
+%%             "_conflicts is added as an array of strings."
+%%         },
+%%         {
+%%             #doc{meta = [{deleted_conflicts, [{10923, 
<<"big_cowboy_hat">>}]}]},
+%%             {[
+%%                  {<<"_id">>, <<>>},
+%%                  {<<"_deleted_conflicts">>, [<<"10923-big_cowboy_hat">>]}
+%%              ]},
+%%             "_deleted_conflicsts is added as an array of strings."
+%%         },
+%%         {
+%%             #doc{atts = [
+%%                 #att{
+%%                     name = <<"big.xml">>,
+%%                     type = <<"xml/sucks">>,
+%%                     data = fun() -> ok end,
+%%                     revpos = 1,
+%%                     att_len = 400,
+%%                     disk_len = 400
+%%                 },
+%%                 #att{
+%%                     name = <<"fast.json">>,
+%%                     type = <<"json/ftw">>,
+%%                     data = <<"{\"so\": \"there!\"}">>,
+%%                     revpos = 1,
+%%                     att_len = 16,
+%%                     disk_len = 16
+%%                 }
+%%             ]},
+%%             {[
+%%                  {<<"_id">>, <<>>},
+%%                  {<<"_attachments">>, {[
+%%                        {<<"big.xml">>, {[
+%%                            {<<"content_type">>, <<"xml/sucks">>},
+%%                            {<<"revpos">>, 1},
+%%                            {<<"length">>, 400},
+%%                            {<<"stub">>, true}
+%%                        ]}},
+%%                        {<<"fast.json">>, {[
+%%                            {<<"content_type">>, <<"json/ftw">>},
+%%                            {<<"revpos">>, 1},
+%%                            {<<"length">>, 16},
+%%                            {<<"stub">>, true}
+%%                        ]}}
+%%                 ]}}
+%%             ]},
+%%             "Attachments attached as stubs only include a length."
+%%         },
+%%         {
+%%             [attachments],
+%%             #doc{atts = [
+%%                 #att{
+%%                     name = <<"stuff.txt">>,
+%%                     type = <<"text/plain">>,
+%%                     data = fun() -> <<"diet pepsi">> end,
+%%                     revpos = 1,
+%%                     att_len = 10,
+%%                     disk_len = 10
+%%                 },
+%%                 #att{
+%%                     name = <<"food.now">>,
+%%                     type = <<"application/food">>,
+%%                     revpos = 1,
+%%                     data = <<"sammich">>
+%%                 }
+%%             ]},
+%%             {[
+%%                 {<<"_id">>, <<>>},
+%%                 {<<"_attachments">>, {[
+%%                    {<<"stuff.txt">>, {[
+%%                        {<<"content_type">>, <<"text/plain">>},
+%%                        {<<"revpos">>, 1},
+%%                        {<<"data">>, <<"ZGlldCBwZXBzaQ==">>}
+%%                    ]}},
+%%                    {<<"food.now">>, {[
+%%                        {<<"content_type">>, <<"application/food">>},
+%%                        {<<"revpos">>, 1},
+%%                        {<<"data">>, <<"c2FtbWljaA==">>}
+%%                    ]}}
+%%                 ]}}
+%%             ]},
+%%             "Attachments included inline with attachments option."
+%%         }
+%%     ],
 
-    lists:map(fun
-        ({Doc, EJson, Msg}) ->
-            {Msg, ?_assertMatch(EJson, couch_doc:to_json_obj(Doc, []))};
-        ({Options, Doc, EJson, Msg}) ->
-            {Msg, ?_assertMatch(EJson, couch_doc:to_json_obj(Doc, Options))}
-    end, Cases).
+%%     lists:map(fun
+%%         ({Doc, EJson, Msg}) ->
+%%             {Msg, ?_assertMatch(EJson, couch_doc:to_json_obj(Doc, []))};
+%%         ({Options, Doc, EJson, Msg}) ->
+%%             {Msg, ?_assertMatch(EJson, couch_doc:to_json_obj(Doc, Options))}
+%%     end, Cases).

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/94ae4be2/test/couch_stats_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_stats_tests.erl b/test/couch_stats_tests.erl
index d62afaf..dfb3d0b 100644
--- a/test/couch_stats_tests.erl
+++ b/test/couch_stats_tests.erl
@@ -23,390 +23,390 @@
 -define(TIMEWAIT, 500).
 
 
-setup_collector() ->
-    couch_stats_collector:start(),
-    ok.
-
-setup_aggregator(_) ->
-    {ok, Pid} = config:start_link([?STATS_INI_FIXTURE]),
-    {ok, _} = couch_stats_collector:start(),
-    {ok, _} = couch_stats_aggregator:start(?STATS_CFG_FIXTURE),
-    Pid.
-
-teardown_collector(_) ->
-    couch_stats_collector:stop(),
-    ok.
-
-teardown_aggregator(_, Pid) ->
-    couch_stats_aggregator:stop(),
-    couch_stats_collector:stop(),
-    erlang:monitor(process, Pid),
-    config:stop(),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, config_stop})
-    end,
-    ok.
-
-
-couch_stats_collector_test_() ->
-    {
-        "CouchDB stats collector tests",
-        {
-            foreach,
-            fun setup_collector/0, fun teardown_collector/1,
-            [
-                should_increment_counter(),
-                should_decrement_counter(),
-                should_increment_and_decrement_counter(),
-                should_record_absolute_values(),
-                should_clear_absolute_values(),
-                should_track_process_count(),
-                should_increment_counter_multiple_times_per_pid(),
-                should_decrement_counter_on_process_exit(),
-                should_decrement_for_each_track_process_count_call_on_exit(),
-                should_return_all_counters_and_absolute_values(),
-                should_return_incremental_counters(),
-                should_return_absolute_values()
-            ]
-        }
-    }.
-
-couch_stats_aggregator_test_() ->
-    Funs = [
-        fun should_init_empty_aggregate/2,
-        fun should_get_empty_aggregate/2,
-        fun should_change_stats_on_values_add/2,
-        fun should_change_stats_for_all_times_on_values_add/2,
-        fun should_change_stats_on_values_change/2,
-        fun should_change_stats_for_all_times_on_values_change/2,
-        fun should_not_remove_data_after_some_time_for_0_sample/2,
-        fun should_remove_data_after_some_time_for_other_samples/2
-    ],
-    {
-        "CouchDB stats aggregator tests",
-        [
-            {
-                "Absolute values",
-                {
-                    foreachx,
-                    fun setup_aggregator/1, fun teardown_aggregator/2,
-                    [{absolute, Fun} || Fun <- Funs]
-                }
-            },
-            {
-                "Counters",
-                {
-                    foreachx,
-                    fun setup_aggregator/1, fun teardown_aggregator/2,
-                    [{counter, Fun} || Fun <- Funs]
-                }
-            }
-        ]
-    }.
-
-
-should_increment_counter() ->
-    ?_assertEqual(100,
-        begin
-            AddCount = fun() -> couch_stats_collector:increment(foo) end,
-            repeat(AddCount, 100),
-            couch_stats_collector:get(foo)
-        end).
-
-should_decrement_counter() ->
-    ?_assertEqual(67,
-        begin
-            AddCount = fun() -> couch_stats_collector:increment(foo) end,
-            RemCount = fun() -> couch_stats_collector:decrement(foo) end,
-            repeat(AddCount, 100),
-            repeat(RemCount, 33),
-            couch_stats_collector:get(foo)
-        end).
-
-should_increment_and_decrement_counter() ->
-    ?_assertEqual(0,
-        begin
-            AddCount = fun() -> couch_stats_collector:increment(foo) end,
-            RemCount = fun() -> couch_stats_collector:decrement(foo) end,
-            repeat(AddCount, 100),
-            repeat(RemCount, 25),
-            repeat(AddCount, 10),
-            repeat(RemCount, 5),
-            repeat(RemCount, 80),
-            couch_stats_collector:get(foo)
-        end).
-
-should_record_absolute_values() ->
-    ?_assertEqual(lists:seq(1, 15),
-        begin
-            lists:map(fun(Val) ->
-                couch_stats_collector:record(bar, Val)
-            end, lists:seq(1, 15)),
-            couch_stats_collector:get(bar)
-        end).
-
-should_clear_absolute_values() ->
-    ?_assertEqual(nil,
-        begin
-            lists:map(fun(Val) ->
-                couch_stats_collector:record(bar, Val)
-            end, lists:seq(1, 15)),
-            couch_stats_collector:clear(bar),
-            couch_stats_collector:get(bar)
-        end).
-
-should_track_process_count() ->
-    ?_assertMatch({_, 1}, spawn_and_count(1)).
-
-should_increment_counter_multiple_times_per_pid() ->
-    ?_assertMatch({_, 3}, spawn_and_count(3)).
-
-should_decrement_counter_on_process_exit() ->
-    ?_assertEqual(2,
-        begin
-            {Pid, 1} = spawn_and_count(1),
-            spawn_and_count(2),
-            RefMon = erlang:monitor(process, Pid),
-            Pid ! sepuku,
-            receive
-                {'DOWN', RefMon, _, _, _} -> ok
-            after ?TIMEOUT ->
-                throw(timeout)
-            end,
-            % sleep for awhile to let collector handle the updates
-            % suddenly, it couldn't notice process death instantly
-            timer:sleep(?TIMEWAIT),
-            couch_stats_collector:get(hoopla)
-        end).
-
-should_decrement_for_each_track_process_count_call_on_exit() ->
-    ?_assertEqual(2,
-        begin
-            {_, 2} = spawn_and_count(2),
-            {Pid, 6} = spawn_and_count(4),
-            RefMon = erlang:monitor(process, Pid),
-            Pid ! sepuku,
-            receive
-                {'DOWN', RefMon, _, _, _} -> ok
-            after ?TIMEOUT ->
-                throw(timeout)
-            end,
-            timer:sleep(?TIMEWAIT),
-            couch_stats_collector:get(hoopla)
-        end).
-
-should_return_all_counters_and_absolute_values() ->
-    ?_assertEqual([{bar,[1.0,0.0]}, {foo,1}],
-        begin
-            couch_stats_collector:record(bar, 0.0),
-            couch_stats_collector:record(bar, 1.0),
-            couch_stats_collector:increment(foo),
-            lists:sort(couch_stats_collector:all())
-        end).
-
-should_return_incremental_counters() ->
-    ?_assertEqual([{foo,1}],
-        begin
-            couch_stats_collector:record(bar, 0.0),
-            couch_stats_collector:record(bar, 1.0),
-            couch_stats_collector:increment(foo),
-            lists:sort(couch_stats_collector:all(incremental))
-        end).
-
-should_return_absolute_values() ->
-    ?_assertEqual([{bar,[1.0,0.0]}, {zing, "Z"}],
-        begin
-            couch_stats_collector:record(bar, 0.0),
-            couch_stats_collector:record(bar, 1.0),
-            couch_stats_collector:record(zing, 90),
-            couch_stats_collector:increment(foo),
-            lists:sort(couch_stats_collector:all(absolute))
-        end).
-
-should_init_empty_aggregate(absolute, _) ->
-    {Aggs} = couch_stats_aggregator:all(),
-    ?_assertEqual({[{'11', make_agg(<<"randomosity">>,
-                                    null, null, null, null, null)}]},
-                  couch_util:get_value(number, Aggs));
-should_init_empty_aggregate(counter, _) ->
-    {Aggs} = couch_stats_aggregator:all(),
-    ?_assertEqual({[{stuff, make_agg(<<"yay description">>,
-                                     null, null, null, null, null)}]},
-                  couch_util:get_value(testing, Aggs)).
-
-should_get_empty_aggregate(absolute, _) ->
-    ?_assertEqual(make_agg(<<"randomosity">>, null, null, null, null, null),
-             couch_stats_aggregator:get_json({number, '11'}));
-should_get_empty_aggregate(counter, _) ->
-    ?_assertEqual(make_agg(<<"yay description">>, null, null, null, null, 
null),
-             couch_stats_aggregator:get_json({testing, stuff})).
-
-should_change_stats_on_values_add(absolute, _) ->
-    lists:foreach(fun(X) ->
-        couch_stats_collector:record({number, 11}, X)
-    end, lists:seq(0, 10)),
-    couch_stats_aggregator:collect_sample(),
-    ?_assertEqual(make_agg(<<"randomosity">>, 5.0, 5.0, null, 5.0, 5.0),
-                  couch_stats_aggregator:get_json({number, 11}));
-should_change_stats_on_values_add(counter, _) ->
-    lists:foreach(fun(_) ->
-        couch_stats_collector:increment({testing, stuff})
-    end, lists:seq(1, 100)),
-    couch_stats_aggregator:collect_sample(),
-    ?_assertEqual(make_agg(<<"yay description">>, 100.0, 100.0, null, 100, 
100),
-                  couch_stats_aggregator:get_json({testing, stuff})).
-
-should_change_stats_for_all_times_on_values_add(absolute, _) ->
-    lists:foreach(fun(X) ->
-        couch_stats_collector:record({number, 11}, X)
-    end, lists:seq(0, 10)),
-    couch_stats_aggregator:collect_sample(),
-    ?_assertEqual(make_agg(<<"randomosity">>, 5.0, 5.0, null, 5.0, 5.0),
-                  couch_stats_aggregator:get_json({number, 11}, 1));
-should_change_stats_for_all_times_on_values_add(counter, _) ->
-    lists:foreach(fun(_) ->
-        couch_stats_collector:increment({testing, stuff})
-    end, lists:seq(1, 100)),
-    couch_stats_aggregator:collect_sample(),
-    ?_assertEqual(make_agg(<<"yay description">>, 100.0, 100.0, null, 100, 
100),
-                  couch_stats_aggregator:get_json({testing, stuff}, 1)).
-
-should_change_stats_on_values_change(absolute, _) ->
-    ?_assertEqual(make_agg(<<"randomosity">>, 20.0, 10.0, 7.071, 5.0, 15.0),
-        begin
-            lists:foreach(fun(X) ->
-                couch_stats_collector:record({number, 11}, X)
-            end, lists:seq(0, 10)),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_collector:record({number, 11}, 15),
-            couch_stats_aggregator:collect_sample(),
-            couch_stats_aggregator:get_json({number, 11})
-        end);
-should_change_stats_on_values_change(counter, _) ->
-    ?_assertEqual(make_agg(<<"yay description">>, 100.0, 50.0, 70.711, 0, 100),
-        begin
-            lists:foreach(fun(_) ->
-                couch_stats_collector:increment({testing, stuff})
-            end, lists:seq(1, 100)),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_aggregator:collect_sample(),
-            couch_stats_aggregator:get_json({testing, stuff})
-        end).
-
-should_change_stats_for_all_times_on_values_change(absolute, _) ->
-    ?_assertEqual(make_agg(<<"randomosity">>, 20.0, 10.0, 7.071, 5.0, 15.0),
-        begin
-            lists:foreach(fun(X) ->
-                couch_stats_collector:record({number, 11}, X)
-            end, lists:seq(0, 10)),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_collector:record({number, 11}, 15),
-            couch_stats_aggregator:collect_sample(),
-            couch_stats_aggregator:get_json({number, 11}, 1)
-        end);
-should_change_stats_for_all_times_on_values_change(counter, _) ->
-    ?_assertEqual(make_agg(<<"yay description">>, 100.0, 50.0, 70.711, 0, 100),
-        begin
-            lists:foreach(fun(_) ->
-                couch_stats_collector:increment({testing, stuff})
-            end, lists:seq(1, 100)),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_aggregator:collect_sample(),
-            couch_stats_aggregator:get_json({testing, stuff}, 1)
-        end).
-
-should_not_remove_data_after_some_time_for_0_sample(absolute, _) ->
-    ?_assertEqual(make_agg(<<"randomosity">>, 20.0, 10.0, 7.071, 5.0, 15.0),
-        begin
-            lists:foreach(fun(X) ->
-                couch_stats_collector:record({number, 11}, X)
-            end, lists:seq(0, 10)),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_collector:record({number, 11}, 15),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_aggregator:collect_sample(),
-            couch_stats_aggregator:get_json({number, 11})
-        end);
-should_not_remove_data_after_some_time_for_0_sample(counter, _) ->
-    ?_assertEqual(make_agg(<<"yay description">>, 100.0, 33.333, 57.735, 0, 
100),
-        begin
-            lists:foreach(fun(_) ->
-                couch_stats_collector:increment({testing, stuff})
-            end, lists:seq(1, 100)),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_aggregator:collect_sample(),
-            couch_stats_aggregator:get_json({testing, stuff})
-        end).
-
-should_remove_data_after_some_time_for_other_samples(absolute, _) ->
-    ?_assertEqual(make_agg(<<"randomosity">>, 15.0, 15.0, null, 15.0, 15.0),
-        begin
-            lists:foreach(fun(X) ->
-                couch_stats_collector:record({number, 11}, X)
-            end, lists:seq(0, 10)),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_collector:record({number, 11}, 15),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_aggregator:collect_sample(),
-            couch_stats_aggregator:get_json({number, 11}, 1)
-        end);
-should_remove_data_after_some_time_for_other_samples(counter, _) ->
-    ?_assertEqual(make_agg(<<"yay description">>, 0, 0.0, 0.0, 0, 0),
-        begin
-            lists:foreach(fun(_) ->
-                couch_stats_collector:increment({testing, stuff})
-            end, lists:seq(1, 100)),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_aggregator:collect_sample(),
-            timer:sleep(?TIMEWAIT),
-            couch_stats_aggregator:collect_sample(),
-            couch_stats_aggregator:get_json({testing, stuff}, 1)
-        end).
-
-
-spawn_and_count(N) ->
-    Self = self(),
-    Pid = spawn(fun() ->
-        lists:foreach(
-            fun(_) ->
-                couch_stats_collector:track_process_count(hoopla)
-            end, lists:seq(1,N)),
-        Self ! reporting,
-        receive
-            sepuku -> ok
-        end
-    end),
-    receive reporting -> ok end,
-    {Pid, couch_stats_collector:get(hoopla)}.
-
-repeat(_, 0) ->
-    ok;
-repeat(Fun, Count) ->
-    Fun(),
-    repeat(Fun, Count-1).
-
-make_agg(Desc, Sum, Mean, StdDev, Min, Max) ->
-    {[
-        {description, Desc},
-        {current, Sum},
-        {sum, Sum},
-        {mean, Mean},
-        {stddev, StdDev},
-        {min, Min},
-        {max, Max}
-    ]}.
+%% setup_collector() ->
+%%     couch_stats_collector:start(),
+%%     ok.
+
+%% setup_aggregator(_) ->
+%%     {ok, Pid} = test_util:start_config([?STATS_INI_FIXTURE]),
+%%     {ok, _} = couch_stats_collector:start(),
+%%     {ok, _} = couch_stats_aggregator:start(?STATS_CFG_FIXTURE),
+%%     Pid.
+
+%% teardown_collector(_) ->
+%%     couch_stats_collector:stop(),
+%%     ok.
+
+%% teardown_aggregator(_, Pid) ->
+%%     couch_stats_aggregator:stop(),
+%%     couch_stats_collector:stop(),
+%%     erlang:monitor(process, Pid),
+%%     config:stop(),
+%%     receive
+%%         {'DOWN', _, _, Pid, _} ->
+%%             ok
+%%     after ?TIMEOUT ->
+%%         throw({timeout, config_stop})
+%%     end,
+%%     ok.
+
+
+%% couch_stats_collector_test_() ->
+%%     {
+%%         "CouchDB stats collector tests",
+%%         {
+%%             foreach,
+%%             fun setup_collector/0, fun teardown_collector/1,
+%%             [
+%%                 should_increment_counter(),
+%%                 should_decrement_counter(),
+%%                 should_increment_and_decrement_counter(),
+%%                 should_record_absolute_values(),
+%%                 should_clear_absolute_values(),
+%%                 should_track_process_count(),
+%%                 should_increment_counter_multiple_times_per_pid(),
+%%                 should_decrement_counter_on_process_exit(),
+%%                 
should_decrement_for_each_track_process_count_call_on_exit(),
+%%                 should_return_all_counters_and_absolute_values(),
+%%                 should_return_incremental_counters(),
+%%                 should_return_absolute_values()
+%%             ]
+%%         }
+%%     }.
+
+%% couch_stats_aggregator_test_() ->
+%%     Funs = [
+%%         fun should_init_empty_aggregate/2,
+%%         fun should_get_empty_aggregate/2,
+%%         fun should_change_stats_on_values_add/2,
+%%         fun should_change_stats_for_all_times_on_values_add/2,
+%%         fun should_change_stats_on_values_change/2,
+%%         fun should_change_stats_for_all_times_on_values_change/2,
+%%         fun should_not_remove_data_after_some_time_for_0_sample/2,
+%%         fun should_remove_data_after_some_time_for_other_samples/2
+%%     ],
+%%     {
+%%         "CouchDB stats aggregator tests",
+%%         [
+%%             {
+%%                 "Absolute values",
+%%                 {
+%%                     foreachx,
+%%                     fun setup_aggregator/1, fun teardown_aggregator/2,
+%%                     [{absolute, Fun} || Fun <- Funs]
+%%                 }
+%%             },
+%%             {
+%%                 "Counters",
+%%                 {
+%%                     foreachx,
+%%                     fun setup_aggregator/1, fun teardown_aggregator/2,
+%%                     [{counter, Fun} || Fun <- Funs]
+%%                 }
+%%             }
+%%         ]
+%%     }.
+
+
+%% should_increment_counter() ->
+%%     ?_assertEqual(100,
+%%         begin
+%%             AddCount = fun() -> couch_stats_collector:increment(foo) end,
+%%             repeat(AddCount, 100),
+%%             couch_stats_collector:get(foo)
+%%         end).
+
+%% should_decrement_counter() ->
+%%     ?_assertEqual(67,
+%%         begin
+%%             AddCount = fun() -> couch_stats_collector:increment(foo) end,
+%%             RemCount = fun() -> couch_stats_collector:decrement(foo) end,
+%%             repeat(AddCount, 100),
+%%             repeat(RemCount, 33),
+%%             couch_stats_collector:get(foo)
+%%         end).
+
+%% should_increment_and_decrement_counter() ->
+%%     ?_assertEqual(0,
+%%         begin
+%%             AddCount = fun() -> couch_stats_collector:increment(foo) end,
+%%             RemCount = fun() -> couch_stats_collector:decrement(foo) end,
+%%             repeat(AddCount, 100),
+%%             repeat(RemCount, 25),
+%%             repeat(AddCount, 10),
+%%             repeat(RemCount, 5),
+%%             repeat(RemCount, 80),
+%%             couch_stats_collector:get(foo)
+%%         end).
+
+%% should_record_absolute_values() ->
+%%     ?_assertEqual(lists:seq(1, 15),
+%%         begin
+%%             lists:map(fun(Val) ->
+%%                 couch_stats_collector:record(bar, Val)
+%%             end, lists:seq(1, 15)),
+%%             couch_stats_collector:get(bar)
+%%         end).
+
+%% should_clear_absolute_values() ->
+%%     ?_assertEqual(nil,
+%%         begin
+%%             lists:map(fun(Val) ->
+%%                 couch_stats_collector:record(bar, Val)
+%%             end, lists:seq(1, 15)),
+%%             couch_stats_collector:clear(bar),
+%%             couch_stats_collector:get(bar)
+%%         end).
+
+%% should_track_process_count() ->
+%%     ?_assertMatch({_, 1}, spawn_and_count(1)).
+
+%% should_increment_counter_multiple_times_per_pid() ->
+%%     ?_assertMatch({_, 3}, spawn_and_count(3)).
+
+%% should_decrement_counter_on_process_exit() ->
+%%     ?_assertEqual(2,
+%%         begin
+%%             {Pid, 1} = spawn_and_count(1),
+%%             spawn_and_count(2),
+%%             RefMon = erlang:monitor(process, Pid),
+%%             Pid ! sepuku,
+%%             receive
+%%                 {'DOWN', RefMon, _, _, _} -> ok
+%%             after ?TIMEOUT ->
+%%                 throw(timeout)
+%%             end,
+%%             % sleep for awhile to let collector handle the updates
+%%             % suddenly, it couldn't notice process death instantly
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_collector:get(hoopla)
+%%         end).
+
+%% should_decrement_for_each_track_process_count_call_on_exit() ->
+%%     ?_assertEqual(2,
+%%         begin
+%%             {_, 2} = spawn_and_count(2),
+%%             {Pid, 6} = spawn_and_count(4),
+%%             RefMon = erlang:monitor(process, Pid),
+%%             Pid ! sepuku,
+%%             receive
+%%                 {'DOWN', RefMon, _, _, _} -> ok
+%%             after ?TIMEOUT ->
+%%                 throw(timeout)
+%%             end,
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_collector:get(hoopla)
+%%         end).
+
+%% should_return_all_counters_and_absolute_values() ->
+%%     ?_assertEqual([{bar,[1.0,0.0]}, {foo,1}],
+%%         begin
+%%             couch_stats_collector:record(bar, 0.0),
+%%             couch_stats_collector:record(bar, 1.0),
+%%             couch_stats_collector:increment(foo),
+%%             lists:sort(couch_stats_collector:all())
+%%         end).
+
+%% should_return_incremental_counters() ->
+%%     ?_assertEqual([{foo,1}],
+%%         begin
+%%             couch_stats_collector:record(bar, 0.0),
+%%             couch_stats_collector:record(bar, 1.0),
+%%             couch_stats_collector:increment(foo),
+%%             lists:sort(couch_stats_collector:all(incremental))
+%%         end).
+
+%% should_return_absolute_values() ->
+%%     ?_assertEqual([{bar,[1.0,0.0]}, {zing, "Z"}],
+%%         begin
+%%             couch_stats_collector:record(bar, 0.0),
+%%             couch_stats_collector:record(bar, 1.0),
+%%             couch_stats_collector:record(zing, 90),
+%%             couch_stats_collector:increment(foo),
+%%             lists:sort(couch_stats_collector:all(absolute))
+%%         end).
+
+%% should_init_empty_aggregate(absolute, _) ->
+%%     {Aggs} = couch_stats_aggregator:all(),
+%%     ?_assertEqual({[{'11', make_agg(<<"randomosity">>,
+%%                                     null, null, null, null, null)}]},
+%%                   couch_util:get_value(number, Aggs));
+%% should_init_empty_aggregate(counter, _) ->
+%%     {Aggs} = couch_stats_aggregator:all(),
+%%     ?_assertEqual({[{stuff, make_agg(<<"yay description">>,
+%%                                      null, null, null, null, null)}]},
+%%                   couch_util:get_value(testing, Aggs)).
+
+%% should_get_empty_aggregate(absolute, _) ->
+%%     ?_assertEqual(make_agg(<<"randomosity">>, null, null, null, null, null),
+%%              couch_stats_aggregator:get_json({number, '11'}));
+%% should_get_empty_aggregate(counter, _) ->
+%%     ?_assertEqual(make_agg(<<"yay description">>, null, null, null, null, 
null),
+%%              couch_stats_aggregator:get_json({testing, stuff})).
+
+%% should_change_stats_on_values_add(absolute, _) ->
+%%     lists:foreach(fun(X) ->
+%%         couch_stats_collector:record({number, 11}, X)
+%%     end, lists:seq(0, 10)),
+%%     couch_stats_aggregator:collect_sample(),
+%%     ?_assertEqual(make_agg(<<"randomosity">>, 5.0, 5.0, null, 5.0, 5.0),
+%%                   couch_stats_aggregator:get_json({number, 11}));
+%% should_change_stats_on_values_add(counter, _) ->
+%%     lists:foreach(fun(_) ->
+%%         couch_stats_collector:increment({testing, stuff})
+%%     end, lists:seq(1, 100)),
+%%     couch_stats_aggregator:collect_sample(),
+%%     ?_assertEqual(make_agg(<<"yay description">>, 100.0, 100.0, null, 100, 
100),
+%%                   couch_stats_aggregator:get_json({testing, stuff})).
+
+%% should_change_stats_for_all_times_on_values_add(absolute, _) ->
+%%     lists:foreach(fun(X) ->
+%%         couch_stats_collector:record({number, 11}, X)
+%%     end, lists:seq(0, 10)),
+%%     couch_stats_aggregator:collect_sample(),
+%%     ?_assertEqual(make_agg(<<"randomosity">>, 5.0, 5.0, null, 5.0, 5.0),
+%%                   couch_stats_aggregator:get_json({number, 11}, 1));
+%% should_change_stats_for_all_times_on_values_add(counter, _) ->
+%%     lists:foreach(fun(_) ->
+%%         couch_stats_collector:increment({testing, stuff})
+%%     end, lists:seq(1, 100)),
+%%     couch_stats_aggregator:collect_sample(),
+%%     ?_assertEqual(make_agg(<<"yay description">>, 100.0, 100.0, null, 100, 
100),
+%%                   couch_stats_aggregator:get_json({testing, stuff}, 1)).
+
+%% should_change_stats_on_values_change(absolute, _) ->
+%%     ?_assertEqual(make_agg(<<"randomosity">>, 20.0, 10.0, 7.071, 5.0, 15.0),
+%%         begin
+%%             lists:foreach(fun(X) ->
+%%                 couch_stats_collector:record({number, 11}, X)
+%%             end, lists:seq(0, 10)),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_collector:record({number, 11}, 15),
+%%             couch_stats_aggregator:collect_sample(),
+%%             couch_stats_aggregator:get_json({number, 11})
+%%         end);
+%% should_change_stats_on_values_change(counter, _) ->
+%%     ?_assertEqual(make_agg(<<"yay description">>, 100.0, 50.0, 70.711, 0, 
100),
+%%         begin
+%%             lists:foreach(fun(_) ->
+%%                 couch_stats_collector:increment({testing, stuff})
+%%             end, lists:seq(1, 100)),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_aggregator:collect_sample(),
+%%             couch_stats_aggregator:get_json({testing, stuff})
+%%         end).
+
+%% should_change_stats_for_all_times_on_values_change(absolute, _) ->
+%%     ?_assertEqual(make_agg(<<"randomosity">>, 20.0, 10.0, 7.071, 5.0, 15.0),
+%%         begin
+%%             lists:foreach(fun(X) ->
+%%                 couch_stats_collector:record({number, 11}, X)
+%%             end, lists:seq(0, 10)),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_collector:record({number, 11}, 15),
+%%             couch_stats_aggregator:collect_sample(),
+%%             couch_stats_aggregator:get_json({number, 11}, 1)
+%%         end);
+%% should_change_stats_for_all_times_on_values_change(counter, _) ->
+%%     ?_assertEqual(make_agg(<<"yay description">>, 100.0, 50.0, 70.711, 0, 
100),
+%%         begin
+%%             lists:foreach(fun(_) ->
+%%                 couch_stats_collector:increment({testing, stuff})
+%%             end, lists:seq(1, 100)),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_aggregator:collect_sample(),
+%%             couch_stats_aggregator:get_json({testing, stuff}, 1)
+%%         end).
+
+%% should_not_remove_data_after_some_time_for_0_sample(absolute, _) ->
+%%     ?_assertEqual(make_agg(<<"randomosity">>, 20.0, 10.0, 7.071, 5.0, 15.0),
+%%         begin
+%%             lists:foreach(fun(X) ->
+%%                 couch_stats_collector:record({number, 11}, X)
+%%             end, lists:seq(0, 10)),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_collector:record({number, 11}, 15),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_aggregator:collect_sample(),
+%%             couch_stats_aggregator:get_json({number, 11})
+%%         end);
+%% should_not_remove_data_after_some_time_for_0_sample(counter, _) ->
+%%     ?_assertEqual(make_agg(<<"yay description">>, 100.0, 33.333, 57.735, 0, 
100),
+%%         begin
+%%             lists:foreach(fun(_) ->
+%%                 couch_stats_collector:increment({testing, stuff})
+%%             end, lists:seq(1, 100)),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_aggregator:collect_sample(),
+%%             couch_stats_aggregator:get_json({testing, stuff})
+%%         end).
+
+%% should_remove_data_after_some_time_for_other_samples(absolute, _) ->
+%%     ?_assertEqual(make_agg(<<"randomosity">>, 15.0, 15.0, null, 15.0, 15.0),
+%%         begin
+%%             lists:foreach(fun(X) ->
+%%                 couch_stats_collector:record({number, 11}, X)
+%%             end, lists:seq(0, 10)),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_collector:record({number, 11}, 15),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_aggregator:collect_sample(),
+%%             couch_stats_aggregator:get_json({number, 11}, 1)
+%%         end);
+%% should_remove_data_after_some_time_for_other_samples(counter, _) ->
+%%     ?_assertEqual(make_agg(<<"yay description">>, 0, 0.0, 0.0, 0, 0),
+%%         begin
+%%             lists:foreach(fun(_) ->
+%%                 couch_stats_collector:increment({testing, stuff})
+%%             end, lists:seq(1, 100)),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_aggregator:collect_sample(),
+%%             timer:sleep(?TIMEWAIT),
+%%             couch_stats_aggregator:collect_sample(),
+%%             couch_stats_aggregator:get_json({testing, stuff}, 1)
+%%         end).
+
+
+%% spawn_and_count(N) ->
+%%     Self = self(),
+%%     Pid = spawn(fun() ->
+%%         lists:foreach(
+%%             fun(_) ->
+%%                 couch_stats_collector:track_process_count(hoopla)
+%%             end, lists:seq(1,N)),
+%%         Self ! reporting,
+%%         receive
+%%             sepuku -> ok
+%%         end
+%%     end),
+%%     receive reporting -> ok end,
+%%     {Pid, couch_stats_collector:get(hoopla)}.
+
+%% repeat(_, 0) ->
+%%     ok;
+%% repeat(Fun, Count) ->
+%%     Fun(),
+%%     repeat(Fun, Count-1).
+
+%% make_agg(Desc, Sum, Mean, StdDev, Min, Max) ->
+%%     {[
+%%         {description, Desc},
+%%         {current, Sum},
+%%         {sum, Sum},
+%%         {mean, Mean},
+%%         {stddev, StdDev},
+%%         {min, Min},
+%%         {max, Max}
+%%     ]}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/94ae4be2/test/couch_uuids_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_uuids_tests.erl b/test/couch_uuids_tests.erl
index 27c5cb8..8eb378f 100644
--- a/test/couch_uuids_tests.erl
+++ b/test/couch_uuids_tests.erl
@@ -17,145 +17,146 @@
 -define(TIMEOUT_S, 20).
 
 
-setup() ->
-    {ok, Pid} = config:start_link(?CONFIG_CHAIN),
-    erlang:monitor(process, Pid),
-    couch_uuids:start(),
-    Pid.
-
-setup(Opts) ->
-    Pid = setup(),
-    lists:foreach(
-        fun({Option, Value}) ->
-            config:set("uuids", Option, Value, false)
-        end, Opts),
-    Pid.
-
-teardown(Pid) ->
-    couch_uuids:stop(),
-    config:stop(),
-    receive
-        {'DOWN', _, _, Pid, _} -> ok
-    after
-        1000 -> throw({timeout_error, config_stop})
-    end.
-
-teardown(_, Pid) ->
-    teardown(Pid).
-
-
-default_test_() ->
-    {
-        "Default UUID algorithm",
-        {
-            setup,
-            fun setup/0, fun teardown/1,
-            fun should_be_unique/1
-        }
-    }.
-
-sequential_test_() ->
-    Opts = [{"algorithm", "sequential"}],
-    Cases = [
-        fun should_be_unique/2,
-        fun should_increment_monotonically/2,
-        fun should_rollover/2
-    ],
-    {
-        "UUID algorithm: sequential",
-        {
-            foreachx,
-            fun setup/1, fun teardown/2,
-            [{Opts, Fun} || Fun <- Cases]
-        }
-    }.
-
-utc_test_() ->
-    Opts = [{"algorithm", "utc_random"}],
-    Cases = [
-        fun should_be_unique/2,
-        fun should_increment_monotonically/2
-    ],
-    {
-        "UUID algorithm: utc_random",
-        {
-            foreachx,
-            fun setup/1, fun teardown/2,
-            [{Opts, Fun} || Fun <- Cases]
-        }
-    }.
-
-utc_id_suffix_test_() ->
-    Opts = [{"algorithm", "utc_id"}, {"utc_id_suffix", "bozo"}],
-    Cases = [
-        fun should_be_unique/2,
-        fun should_increment_monotonically/2,
-        fun should_preserve_suffix/2
-    ],
-    {
-        "UUID algorithm: utc_id",
-        {
-            foreachx,
-            fun setup/1, fun teardown/2,
-            [{Opts, Fun} || Fun <- Cases]
-        }
-    }.
-
-
-should_be_unique() ->
-    %% this one may really runs for too long on slow hosts
-    {timeout, ?TIMEOUT_S, ?_assert(test_unique(10000, [couch_uuids:new()]))}.
-should_be_unique(_) ->
-    should_be_unique().
-should_be_unique(_, _) ->
-    should_be_unique().
-
-should_increment_monotonically(_, _) ->
-    ?_assert(couch_uuids:new() < couch_uuids:new()).
-
-should_rollover(_, _) ->
-    ?_test(begin
-        UUID = binary_to_list(couch_uuids:new()),
-        Prefix = element(1, lists:split(26, UUID)),
-        N = gen_until_pref_change(Prefix, 0),
-        ?assert(N >= 5000 andalso N =< 11000)
-    end).
-
-should_preserve_suffix(_, _) ->
-    ?_test(begin
-        UUID = binary_to_list(couch_uuids:new()),
-        Suffix = get_suffix(UUID),
-        ?assert(test_same_suffix(10000, Suffix))
-    end).
-
-
-test_unique(0, _) ->
-    true;
-test_unique(N, UUIDs) ->
-    UUID = couch_uuids:new(),
-    ?assertNot(lists:member(UUID, UUIDs)),
-    test_unique(N - 1, [UUID| UUIDs]).
-
-get_prefix(UUID) ->
-    element(1, lists:split(26, binary_to_list(UUID))).
-
-gen_until_pref_change(_, Count) when Count > 8251 ->
-    Count;
-gen_until_pref_change(Prefix, N) ->
-    case get_prefix(couch_uuids:new()) of
-        Prefix -> gen_until_pref_change(Prefix, N + 1);
-        _ -> N
-    end.
-
-get_suffix(UUID) when is_binary(UUID) ->
-    get_suffix(binary_to_list(UUID));
-get_suffix(UUID) ->
-    element(2, lists:split(14, UUID)).
-
-test_same_suffix(0, _) ->
-    true;
-test_same_suffix(N, Suffix) ->
-    case get_suffix(couch_uuids:new()) of
-        Suffix -> test_same_suffix(N - 1, Suffix);
-        _ -> false
-    end.
+%% setup() ->
+%%     %% {ok, Pid} = config:start_link(?CONFIG_CHAIN),
+%%     {ok, Pid} = test_util:start_config(?CONFIG_CHAIN),
+%%     erlang:monitor(process, Pid),
+%%     couch_uuids:start(),
+%%     Pid.
+
+%% setup(Opts) ->
+%%     Pid = setup(),
+%%     lists:foreach(
+%%         fun({Option, Value}) ->
+%%             config:set("uuids", Option, Value, false)
+%%         end, Opts),
+%%     Pid.
+
+%% teardown(Pid) ->
+%%     couch_uuids:stop(),
+%%     config:stop(),
+%%     receive
+%%         {'DOWN', _, _, Pid, _} -> ok
+%%     after
+%%         1000 -> throw({timeout_error, config_stop})
+%%     end.
+
+%% teardown(_, Pid) ->
+%%     teardown(Pid).
+
+
+%% default_test_() ->
+%%     {
+%%         "Default UUID algorithm",
+%%         {
+%%             setup,
+%%             fun setup/0, fun teardown/1,
+%%             fun should_be_unique/1
+%%         }
+%%     }.
+
+%% sequential_test_() ->
+%%     Opts = [{"algorithm", "sequential"}],
+%%     Cases = [
+%%         fun should_be_unique/2,
+%%         fun should_increment_monotonically/2,
+%%         fun should_rollover/2
+%%     ],
+%%     {
+%%         "UUID algorithm: sequential",
+%%         {
+%%             foreachx,
+%%             fun setup/1, fun teardown/2,
+%%             [{Opts, Fun} || Fun <- Cases]
+%%         }
+%%     }.
+
+%% utc_test_() ->
+%%     Opts = [{"algorithm", "utc_random"}],
+%%     Cases = [
+%%         fun should_be_unique/2,
+%%         fun should_increment_monotonically/2
+%%     ],
+%%     {
+%%         "UUID algorithm: utc_random",
+%%         {
+%%             foreachx,
+%%             fun setup/1, fun teardown/2,
+%%             [{Opts, Fun} || Fun <- Cases]
+%%         }
+%%     }.
+
+%% utc_id_suffix_test_() ->
+%%     Opts = [{"algorithm", "utc_id"}, {"utc_id_suffix", "bozo"}],
+%%     Cases = [
+%%         fun should_be_unique/2,
+%%         fun should_increment_monotonically/2,
+%%         fun should_preserve_suffix/2
+%%     ],
+%%     {
+%%         "UUID algorithm: utc_id",
+%%         {
+%%             foreachx,
+%%             fun setup/1, fun teardown/2,
+%%             [{Opts, Fun} || Fun <- Cases]
+%%         }
+%%     }.
+
+
+%% should_be_unique() ->
+%%     %% this one may really runs for too long on slow hosts
+%%     {timeout, ?TIMEOUT_S, ?_assert(test_unique(10000, 
[couch_uuids:new()]))}.
+%% should_be_unique(_) ->
+%%     should_be_unique().
+%% should_be_unique(_, _) ->
+%%     should_be_unique().
+
+%% should_increment_monotonically(_, _) ->
+%%     ?_assert(couch_uuids:new() < couch_uuids:new()).
+
+%% should_rollover(_, _) ->
+%%     ?_test(begin
+%%         UUID = binary_to_list(couch_uuids:new()),
+%%         Prefix = element(1, lists:split(26, UUID)),
+%%         N = gen_until_pref_change(Prefix, 0),
+%%         ?assert(N >= 5000 andalso N =< 11000)
+%%     end).
+
+%% should_preserve_suffix(_, _) ->
+%%     ?_test(begin
+%%         UUID = binary_to_list(couch_uuids:new()),
+%%         Suffix = get_suffix(UUID),
+%%         ?assert(test_same_suffix(10000, Suffix))
+%%     end).
+
+
+%% test_unique(0, _) ->
+%%     true;
+%% test_unique(N, UUIDs) ->
+%%     UUID = couch_uuids:new(),
+%%     ?assertNot(lists:member(UUID, UUIDs)),
+%%     test_unique(N - 1, [UUID| UUIDs]).
+
+%% get_prefix(UUID) ->
+%%     element(1, lists:split(26, binary_to_list(UUID))).
+
+%% gen_until_pref_change(_, Count) when Count > 8251 ->
+%%     Count;
+%% gen_until_pref_change(Prefix, N) ->
+%%     case get_prefix(couch_uuids:new()) of
+%%         Prefix -> gen_until_pref_change(Prefix, N + 1);
+%%         _ -> N
+%%     end.
+
+%% get_suffix(UUID) when is_binary(UUID) ->
+%%     get_suffix(binary_to_list(UUID));
+%% get_suffix(UUID) ->
+%%     element(2, lists:split(14, UUID)).
+
+%% test_same_suffix(0, _) ->
+%%     true;
+%% test_same_suffix(N, Suffix) ->
+%%     case get_suffix(couch_uuids:new()) of
+%%         Suffix -> test_same_suffix(N - 1, Suffix);
+%%         _ -> false
+%%     end.

Reply via email to