You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2023/04/10 20:23:39 UTC
[couchdb] branch improve-couchdb-file-compression-tests created (now 4bdabda68)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch improve-couchdb-file-compression-tests
in repository https://gitbox.apache.org/repos/asf/couchdb.git
at 4bdabda68 Improve compression eunit test suite
This branch includes the following new commits:
new 4bdabda68 Improve compression eunit test suite
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb] 01/01: Improve compression eunit test suite
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch improve-couchdb-file-compression-tests
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 4bdabda6889ca9bcf475e34ea6cac21e06c2d5c2
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Mon Apr 10 16:20:37 2023 -0400
Improve compression eunit test suite
Use the simpler `?TDEF_FE` macro and fix timeout usage bug. EUnit timeout is in
seconds, while test_util:wait/2 takes milliseconds. This was revealed due a
slow disk IO speed on the new s390x worker.
Issue: https://github.com/apache/couchdb/issues/4521
---
.../test/eunit/couchdb_file_compression_tests.erl | 108 ++++++++++-----------
1 file changed, 49 insertions(+), 59 deletions(-)
diff --git a/src/couch/test/eunit/couchdb_file_compression_tests.erl b/src/couch/test/eunit/couchdb_file_compression_tests.erl
index 75bf18a12..3a7b71684 100644
--- a/src/couch/test/eunit/couchdb_file_compression_tests.erl
+++ b/src/couch/test/eunit/couchdb_file_compression_tests.erl
@@ -21,6 +21,31 @@
setup_all() ->
Ctx = test_util:start_couch(),
+ config:set("couchdb", "file_compression", "none", false),
+ Ctx.
+
+teardown_all(Ctx) ->
+ config:delete("couchdb", "file_compression", false),
+ test_util:stop_couch(Ctx).
+
+couch_file_compression_test_() ->
+ {
+ "CouchDB file compression tests",
+ {
+ setup,
+ fun setup_all/0,
+ fun teardown_all/1,
+ {foreach, fun setup/0, fun teardown/1, [
+ ?TDEF_FE(should_use_none, ?TIMEOUT),
+ ?TDEF_FE(should_use_deflate_1, ?TIMEOUT),
+ ?TDEF_FE(should_use_deflate_9, ?TIMEOUT),
+ ?TDEF_FE(should_use_snappy, ?TIMEOUT),
+ ?TDEF_FE(should_compare_compression_methods, ?TIMEOUT)
+ ]}
+ }
+ }.
+
+setup() ->
config:set("couchdb", "file_compression", "none", false),
DbName = ?tempdb(),
{ok, Db} = couch_db:create(DbName, [?ADMIN_CTX]),
@@ -40,58 +65,34 @@ setup_all() ->
),
{ok, _} = couch_db:update_doc(Db, DDoc, []),
ok = couch_db:close(Db),
- {Ctx, DbName}.
+ ok = refresh_index(DbName),
+ DbName.
-teardown_all({Ctx, DbName}) ->
- ok = couch_server:delete(DbName, [?ADMIN_CTX]),
- test_util:stop_couch(Ctx).
+teardown(DbName) ->
+ config:delete("couchdb", "file_compression", false),
+ couch_server:delete(DbName, [?ADMIN_CTX]).
-couch_file_compression_test_() ->
- {
- "CouchDB file compression tests",
- {
- setup,
- fun setup_all/0,
- fun teardown_all/1,
- {with, [
- fun should_use_none/1,
- fun should_use_deflate_1/1,
- fun should_use_deflate_9/1,
- fun should_use_snappy/1,
- fun should_compare_compression_methods/1
- ]}
- }
- }.
+should_use_none(DbName) ->
+ config:set("couchdb", "file_compression", "none", false),
+ compact_db(DbName),
+ compact_view(DbName).
-should_use_none({_, DbName}) -> run_test(DbName, "none").
-should_use_deflate_1({_, DbName}) -> run_test(DbName, "deflate_1").
-should_use_deflate_9({_, DbName}) -> run_test(DbName, "deflate_9").
-should_use_snappy({_, DbName}) -> run_test(DbName, "snappy").
-
-should_compare_compression_methods({_, DbName}) ->
- TestDb = setup_db(DbName),
- Name = "none > snappy > deflate_1 > deflate_9",
- try
- {Name, {timeout, ?TIMEOUT, ?_test(compare_methods(TestDb))}}
- after
- couch_server:delete(TestDb, [?ADMIN_CTX])
- end.
+should_use_deflate_1(DbName) ->
+ config:set("couchdb", "file_compression", "deflate_1", false),
+ compact_db(DbName),
+ compact_view(DbName).
-run_test(DbName, Comp) ->
- config:set("couchdb", "file_compression", Comp, false),
- Timeout = 5 + ?TIMEOUT,
- TestDb = setup_db(DbName),
- Tests = [
- {"compact database", {timeout, Timeout, ?_test(compact_db(DbName))}},
- {"compact view", {timeout, Timeout, ?_test(compact_view(DbName))}}
- ],
- try
- {"Use compression: " ++ Comp, Tests}
- after
- ok = couch_server:delete(TestDb, [?ADMIN_CTX])
- end.
+should_use_deflate_9(DbName) ->
+ config:set("couchdb", "file_compression", "deflate_9", false),
+ compact_db(DbName),
+ compact_view(DbName).
-compare_methods(DbName) ->
+should_use_snappy(DbName) ->
+ config:set("couchdb", "file_compression", "deflate_9", false),
+ compact_db(DbName),
+ compact_view(DbName).
+
+should_compare_compression_methods(DbName) ->
config:set("couchdb", "file_compression", "none", false),
ExternalSizePreCompact = db_external_size(DbName),
compact_db(DbName),
@@ -154,17 +155,6 @@ populate_db(Db, NumDocs) ->
{ok, _} = couch_db:update_docs(Db, Docs, []),
populate_db(Db, NumDocs - 500).
-setup_db(SrcDbName) ->
- TgtDbName = ?tempdb(),
- TgtDbFileName = binary_to_list(TgtDbName) ++ ".couch",
- couch_util:with_db(SrcDbName, fun(Db) ->
- OldPath = couch_db:get_filepath(Db),
- NewPath = filename:join(filename:dirname(OldPath), TgtDbFileName),
- {ok, _} = file:copy(OldPath, NewPath)
- end),
- refresh_index(TgtDbName),
- TgtDbName.
-
refresh_index(DbName) ->
{ok, Db} = couch_db:open_int(DbName, []),
{ok, DDoc} = couch_db:open_doc(Db, ?DDOC_ID, [ejson_body]),
@@ -226,7 +216,7 @@ wait_compaction(DbName, Kind, Line) ->
false -> ok
end
end,
- case test_util:wait(WaitFun, ?TIMEOUT) of
+ case test_util:wait(WaitFun, ?TIMEOUT * 1000) of
timeout ->
erlang:error(
{assertion_failed, [