diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-12-26 12:03:46 -0600 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-12-26 12:04:34 -0600 |
commit | f290788be4beee412438580e17bf9016851c1f6f (patch) | |
tree | a93f773ebeba2391b6f87e60ebaed18645920e7e | |
parent | f2da0016c9ff873beafeba4cee81212ae396b8aa (diff) | |
download | couchdb-f290788be4beee412438580e17bf9016851c1f6f.tar.gz |
Shorten long tests during PR builds
-rw-r--r-- | src/couch/rebar.config.script | 8 | ||||
-rw-r--r-- | src/couch/test/eunit/couch_key_tree_prop_tests.erl | 32 | ||||
-rw-r--r-- | src/couch/test/eunit/couch_passwords_tests.erl | 102 | ||||
-rw-r--r-- | src/mango/test/20-no-timeout-test.py | 8 |
4 files changed, 113 insertions, 37 deletions
diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script index a07b9418e..a7b3e80d1 100644 --- a/src/couch/rebar.config.script +++ b/src/couch/rebar.config.script @@ -199,6 +199,12 @@ end, PlatformDefines = [ {platform_define, "win32", 'WINDOWS'} ], +EunitOpts = case os:getenv("PR_BUILD", "false") of + "true" -> + [{d, 'PR_BUILD'}]; + _ -> + [] +end, AddConfig = [ {port_specs, PortSpecs}, {erl_opts, PlatformDefines ++ [ @@ -206,7 +212,7 @@ AddConfig = [ {d, 'COUCHDB_GIT_SHA', GitSha}, {i, "../"} ] ++ MD5Config}, - {eunit_compile_opts, PlatformDefines} + {eunit_compile_opts, EunitOpts ++ PlatformDefines} ]. lists:foldl(fun({K, V}, CfgAcc) -> diff --git a/src/couch/test/eunit/couch_key_tree_prop_tests.erl b/src/couch/test/eunit/couch_key_tree_prop_tests.erl index f8146926a..8333ae9ca 100644 --- a/src/couch/test/eunit/couch_key_tree_prop_tests.erl +++ b/src/couch/test/eunit/couch_key_tree_prop_tests.erl @@ -12,14 +12,44 @@ -module(couch_key_tree_prop_tests). +-export([ + key_tree_test_/0 +]). + -include_lib("triq/include/triq.hrl"). --triq(eunit). + + +-ifdef(PR_BUILD). +-define(NUM_TESTS, 1). +-else. +-define(NUM_TESTS, 100). +-endif. -define(SIZE_REDUCTION, 3). % How much to reduce size with tree depth. -define(MAX_BRANCHES, 4). % Maximum number of branches. -define(RAND_SIZE, 1 bsl 64). +key_tree_test_() -> + Tests = [ + prop_revtree_merge_with_subset_of_own_nodes, + prop_revtree_merge_random_nodes, + prop_revtree_merge_some_existing_some_new, + prop_no_change_stemming_deeper_than_current_depth, + prop_stemming_results_in_same_or_less_total_revs, + prop_stem_path_expect_size_to_get_smaller, + prop_after_stemming_all_leaves_are_present, + prop_after_stemming_paths_are_shorter, + prop_leaf_count, + prop_get_leafs + ], + lists:map(fun(Test) -> + {timeout, 3600, {atom_to_list(Test), fun() -> + true == triq:check(?MODULE:Test(), ?NUM_TESTS) + end}} + end, Tests). + + % % Properties % diff --git a/src/couch/test/eunit/couch_passwords_tests.erl b/src/couch/test/eunit/couch_passwords_tests.erl index 88de8530f..be03c698d 100644 --- a/src/couch/test/eunit/couch_passwords_tests.erl +++ b/src/couch/test/eunit/couch_passwords_tests.erl @@ -14,41 +14,75 @@ -include_lib("couch/include/couch_eunit.hrl"). +cases() -> + [ + { + <<"0c60c80f961f0e71f3a9b524af6012062fe037a6">>, + <<"password">>, + <<"salt">>, + 1, + 20, + 5 + }, + { + <<"ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957">>, + <<"password">>, + <<"salt">>, + 2, + 20, + 5 + }, + { + <<"4b007901b765489abead49d926f721d065a429c1">>, + <<"password">>, + <<"salt">>, + 4096, + 20, + 5 + }, + { + <<"3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038">>, + <<"passwordPASSWORDpassword">>, + <<"saltSALTsaltSALTsaltSALTsaltSALTsalt">>, + 4096, + 25, + 5 + }, + { + <<"56fa6aa75548099dcc37d7f03425e0c3">>, + <<"pass\0word">>, + <<"sa\0lt">>, + 4096, + 16, + 5 + } + ] ++ long_tests(). -pbkdf2_test_()-> - {"PBKDF2", - [ - {"Iterations: 1, length: 20", - ?_assertEqual( - {ok, <<"0c60c80f961f0e71f3a9b524af6012062fe037a6">>}, - couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 1, 20))}, - - {"Iterations: 2, length: 20", - ?_assertEqual( - {ok, <<"ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957">>}, - couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 2, 20))}, - {"Iterations: 4096, length: 20", - ?_assertEqual( - {ok, <<"4b007901b765489abead49d926f721d065a429c1">>}, - couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 4096, 20))}, +-ifdef(PR_BUILD). +long_tests() -> + []. +-else. +long_tests() -> + [{ + <<"eefe3d61cd4da4e4e9945b3d6ba2158c2634e984">>, + <<"password">>, + <<"salt">>, + 16777216, + 20, + 600 + }]. +-endif. - {"Iterations: 4096, length: 25", - ?_assertEqual( - {ok, <<"3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038">>}, - couch_passwords:pbkdf2(<<"passwordPASSWORDpassword">>, - <<"saltSALTsaltSALTsaltSALTsaltSALTsalt">>, - 4096, 25))}, - {"Null byte", - ?_assertEqual( - {ok, <<"56fa6aa75548099dcc37d7f03425e0c3">>}, - couch_passwords:pbkdf2(<<"pass\0word">>, - <<"sa\0lt">>, - 4096, 16))}, - {timeout, 600, %% this may runs too long on slow hosts - {"Iterations: 16777216 - this may take some time", - ?_assertEqual( - {ok, <<"eefe3d61cd4da4e4e9945b3d6ba2158c2634e984">>}, - couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 16777216, 20) - )}}]}. +pbkdf2_test_()-> + Tests = lists:map(fun({Expect, Pass, Salt, Iters, Length, Timeout}) -> + Name = io_lib:format("Iterations: ~b, length: ~b", [Iters, Length]), + {timeout, Timeout, {lists:flatten(Name), + ?_assertEqual( + {ok, Expect}, + couch_passwords:pbkdf2(Pass, Salt, Iters, Length) + ) + }} + end, cases()), + {"PBKDF2", Tests}. diff --git a/src/mango/test/20-no-timeout-test.py b/src/mango/test/20-no-timeout-test.py index cffdfc335..a7ff74343 100644 --- a/src/mango/test/20-no-timeout-test.py +++ b/src/mango/test/20-no-timeout-test.py @@ -12,14 +12,20 @@ import mango import copy +import os import unittest +NUM_DOCS = 100000 +if os.getenv("PR_BUILD", "false").lower() == "true": + NUM_DOCS = 100 + + class LongRunningMangoTest(mango.DbPerClass): def setUp(self): self.db.recreate() docs = [] - for i in range(100000): + for i in range(NUM_DOCS): docs.append({"_id": str(i), "another": "field"}) if i % 20000 == 0: self.db.save_docs(docs) |