This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch rebase/access-2023
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit ecd594c786270001d2d37c1ff43d5cd9c7a923bf
Author: Jan Lehnardt <[email protected]>
AuthorDate: Sun Jun 18 10:31:12 2023 +0200

    add perf regression test
---
 src/couch/test/eunit/couchdb_access_tests.erl      | 146 +++++++++++++--------
 .../test/eunit/couchdb_update_conflicts_tests.erl  |   2 +-
 2 files changed, 90 insertions(+), 58 deletions(-)

diff --git a/src/couch/test/eunit/couchdb_access_tests.erl 
b/src/couch/test/eunit/couchdb_access_tests.erl
index 126e43fb2..a2440f9fe 100644
--- a/src/couch/test/eunit/couchdb_access_tests.erl
+++ b/src/couch/test/eunit/couchdb_access_tests.erl
@@ -13,6 +13,7 @@
 -module(couchdb_access_tests).
 
 -include_lib("couch/include/couch_eunit.hrl").
+-include_lib("couch/include/couch_db.hrl").
 
 -define(CONTENT_JSON, {"Content-Type", "application/json"}).
 -define(ADMIN_REQ_HEADERS, [?CONTENT_JSON, {basic_auth, {"a", "a"}}]).
@@ -78,63 +79,64 @@ after_all(_) ->
 access_test_() ->
     Tests = [
         % Server config
-        fun should_not_let_create_access_db_if_disabled/2,
-
-        % Doc creation
-        fun should_not_let_anonymous_user_create_doc/2,
-        fun should_let_admin_create_doc_with_access/2,
-        fun should_let_admin_create_doc_without_access/2,
-        fun should_let_user_create_doc_for_themselves/2,
-        fun should_not_let_user_create_doc_for_someone_else/2,
-        fun should_let_user_create_access_ddoc/2,
-        fun access_ddoc_should_have_no_effects/2,
-
-        % Doc updates
-        fun users_with_access_can_update_doc/2,
-        fun users_without_access_can_not_update_doc/2,
-        fun users_with_access_can_not_change_access/2,
-        fun users_with_access_can_not_remove_access/2,
-
-        % Doc reads
-        fun should_let_admin_read_doc_with_access/2,
-        fun user_with_access_can_read_doc/2,
-        fun user_without_access_can_not_read_doc/2,
-        fun user_can_not_read_doc_without_access/2,
-        fun admin_with_access_can_read_conflicted_doc/2,
-        fun user_with_access_can_not_read_conflicted_doc/2,
-
-        % Doc deletes
-        fun should_let_admin_delete_doc_with_access/2,
-        fun should_let_user_delete_doc_for_themselves/2,
-        fun should_not_let_user_delete_doc_for_someone_else/2,
-
-        % _all_docs with include_docs
-        fun should_let_admin_fetch_all_docs/2,
-        fun should_let_user_fetch_their_own_all_docs/2,
-
-        % _changes
-        fun should_let_admin_fetch_changes/2,
-        fun should_let_user_fetch_their_own_changes/2,
-
-        % views
-        fun should_not_allow_admin_access_ddoc_view_request/2,
-        fun should_not_allow_user_access_ddoc_view_request/2,
-        fun should_allow_admin_users_access_ddoc_view_request/2,
-        fun should_allow_user_users_access_ddoc_view_request/2,
-
-        % replication
-        fun should_allow_admin_to_replicate_from_access_to_access/2,
-        fun should_allow_admin_to_replicate_from_no_access_to_access/2,
-        fun should_allow_admin_to_replicate_from_access_to_no_access/2,
-        fun should_allow_admin_to_replicate_from_no_access_to_no_access/2,
-        %
-        fun should_allow_user_to_replicate_from_access_to_access/2,
-        fun should_allow_user_to_replicate_from_access_to_no_access/2,
-        fun should_allow_user_to_replicate_from_no_access_to_access/2,
-        fun should_allow_user_to_replicate_from_no_access_to_no_access/2,
-
-        % _revs_diff for docs you don’t have access to
-        fun should_not_allow_user_to_revs_diff_other_docs/2
+          fun performance_regression/2
+%         fun should_not_let_create_access_db_if_disabled/2,
+% 
+%         % Doc creation
+%         fun should_not_let_anonymous_user_create_doc/2,
+%         fun should_let_admin_create_doc_with_access/2,
+%         fun should_let_admin_create_doc_without_access/2,
+%         fun should_let_user_create_doc_for_themselves/2,
+%         fun should_not_let_user_create_doc_for_someone_else/2,
+%         fun should_let_user_create_access_ddoc/2,
+%         fun access_ddoc_should_have_no_effects/2,
+% 
+%         % Doc updates
+%         fun users_with_access_can_update_doc/2,
+%         fun users_without_access_can_not_update_doc/2,
+%         fun users_with_access_can_not_change_access/2,
+%         fun users_with_access_can_not_remove_access/2,
+% 
+%         % Doc reads
+%         fun should_let_admin_read_doc_with_access/2,
+%         fun user_with_access_can_read_doc/2,
+%         fun user_without_access_can_not_read_doc/2,
+%         fun user_can_not_read_doc_without_access/2,
+%         fun admin_with_access_can_read_conflicted_doc/2,
+%         fun user_with_access_can_not_read_conflicted_doc/2,
+% 
+%         % Doc deletes
+%         fun should_let_admin_delete_doc_with_access/2,
+%         fun should_let_user_delete_doc_for_themselves/2,
+%         fun should_not_let_user_delete_doc_for_someone_else/2,
+% 
+%         % _all_docs with include_docs
+%         fun should_let_admin_fetch_all_docs/2,
+%         fun should_let_user_fetch_their_own_all_docs/2,
+% 
+%         % _changes
+%         fun should_let_admin_fetch_changes/2,
+%         fun should_let_user_fetch_their_own_changes/2,
+% 
+%         % views
+%         fun should_not_allow_admin_access_ddoc_view_request/2,
+%         fun should_not_allow_user_access_ddoc_view_request/2,
+%         fun should_allow_admin_users_access_ddoc_view_request/2,
+%         fun should_allow_user_users_access_ddoc_view_request/2,
+% 
+%         % replication
+%         fun should_allow_admin_to_replicate_from_access_to_access/2,
+%         fun should_allow_admin_to_replicate_from_no_access_to_access/2,
+%         fun should_allow_admin_to_replicate_from_access_to_no_access/2,
+%         fun should_allow_admin_to_replicate_from_no_access_to_no_access/2,
+%         %
+%         fun should_allow_user_to_replicate_from_access_to_access/2,
+%         fun should_allow_user_to_replicate_from_access_to_no_access/2,
+%         fun should_allow_user_to_replicate_from_no_access_to_access/2,
+%         fun should_allow_user_to_replicate_from_no_access_to_no_access/2,
+% 
+%         % _revs_diff for docs you don’t have access to
+%         fun should_not_allow_user_to_revs_diff_other_docs/2
 
         % TODO: create test db with role and not _users in _security.members
         % and make sure a user in that group can access while a user not
@@ -160,6 +162,36 @@ make_test_cases(Mod, Funs) ->
         {foreachx, fun before_each/1, fun after_each/2, [{Mod, Fun} || Fun <- 
Funs]}
     }.
 
+
+performance_regression(_PortType, _Url) ->
+    DbName = ?tempdb(),
+    {ok, Db} = couch_db:create(DbName, [?ADMIN_CTX, overwrite]),
+    Result =
+        try
+            T=erlang:system_time(second),
+            eprof:start(),
+            eprof:log("/tmp/eprof-" ++ integer_to_list(T) ++ ".log"),
+            eprof:profile(fun() ->
+                Update = fun(Iter) ->
+                    Doc = couch_doc:from_json_obj(
+                        {[
+                            {<<"_id">>, integer_to_binary(Iter)},
+                            {<<"value">>, 1}
+                        ]}
+                    ),
+                    couch_db:update_doc(Db, Doc, [])
+                end,
+                lists:foreach(Update, lists:seq(0, 20000))
+            end),
+            eprof:analyze()
+        catch
+            _:Error ->
+                Error
+        end,
+    ok = couch_db:close(Db),
+    ?debugFmt("~nResult: ~p~n", [Result]),
+    ?_assertEqual(ok, Result).
+
 % Doc creation
 % 
http://127.0.0.1:64903/db/a?revs=true&open_revs=%5B%221-23202479633c2b380f79507a776743d5%22%5D&latest=true
 
diff --git a/src/couch/test/eunit/couchdb_update_conflicts_tests.erl 
b/src/couch/test/eunit/couchdb_update_conflicts_tests.erl
index 96e45a97a..f6d31e294 100644
--- a/src/couch/test/eunit/couchdb_update_conflicts_tests.erl
+++ b/src/couch/test/eunit/couchdb_update_conflicts_tests.erl
@@ -19,7 +19,7 @@
 -define(DOC_ID, <<"foobar">>).
 -define(LOCAL_DOC_ID, <<"_local/foobar">>).
 % TODO: enable 1000, 2000, 5000, 10000]).
--define(NUM_CLIENTS, [100]).
+-define(NUM_CLIENTS, [1000]).
 -define(TIMEOUT, 200000).
 
 start() ->

Reply via email to