diff --git a/.gitlab/ci/jobs/packaging/opam_package.yml b/.gitlab/ci/jobs/packaging/opam_package.yml index c092da6c15314be3054c1b1d9310ad3fe65e71c5..d49aff55af933f1017ce14d034e5f324d57c4b62 100644 --- a/.gitlab/ci/jobs/packaging/opam_package.yml +++ b/.gitlab/ci/jobs/packaging/opam_package.yml @@ -519,7 +519,7 @@ opam:tezos-base-test-helpers: opam:tezos-clic: extends: - .opam_template - - .rules_template__trigger_opam_batch_7 + - .rules_template__trigger_opam_batch_6 variables: package: tezos-clic @@ -1607,13 +1607,6 @@ opam:tezos-test-helpers: variables: package: tezos-test-helpers -opam:tezos-test-helpers-extra: - extends: - - .opam_template - - .rules_template__trigger_opam_batch_6 - variables: - package: tezos-test-helpers-extra - # Ignoring unreleased package tezos-tooling. # Ignoring unreleased package tezos-tps-evaluation. diff --git a/Makefile b/Makefile index d834c355f51c3f30c15705c740ad0ae58e798f82..f838b26687c562b197dc140b9b61938c071886b4 100644 --- a/Makefile +++ b/Makefile @@ -239,7 +239,17 @@ test-proto-unit: scripts/test_wrapper.sh test-proto-unit \ $(addprefix @, $(addsuffix /runtest,$(PROTO_DIRS))) +.PHONY: test-lib-store-slow +test-lib-store-slow: + DUNE_PROFILE=$(PROFILE) \ + COVERAGE_OPTIONS="$(COVERAGE_OPTIONS)" \ + dune exec src/lib_store/unix/test/slow/test_slow.exe -- --file test_slow.ml --info +.PHONY: test-lib-store-bench +test-lib-store-bench: + DUNE_PROFILE=$(PROFILE) \ + COVERAGE_OPTIONS="$(COVERAGE_OPTIONS)" \ + dune exec src/lib_store/unix/test/bench/bench.exe -- --file bench.ml --info .PHONY: test-nonproto-unit test-nonproto-unit: @@ -253,7 +263,7 @@ test-lib-store-unit: DUNE_PROFILE=$(PROFILE) \ COVERAGE_OPTIONS="$(COVERAGE_OPTIONS)" \ scripts/test_wrapper.sh test-lib-store-unit \ - @$(LIBSTORE_UNIX_DIR)/runtest + @$(LIBSTORE_UNIX_DIR)/runtezt .PHONY: test-unit test-unit: test-nonproto-unit test-proto-unit diff --git a/dune-project b/dune-project index e8afa8e5c4e347531f0fce1a2cc63ed1f8a2d0f7..064c16b951b11dfbe80d7d0286d8884a56b31608 100644 --- a/dune-project +++ b/dune-project @@ -247,7 +247,6 @@ (package (name tezos-stdlib-unix)) (package (name tezos-store)) (package (name tezos-test-helpers)) -(package (name tezos-test-helpers-extra)) (package (name tezos-tooling)) (package (name tezos-tps-evaluation)) (package (name tezos-tree-encoding)) diff --git a/manifest/main.ml b/manifest/main.ml index 6b274623c96bca52eca5b5cf4ddb8fb3a7c4f1fe..6155bcc32f77d0c6670f10d9d1c7952701471416 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -2164,22 +2164,6 @@ let octez_shell_services = ~linkall:true ~js_compatible:true -let octez_test_helpers_extra = - public_lib - "tezos-test-helpers-extra" - ~path:"src/lib_test" - ~internal_name:"lib_test_extra" - ~synopsis:"Test helpers dependent on tezos-base" - ~deps:[octez_base; octez_crypto; octez_test_helpers] - ~dune: - Dune. - [ - (* This rule is necessary for `make lint-tests-pkg`, without it dune - complains that the alias is empty. *) - alias_rule "runtest_js_base" ~action:(S "progn"); - ] - ~modules:["assert_lib"] - let _octez_shell_services_tests = tezt ["test_block_services"] @@ -2632,7 +2616,6 @@ let _octez_context_tests = octez_context_encoding; octez_stdlib_unix |> open_; octez_test_helpers |> open_; - octez_test_helpers_extra; qcheck_alcotest; alcotezt; ] @@ -4922,22 +4905,25 @@ end = struct can be run either with [dune build @runtezt], with [dune exec src/proto_alpha/lib_protocol/test/regression/main.exe], or with [dune exec tezt/tests/main.exe -- -f test_logging.ml]. *) - tezt - ["test_logging"] - ~path:(path // "lib_protocol/test/regression") - ~with_macos_security_framework:true - ~opam:(sf "tezos-protocol-%s-tests" name_dash) - ~deps: - [ - octez_base |> open_ ~m:"TzPervasives"; - tezt_tezos |> open_; - main |> open_; - client |> if_some |> open_; - plugin |> if_some |> open_; - test_helpers |> if_some |> open_; - octez_micheline |> open_; - ] - ~dep_globs:["contracts/*.tz"; "expected/test_logging.ml/*.out"] + let _ = + tezt + ["test_logging"] + ~path:(path // "lib_protocol/test/regression") + ~with_macos_security_framework:true + ~opam:(sf "tezos-protocol-%s-tests" name_dash) + ~deps: + [ + octez_base |> open_ ~m:"TzPervasives"; + tezt_tezos |> open_; + main |> open_; + client |> if_some |> open_; + plugin |> if_some |> open_; + test_helpers |> if_some |> open_; + octez_micheline |> open_; + ] + ~dep_globs:["contracts/*.tz"; "expected/test_logging.ml/*.out"] + in + () in () @@ -6486,9 +6472,13 @@ let _octez_micheline_rewriting_tests = ] let _octez_store_tests = - tests + tezt [ "test"; + "test_snapshots"; + "test_reconstruct"; + "test_history_mode_switch"; + "alpha_utils"; "test_consistency"; "test_locator"; "test_cemented_store"; @@ -6496,6 +6486,8 @@ let _octez_store_tests = "test_protocol_store"; "test_store"; "test_testchain"; + "test_utils"; + "assert_lib"; ] ~path:"src/lib_store/unix/test" ~with_macos_security_framework:true @@ -6518,56 +6510,46 @@ let _octez_store_tests = Protocol.(embedded alpha); Protocol.(parameters_exn alpha |> open_); Protocol.(plugin_exn alpha) |> open_; - alcotest_lwt; + alcotezt; octez_test_helpers |> open_; - octez_test_helpers_extra; ] - ~alias:"" - ~dune: - (* [test_slow_manual] is a very long test, running a huge - combination of tests that are useful for local testing for a - given test suite. In addition to that, there is a memory leak - is the tests (that could be in alcotest) which makes the test - to consumes like > 10Gb of ram. For these reasons, we do not - run these tests in the CI. *) - Dune. - [ - alias_rule - "runtest" - ~package:"tezos-store" - ~action:(run_exe "test_cemented_store" []); - alias_rule - "runtest" - ~package:"tezos-store" - ~action:(run_exe "test_consistency" []); - alias_rule - "runtest" - ~package:"tezos-store" - ~action:(run_exe "test_block_store" []); - alias_rule - "runtest" - ~package:"tezos-store" - ~action:(run_exe "test_protocol_store" []); - alias_rule - "runtest" - ~package:"tezos-store" - ~action:(run_exe "test_store" []); - alias_rule - "runtest" - ~package:"tezos-store" - ~action:(run_exe "test_testchain" []); - alias_rule - "runtest" - ~package:"tezos-store" - ~action:(setenv "SLOW_TEST" "false" @@ run_exe "test" []); - alias_rule - "test_slow_manual" - ~action:(setenv "SLOW_TEST" "true" @@ run_exe "test" []); - alias_rule - "runtest_locator_bench" - ~package:"tezos-store" - ~action:(run_exe "test_locator" ["--bench"]); - ] + +(* [_octez_bench_store_lib_tests_exe] is a bench for the store locator, + We do not run these tests in the CI. *) +let _octez_bench_store_lib_tests_exe = + private_exe + "bench" + ~path:"src/lib_store/unix/test/bench" + ~synopsis:"Bench store lib tests" + ~opam:"" + ~deps: + [ + octez_base |> open_ ~m:"TzPervasives"; + tezt_lib; + alcotezt; + _octez_store_tests |> open_; + ] + +(* [_octez_slow_store_lib_tests_exe] is a very long test, running a huge + combination of tests that are useful for local testing for a + given test suite. In addition to that, there is a memory leak + is the tests (that could be in alcotest) which makes the test + to consumes like > 10Gb of ram. For these reasons, we do not + run these tests in the CI. *) +let _octez_slow_store_lib_tests_exe = + private_exe + "test_slow" + ~path:"src/lib_store/unix/test/slow" + ~synopsis:"Slow store lib tests" + ~modules:["test_slow"] + ~opam:"" + ~deps: + [ + octez_base |> open_ ~m:"TzPervasives"; + tezt_lib; + alcotezt; + _octez_store_tests |> open_; + ] let _octez_shell_tests = tezt diff --git a/manifest/manifest.ml b/manifest/manifest.ml index 38b8180e65eae7f269452f71dcd5adadf630d542..bbb2cce6c3ad41188a97b16194b4e88a279e2a1e 100644 --- a/manifest/manifest.ml +++ b/manifest/manifest.ml @@ -1804,6 +1804,7 @@ type tezt_target = { opam_with_test : with_test option; with_macos_security_framework : bool; dune : Dune.s_expr; + tezt_local_test_lib : target; } let tezt_targets_by_path : tezt_target String_map.t ref = ref String_map.empty @@ -1815,6 +1816,23 @@ let tezt ~opam ~path ?js_compatible ?modes ?(lib_deps = []) ?(exe_deps = []) if String_map.mem path !tezt_targets_by_path then invalid_arg ("cannot call Manifest.tezt twice for the same directory: " ^ path) ; + let path_with_underscores = + String.map (function '-' | '/' -> '_' | c -> c) path + in + (* [linkall] is used to ensure that the test executable is linked with [module_name] and [tezt]. *) + let tezt_local_test_lib_name = path_with_underscores ^ "_tezt_lib" in + let tezt_local_test_lib = + Target.( + private_lib + ~path + ~opam:"" + ?js_compatible + ~deps:lib_deps + ~modules + ~linkall:true + ~dune + tezt_local_test_lib_name) + in let tezt_target = { opam; @@ -1831,46 +1849,30 @@ let tezt ~opam ~path ?js_compatible ?modes ?(lib_deps = []) ?(exe_deps = []) opam_with_test; with_macos_security_framework; dune; + tezt_local_test_lib; } in - tezt_targets_by_path := String_map.add path tezt_target !tezt_targets_by_path + tezt_targets_by_path := String_map.add path tezt_target !tezt_targets_by_path ; + tezt_local_test_lib let register_tezt_targets ~make_tezt_exe = let tezt_test_libs = ref [] in let register_path path { opam; - lib_deps; exe_deps; js_deps; dep_globs; dep_globs_rec; dep_files; - modules; - js_compatible; modes; synopsis; opam_with_test; with_macos_security_framework; - dune; + tezt_local_test_lib; + _; } = - let path_with_underscores = - String.map (function '-' | '/' -> '_' | c -> c) path - in - let lib = - (* [linkall] is used to ensure that the test executable is linked with - [module_name] and [tezt]. *) - Target.private_lib - (path_with_underscores ^ "_tezt_lib") - ~path - ~opam:"" - ?js_compatible - ~deps:lib_deps - ~modules - ~linkall:true - ~dune - in - tezt_test_libs := lib :: !tezt_test_libs ; + tezt_test_libs := tezt_local_test_lib :: !tezt_test_libs ; let declare_exe ?js_compatible exe_name modes deps main = let (_ : Target.t option) = Target.test @@ -1885,7 +1887,7 @@ let register_tezt_targets ~make_tezt_exe = (* Instrument with sigterm handler, to ensure that coverage from Tezt worker processes are collected. *) ~bisect_ppx:With_sigterm - ~deps:(lib :: deps) + ~deps:(tezt_local_test_lib :: deps) ~dep_globs ~dep_globs_rec ~dep_files diff --git a/manifest/manifest.mli b/manifest/manifest.mli index de561cf350a53a4387c2997c716ccc37a07ff81c..c31ae7c784b2554004e2d4da14d3b01072ea9f89 100644 --- a/manifest/manifest.mli +++ b/manifest/manifest.mli @@ -939,7 +939,11 @@ val tests : The flag [with_macos_security_framework] has a default [false]. When set to [true], the [-ccopt "-framework Security"]flag is added at link time for - macOS system. *) + macOS system. + + The function returns a target that is the local library created by tezt + to register all tests. This can be reused locally in the same module + to share code with other targets. *) val tezt : opam:string -> path:string -> @@ -956,7 +960,7 @@ val tezt : ?with_macos_security_framework:bool -> ?dune:Dune.s_expr -> string list -> - unit + target (** Make an external vendored library, for use in internal target dependencies. diff --git a/opam/tezos-context.opam b/opam/tezos-context.opam index 678eef65643f4b367efa151f4734107ad4ef26db..25f2b75cf6c57db246b95872ec8057b3e63ee322 100644 --- a/opam/tezos-context.opam +++ b/opam/tezos-context.opam @@ -21,7 +21,6 @@ depends: [ "tezt" { with-test & >= "3.0.0" } "octez-alcotezt" {with-test} "tezos-test-helpers" {with-test} - "tezos-test-helpers-extra" {with-test} "qcheck-alcotest" { with-test & >= "0.20" } ] build: [ diff --git a/opam/tezos-store.opam b/opam/tezos-store.opam index a318b60e6e5b73e7bd5377500cafdaec6478d50f..f867f699a954b83e83be3baf5ee37d7b9afa98e2 100644 --- a/opam/tezos-store.opam +++ b/opam/tezos-store.opam @@ -32,19 +32,20 @@ depends: [ "tar-unix" { >= "2.0.1" & < "3.0.0" } "prometheus" { >= "1.2" } "tezos-rpc" + "tezt" { with-test & >= "3.0.0" } "tezos-embedded-protocol-demo-noops" {with-test} "tezos-embedded-protocol-genesis" {with-test} "tezos-embedded-protocol-alpha" {with-test} "tezos-protocol-alpha" {with-test} "tezos-protocol-plugin-alpha" {with-test} - "alcotest-lwt" { with-test & >= "1.5.0" } + "octez-alcotezt" {with-test} "tezos-test-helpers" {with-test} - "tezos-test-helpers-extra" {with-test} ] build: [ ["rm" "-r" "vendors"] ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "@runtezt" "-p" name "-j" jobs] {with-test} ] synopsis: "Tezos: store for `octez-node`" description: "This library provides abstraction for storing and iterating over blocks. diff --git a/opam/tezos-test-helpers-extra.opam b/opam/tezos-test-helpers-extra.opam deleted file mode 100644 index db9da3c8a400867ae80ae1dfae2984053f81d1bf..0000000000000000000000000000000000000000 --- a/opam/tezos-test-helpers-extra.opam +++ /dev/null @@ -1,22 +0,0 @@ -# This file was automatically generated, do not edit. -# Edit file manifest/main.ml instead. -opam-version: "2.0" -maintainer: "contact@tezos.com" -authors: ["Tezos devteam"] -homepage: "https://www.tezos.com/" -bug-reports: "https://gitlab.com/tezos/tezos/issues" -dev-repo: "git+https://gitlab.com/tezos/tezos.git" -license: "MIT" -depends: [ - "dune" { >= "3.0" } - "ocaml" { >= "4.14" } - "tezos-base" - "tezos-crypto" - "tezos-test-helpers" -] -build: [ - ["rm" "-r" "vendors"] - ["dune" "build" "-p" name "-j" jobs] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} -] -synopsis: "Test helpers dependent on tezos-base" diff --git a/src/lib_context/test/dune b/src/lib_context/test/dune index 798e505d1bcfbde1e02f42480ba6f85eed828d13..5cd9113d2e6441317ed2e896b7bd3b6ae997ff1f 100644 --- a/src/lib_context/test/dune +++ b/src/lib_context/test/dune @@ -14,7 +14,6 @@ tezos-context.encoding tezos-stdlib-unix tezos-test-helpers - tezos-test-helpers-extra qcheck-alcotest octez-alcotezt) (library_flags (:standard -linkall)) diff --git a/src/lib_context/test/test_context.ml b/src/lib_context/test/test_context.ml index 4ef7923cae96e390a0bbd79a9fbcfe5419773333..d4d021e376dacae1dc7d5590cd45c71e22afdc81 100644 --- a/src/lib_context/test/test_context.ml +++ b/src/lib_context/test/test_context.ml @@ -30,7 +30,30 @@ Subject: On context features. *) -module Assert_lib = Lib_test_extra.Assert_lib +(** Module concerning assertions about raw trees i.e. values of type + [[< `Tree of 'a Tezos_base.TzPervasives.String.Map.t | `Value of bytes] as 'a] *) +module Raw_Tree = struct + (** [equal loc msg rt0 rt1] checks that the raw tree [rt0] and [rt1] are equal. + Will fail with the message [msg] displaying the location [loc] otherwise *) + let equal ?loc ?msg r1 r2 = + let rec aux r1 r2 = + match (r1, r2) with + | `Value v1, `Value v2 -> + Assert.Bytes.equal ?loc ?msg v1 v2 ; + true + | `Tree t1, `Tree t2 -> + if not (Tezos_base.TzPervasives.String.Map.equal aux t1 t2) then + Assert.String.fail "" "" ?msg ?loc + else true + | `Tree _, `Value v -> + Assert.String.fail ?loc ?msg "" (Bytes.to_string v) + | `Value v, `Tree _ -> + Assert.String.fail ?loc ?msg (Bytes.to_string v) "" + in + let _b : bool = aux r1 r2 in + () +end + module Assert = Assert let equal_context_hash ?loc ?msg l1 l2 = @@ -460,7 +483,7 @@ struct let c = String.Map.add "bar" (`Tree b) a in let d = String.Map.singleton "foo" (`Tree c) in let e = `Tree d in - Assert_lib.Raw_Tree.equal ~loc:__LOC__ e raw ; + Raw_Tree.equal ~loc:__LOC__ e raw ; Lwt.return () let string n = String.make n 'a' diff --git a/src/lib_sapling/test/dune b/src/lib_sapling/test/dune index 663f006e43027d996f63a1b99f2c7ed95aab043d..f4bbc29bdb52bd4d4fbcb65bcf71525f2408aeac 100644 --- a/src/lib_sapling/test/dune +++ b/src/lib_sapling/test/dune @@ -3,23 +3,6 @@ (env (_ (env-vars (NODE_PRELOAD hacl-wasm,ocaml-bls12-381,secp256k1-wasm)))) -(executable - (name test_js) - (modes js) - (libraries - tezos-sapling - tezos-hacl) - (js_of_ocaml) - (link_flags - (:standard) - (-linkall)) - (modules test_js)) - -(rule - (alias runtest_js) - (package tezos-sapling) - (action (run node %{dep:./test_js.bc.js}))) - (library (name src_lib_sapling_test_tezt_lib) (instrumentation (backend bisect_ppx)) @@ -54,6 +37,23 @@ keys example)) +(executable + (name test_js) + (modes js) + (libraries + tezos-sapling + tezos-hacl) + (js_of_ocaml) + (link_flags + (:standard) + (-linkall)) + (modules test_js)) + +(rule + (alias runtest_js) + (package tezos-sapling) + (action (run node %{dep:./test_js.bc.js}))) + (executable (name main) (instrumentation (backend bisect_ppx --bisect-sigterm)) diff --git a/src/lib_test/assert_lib.ml b/src/lib_store/unix/test/assert_lib.ml similarity index 86% rename from src/lib_test/assert_lib.ml rename to src/lib_store/unix/test/assert_lib.ml index e6fefc7a00ffe540a3f2ea4209f0ddf9d329d05a..09a0b7739038c775802b6a3c8c4e5372d578cf5a 100644 --- a/src/lib_test/assert_lib.ml +++ b/src/lib_store/unix/test/assert_lib.ml @@ -94,23 +94,3 @@ module Crypto = struct in Assert.equal ?loc ?msg ~pp ~eq bd1 bd2 end - -module Raw_Tree = struct - let equal ?loc ?msg r1 r2 = - let rec aux r1 r2 = - match (r1, r2) with - | `Value v1, `Value v2 -> - Assert.Bytes.equal ?loc ?msg v1 v2 ; - true - | `Tree t1, `Tree t2 -> - if not (Tezos_base.TzPervasives.String.Map.equal aux t1 t2) then - Assert.String.fail "" "" ?msg ?loc - else true - | `Tree _, `Value v -> - Assert.String.fail ?loc ?msg "" (Bytes.to_string v) - | `Value v, `Tree _ -> - Assert.String.fail ?loc ?msg (Bytes.to_string v) "" - in - let _b : bool = aux r1 r2 in - () -end diff --git a/src/lib_test/assert_lib.mli b/src/lib_store/unix/test/assert_lib.mli similarity index 87% rename from src/lib_test/assert_lib.mli rename to src/lib_store/unix/test/assert_lib.mli index 703486ac17700dc429d15073e0bfbe8bb820d5db..0d7e756370eb0a7dd82a92cc4501fbbed72fe30b 100644 --- a/src/lib_test/assert_lib.mli +++ b/src/lib_store/unix/test/assert_lib.mli @@ -56,18 +56,3 @@ module Crypto : sig val equal_block_descriptor : (int32 * Tezos_crypto.Hashed.Block_hash.t) Tezos_test_helpers.Assert.check2 end - -(** Module concerning assertions about raw trees i.e. values of type - [[< `Tree of 'a Tezos_base.TzPervasives.String.Map.t | `Value of bytes] as 'a] *) -module Raw_Tree : sig - (** [equal loc msg rt0 rt1] checks that the raw tree [rt0] and [rt1] are equal. - Will fail with the message [msg] displaying the location [loc] otherwise *) - val equal : - ?loc:string -> - ?msg:string -> - ([< `Tree of 'a Tezos_base.TzPervasives.String.Map.t | `Value of bytes] - as - 'a) -> - 'a -> - unit -end diff --git a/src/lib_store/unix/test/bench/bench.ml b/src/lib_store/unix/test/bench/bench.ml new file mode 100644 index 0000000000000000000000000000000000000000..20643e1abec1e35bb1d21d4072d1fca2dc7adcd1 --- /dev/null +++ b/src/lib_store/unix/test/bench/bench.ml @@ -0,0 +1,104 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2020 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Testing + _______ + + Invocation: dune exec src/lib_store/unix/test/bench.exe --file bench.ml + Subject: Store locator bench. These tests are not run in the CI +*) + +module Store = Tezos_store_unix.Store + +(** Test if the linear and exponential locator are the same and outputs + their timing. + Run the test with: + $ dune build @runtest_locator + Copy the output to a file timing.dat and plot it with: + $ generate_locator_plot.sh timing.dat +*) +let bench_locator base_dir = + let open Test_locator in + let open Lwt_result_syntax in + let size_chain = 80000 in + (* timing locators with average over [runs] times *) + let runs = 10 in + let _ = Printf.printf "#runs %i\n" runs in + (* limit after which exp should go linear *) + let exp_limit = Test_locator.compute_size_chain 120 in + let _ = Printf.printf "#exp_limit %i\n" exp_limit in + (* size after which locator always reaches genesis *) + let locator_limit = compute_size_locator size_chain in + let _ = Printf.printf "#locator_limit %i\n" locator_limit in + let*! store = init_chain base_dir in + let chain_store = Store.main_chain_store store in + time1 (fun () -> make_empty_chain chain_store size_chain) + |> fun (res, t_chain) -> + let _ = + Printf.printf + "#size_chain %i built in %f sec\n# size exp lins\n" + size_chain + t_chain + in + let*! head = res in + let check_locator max_size : unit tzresult Lwt.t = + let*! caboose, _ = Store.Chain.caboose chain_store in + let* block = Store.Block.read_block chain_store head in + time ~runs (fun () -> + Store.Chain.compute_locator chain_store ~max_size block seed) + |> fun (l_exp, t_exp) -> + time ~runs (fun () -> + compute_linear_locator chain_store ~caboose ~max_size block) + |> fun (l_lin, t_lin) -> + let*! {Block_locator.history = l_exp; _} = l_exp in + let*! {Block_locator.history = l_lin; _} = l_lin in + let _ = Printf.printf "%10i %f %f\n" max_size t_exp t_lin in + Lwt.return + @@ List.iter2 + ~when_different_lengths:(TzTrace.make @@ Exn (Failure __LOC__)) + (fun hn ho -> + if not (Block_hash.equal hn ho) then + Assert.fail_msg "Invalid locator %i" max_size) + l_exp + l_lin + in + let stop = locator_limit + 20 in + let rec loop size = + if size < stop then + let* _ = check_locator size in + loop (size + 5) + else return_unit + in + loop 1 + +let bench = [Test_locator.wrap "bench locator" bench_locator] + +let () = + let open Lwt_syntax in + Lwt_main.run + (let* () = Tezos_base_unix.Internal_event_unix.init () in + Alcotest_lwt.run ~__FILE__ "tezos-store-bench" [("locator bench", bench)]) + +let () = Tezt.Test.run () diff --git a/src/lib_store/unix/test/bench/dune b/src/lib_store/unix/test/bench/dune new file mode 100644 index 0000000000000000000000000000000000000000..fe4fe776392c341c89d287883444e2dc6572a9b2 --- /dev/null +++ b/src/lib_store/unix/test/bench/dune @@ -0,0 +1,16 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(executable + (name bench) + (instrumentation (backend bisect_ppx)) + (libraries + tezos-base + tezt + octez-alcotezt + src_lib_store_unix_test_tezt_lib) + (flags + (:standard) + -open Tezos_base.TzPervasives + -open Octez_alcotezt + -open Src_lib_store_unix_test_tezt_lib)) diff --git a/src/lib_store/unix/test/dune b/src/lib_store/unix/test/dune index 86954a3911562cae353453af98345a881cf50d7b..98d0d1ee061b68a331c422a8550c78a08f0603aa 100644 --- a/src/lib_store/unix/test/dune +++ b/src/lib_store/unix/test/dune @@ -1,17 +1,11 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executables - (names - test - test_consistency - test_locator - test_cemented_store - test_block_store - test_protocol_store - test_store - test_testchain) +(library + (name src_lib_store_unix_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries + tezt.core tezos-base tezos-crypto tezos-context-ops @@ -28,14 +22,13 @@ tezos-embedded-protocol-alpha tezos-protocol-alpha.parameters tezos-protocol-plugin-alpha - alcotest-lwt - tezos-test-helpers - tezos-test-helpers-extra) - (link_flags - (:standard) - (:include %{workspace_root}/macos-link-flags.sexp)) + octez-alcotezt + tezos-test-helpers) + (library_flags (:standard -linkall)) (flags (:standard) + -open Tezt_core + -open Tezt_core.Base -open Tezos_base.TzPervasives -open Tezos_crypto -open Tezos_context_ops @@ -49,48 +42,37 @@ -open Tezos_protocol_updater -open Tezos_protocol_alpha_parameters -open Tezos_protocol_plugin_alpha - -open Tezos_test_helpers)) - -(rule - (alias runtest) - (package tezos-store) - (action (run %{exe:test_cemented_store.exe}))) - -(rule - (alias runtest) - (package tezos-store) - (action (run %{exe:test_consistency.exe}))) - -(rule - (alias runtest) - (package tezos-store) - (action (run %{exe:test_block_store.exe}))) - -(rule - (alias runtest) - (package tezos-store) - (action (run %{exe:test_protocol_store.exe}))) - -(rule - (alias runtest) - (package tezos-store) - (action (run %{exe:test_store.exe}))) - -(rule - (alias runtest) - (package tezos-store) - (action (run %{exe:test_testchain.exe}))) + -open Octez_alcotezt + -open Tezos_test_helpers) + (modules + test + test_snapshots + test_reconstruct + test_history_mode_switch + alpha_utils + test_consistency + test_locator + test_cemented_store + test_block_store + test_protocol_store + test_store + test_testchain + test_utils + assert_lib)) -(rule - (alias runtest) - (package tezos-store) - (action (setenv SLOW_TEST false (run %{exe:test.exe})))) +(executable + (name main) + (instrumentation (backend bisect_ppx --bisect-sigterm)) + (libraries + src_lib_store_unix_test_tezt_lib + tezt) + (link_flags + (:standard) + (:include %{workspace_root}/macos-link-flags.sexp)) + (modules main)) -(rule - (alias test_slow_manual) - (action (setenv SLOW_TEST true (run %{exe:test.exe})))) +(rule (alias runtezt) (package tezos-store) (action (run %{dep:./main.exe}))) (rule - (alias runtest_locator_bench) - (package tezos-store) - (action (run %{exe:test_locator.exe} --bench))) + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/src/lib_store/unix/test/slow/dune b/src/lib_store/unix/test/slow/dune new file mode 100644 index 0000000000000000000000000000000000000000..00a64ea6fa9104e495aa4796b827519bacd7d2de --- /dev/null +++ b/src/lib_store/unix/test/slow/dune @@ -0,0 +1,17 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(executable + (name test_slow) + (instrumentation (backend bisect_ppx)) + (libraries + tezos-base + tezt + octez-alcotezt + src_lib_store_unix_test_tezt_lib) + (flags + (:standard) + -open Tezos_base.TzPervasives + -open Octez_alcotezt + -open Src_lib_store_unix_test_tezt_lib) + (modules test_slow)) diff --git a/src/lib_store/unix/test/slow/test_slow.ml b/src/lib_store/unix/test/slow/test_slow.ml new file mode 100644 index 0000000000000000000000000000000000000000..5b5b3677f3103f62e93ae6e0567d678317026e72 --- /dev/null +++ b/src/lib_store/unix/test/slow/test_slow.ml @@ -0,0 +1,48 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2020 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Testing + _______ + + Invocation: dune exec src/lib_store/unix/test/slow/test_slow.exe \ + -- --file test_slow.ml + Subject: Store slow tests. Same tests as test.ml, but run on the + side and not in the CI +*) + +let () = + let open Lwt_syntax in + Lwt_main.run + (let* () = Tezos_base_unix.Internal_event_unix.init () in + Alcotest_lwt.run + ~__FILE__ + "tezos-store-slow" + [ + Test_snapshots.tests `Slow; + Test_reconstruct.tests `Slow; + Test_history_mode_switch.tests `Slow; + ]) + +let () = Tezt.Test.run () diff --git a/src/lib_store/unix/test/test.ml b/src/lib_store/unix/test/test.ml index 34705c983fe0a9f97c9d2d4edd57324eb0cc61ab..fd269c2d9ea97ff40e10b41b3df7f97084b35346 100644 --- a/src/lib_store/unix/test/test.ml +++ b/src/lib_store/unix/test/test.ml @@ -23,25 +23,23 @@ (* *) (*****************************************************************************) -(* Several of the tests take the additional [SLOW_TEST] environment variable. - We group those tests in this here executable for simplicity. *) +(** Testing + _______ + + Component: Store + Invocation: dune exec src/lib_store/unix/test/main.exe --file test.ml + Subject: Store tests ( snapshots, reconstruct, history_mode_switch ) +*) let () = - let speed = - try - let s = Sys.getenv "SLOW_TEST" in - match String.(trim (uncapitalize_ascii s)) with - | "true" | "1" | "yes" -> `Slow - | _ -> `Quick - with Not_found -> `Quick - in let open Lwt_syntax in Lwt_main.run (let* () = Tezos_base_unix.Internal_event_unix.init () in Alcotest_lwt.run + ~__FILE__ "tezos-store" [ - Test_snapshots.tests speed; - Test_reconstruct.tests speed; - Test_history_mode_switch.tests speed; + Test_snapshots.tests `Quick; + Test_reconstruct.tests `Quick; + Test_history_mode_switch.tests `Quick; ]) diff --git a/src/lib_store/unix/test/test_block_store.ml b/src/lib_store/unix/test/test_block_store.ml index 7ff0d9910a2af3d48c5f177c3333c4277949903e..31f4bf7f56f79da98847381a15bafed857bafb7d 100644 --- a/src/lib_store/unix/test/test_block_store.ml +++ b/src/lib_store/unix/test/test_block_store.ml @@ -23,8 +23,16 @@ (* *) (*****************************************************************************) +(** Testing + _______ + + Component: Store + Invocation: dune exec src/lib_store/unix/test/main.exe \ + -- --file test_block_store.ml + Subject: Store tests ( block storing and access ) +*) + module Assert = Assert -module Assert_lib = Lib_test_extra.Assert_lib open Test_utils open Block_store @@ -757,4 +765,4 @@ let () = let open Lwt_syntax in Lwt_main.run (let* () = Tezos_base_unix.Internal_event_unix.init () in - Alcotest_lwt.run "tezos-store" [tests]) + Alcotest_lwt.run ~__FILE__ "tezos-store" [tests]) diff --git a/src/lib_store/unix/test/test_cemented_store.ml b/src/lib_store/unix/test/test_cemented_store.ml index c7b0daf17bc8730cb68466cd654ded9fa07d7a15..49ef637a4fe5f3ccc72d8ccb05712e680a0fbe9c 100644 --- a/src/lib_store/unix/test/test_cemented_store.ml +++ b/src/lib_store/unix/test/test_cemented_store.ml @@ -23,7 +23,14 @@ (* *) (*****************************************************************************) -module Assert_lib = Lib_test_extra.Assert_lib +(** Testing + _______ + + Component: Store + Invocation: dune exec src/lib_store/unix/test/main.exe -- --file test_cemented_store.ml + Subject: Store tests ( block cementing ) +*) + open Test_utils let assert_presence_in_cemented_store ?(with_metadata = true) cemented_store @@ -144,4 +151,4 @@ let () = let open Lwt_syntax in Lwt_main.run (let* () = Tezos_base_unix.Internal_event_unix.init () in - Alcotest_lwt.run "tezos-store" [tests]) + Alcotest_lwt.run ~__FILE__ "tezos-store" [tests]) diff --git a/src/lib_store/unix/test/test_consistency.ml b/src/lib_store/unix/test/test_consistency.ml index 72b62d241b92cbb7cbde861672a7a605e3565bf5..36e269c435e93a5fa8281b0325cfda49ae86e087 100644 --- a/src/lib_store/unix/test/test_consistency.ml +++ b/src/lib_store/unix/test/test_consistency.ml @@ -23,6 +23,15 @@ (* *) (*****************************************************************************) +(** Testing + _______ + + Component: Store + Invocation: dune exec src/lib_store/unix/test/main.exe \ + -- --file test_consistency.ml + Subject: Store consistency tests +*) + open Test_utils let nb_protocols = 5 @@ -302,6 +311,7 @@ let make_tests = let () = Lwt_main.run @@ Alcotest_lwt.run + ~__FILE__ "tezos-store" [ ( "consistency", diff --git a/src/lib_store/unix/test/test_history_mode_switch.ml b/src/lib_store/unix/test/test_history_mode_switch.ml index 8db19853a55a6243d2829ec3d2e7a57fbdaa4156..87e3781ce8cadcf8547ff49bf77bcc019c6dd822 100644 --- a/src/lib_store/unix/test/test_history_mode_switch.ml +++ b/src/lib_store/unix/test/test_history_mode_switch.ml @@ -24,6 +24,14 @@ (* *) (*****************************************************************************) +(** Testing + _______ + + Component: Store + Invocation: dune exec src/lib_store/unix/test/main.exe -- --match history_mode_switch + Subject: Store tests ( history_mode_switch ) +*) + open Test_utils open History_mode @@ -377,32 +385,34 @@ let make_tests speed parameters = ~json:(Default_parameters.json_of_parameters parameters) in let history_modes = - match speed with - | `Slow -> - [ - Archive; - Full (Some {offset = 0}); - Full (Some {offset = 3}); - default_full; - Full (Some {offset = 7}); - Full (Some {offset = 10}); - Rolling (Some {offset = 0}); - Rolling (Some {offset = 3}); - default_rolling; - Rolling (Some {offset = 7}); - Rolling (Some {offset = 10}); - default; - ] - | `Quick -> - [ - Archive; - Full (Some {offset = 0}); - default_full; - Rolling (Some {offset = 0}); - default_rolling; - Full (Some {offset = 5}); - Rolling (Some {offset = 5}); - ] + List.sort_uniq + compare + (match speed with + | `Slow -> + [ + Archive; + Full (Some {offset = 0}); + Full (Some {offset = 3}); + default_full; + Full (Some {offset = 7}); + Full (Some {offset = 10}); + Rolling (Some {offset = 0}); + Rolling (Some {offset = 3}); + default_rolling; + Rolling (Some {offset = 7}); + Rolling (Some {offset = 10}); + default; + ] + | `Quick -> + [ + Archive; + Full (Some {offset = 0}); + default_full; + Rolling (Some {offset = 0}); + default_rolling; + Full (Some {offset = 5}); + Rolling (Some {offset = 5}); + ]) in let blocks_per_cycle = parameters.constants.blocks_per_cycle in let nb_blocks_to_bake = [9 * Int32.to_int blocks_per_cycle] in @@ -424,6 +434,7 @@ let make_tests speed parameters = in Some (wrap_simple_store_init_test + ~speed ~with_gc:true ~keep_dir:false ~history_mode:from_hm @@ -440,7 +451,7 @@ let make_tests speed parameters = store ))) permutations -let make_test_drag _speed parameters = +let make_test_drag speed parameters = let patch_context ctxt = Alpha_utils.patch_context ctxt @@ -451,6 +462,7 @@ let make_test_drag _speed parameters = let test_descr = "Check savepoint drag with cycles bigger that max_op_ttl" in let from_hm = default_full in wrap_simple_store_init_test + ~speed ~with_gc:true ~keep_dir:false ~history_mode:from_hm diff --git a/src/lib_store/unix/test/test_locator.ml b/src/lib_store/unix/test/test_locator.ml index ccde7c2ff3e12d810d0247683ba2aba4c658f66d..3cca2f2f60ba26f7f36955923f6989741936f321 100644 --- a/src/lib_store/unix/test/test_locator.ml +++ b/src/lib_store/unix/test/test_locator.ml @@ -25,13 +25,12 @@ (** Testing ------- - Component: Shell - Invocation: dune exec src/lib_shell/test/test_locator.exe + Component: Store + Invocation: dune exec src/lib_shell/test/main.exe \ + -- --file test_locator.ml Subject: Checks operations on locators. *) -(** Basic blocks *) - module Assert = Assert (** Basic blocks *) @@ -374,66 +373,6 @@ let compute_size_chain size_locator = chain 2 months 86k covered by locator 120 *) -(** Test if the linear and exponential locator are the same and outputs - their timing. - Run the test with: - $ dune build @runtest_locator - Copy the output to a file timing.dat and plot it with: - $ generate_locator_plot.sh timing.dat -*) -let bench_locator base_dir = - let open Lwt_result_syntax in - let size_chain = 80000 in - (* timing locators with average over [runs] times *) - let runs = 10 in - let _ = Printf.printf "#runs %i\n" runs in - (* limit after which exp should go linear *) - let exp_limit = compute_size_chain 120 in - let _ = Printf.printf "#exp_limit %i\n" exp_limit in - (* size after which locator always reaches genesis *) - let locator_limit = compute_size_locator size_chain in - let _ = Printf.printf "#locator_limit %i\n" locator_limit in - let*! store = init_chain base_dir in - let chain_store = Store.main_chain_store store in - time1 (fun () -> make_empty_chain chain_store size_chain) - |> fun (res, t_chain) -> - let _ = - Printf.printf - "#size_chain %i built in %f sec\n# size exp lins\n" - size_chain - t_chain - in - let*! head = res in - let check_locator max_size : unit tzresult Lwt.t = - let*! caboose, _ = Store.Chain.caboose chain_store in - let* block = Store.Block.read_block chain_store head in - time ~runs (fun () -> - Store.Chain.compute_locator chain_store ~max_size block seed) - |> fun (l_exp, t_exp) -> - time ~runs (fun () -> - compute_linear_locator chain_store ~caboose ~max_size block) - |> fun (l_lin, t_lin) -> - let*! {Block_locator.history = l_exp; _} = l_exp in - let*! {Block_locator.history = l_lin; _} = l_lin in - let _ = Printf.printf "%10i %f %f\n" max_size t_exp t_lin in - Lwt.return - @@ List.iter2 - ~when_different_lengths:(TzTrace.make @@ Exn (Failure __LOC__)) - (fun hn ho -> - if not (Block_hash.equal hn ho) then - Assert.fail_msg "Invalid locator %i" max_size) - l_exp - l_lin - in - let stop = locator_limit + 20 in - let rec loop size = - if size < stop then - let* _ = check_locator size in - loop (size + 5) - else return_unit - in - loop 1 - let test_protocol_locator base_dir = let open Lwt_result_syntax in let*! store = init_chain base_dir in @@ -619,22 +558,5 @@ let tests = wrap "test protocol locator" test_protocol_locator; ] -let bench = [wrap "bench locator" bench_locator] - -let tests = - tests - @ - if Array.length Sys.argv > 1 then - match Sys.argv.(1) with "--bench" -> bench | _ -> [] - else [] - -let tests = - tests - @ - if Array.length Sys.argv > 1 then - match Sys.argv.(1) with "--bench" -> bench | _ -> [] - else [] - let () = - Alcotest_lwt.run ~argv:[|""|] "tezos-store" [("locator", tests)] - |> Lwt_main.run + Alcotest_lwt.run ~__FILE__ "tezos-store" [("locator", tests)] |> Lwt_main.run diff --git a/src/lib_store/unix/test/test_protocol_store.ml b/src/lib_store/unix/test/test_protocol_store.ml index bae252a0d16e58b67d31e7f7e491751d7debc614..1e6189bd904a4b30320529fbda39af924abc96b3 100644 --- a/src/lib_store/unix/test/test_protocol_store.ml +++ b/src/lib_store/unix/test/test_protocol_store.ml @@ -23,6 +23,15 @@ (* *) (*****************************************************************************) +(** Testing + _______ + + Component: Store + Invocation: dune exec src/lib_store/unix/test/main.exe \ + -- --file test_protocol_store.ml + Subject: Store tests ( protocol ) +*) + open Test_utils let test_protocol_store _ store = @@ -74,4 +83,4 @@ let () = let open Lwt_syntax in Lwt_main.run (let* () = Tezos_base_unix.Internal_event_unix.init () in - Alcotest_lwt.run "tezos-store" [tests]) + Alcotest_lwt.run ~__FILE__ "tezos-store" [tests]) diff --git a/src/lib_store/unix/test/test_reconstruct.ml b/src/lib_store/unix/test/test_reconstruct.ml index 0c7fc452c962db258659c5d56a826c8dbd814179..fff158336a36861b4a102b76ac3e4162a259701d 100644 --- a/src/lib_store/unix/test/test_reconstruct.ml +++ b/src/lib_store/unix/test/test_reconstruct.ml @@ -24,7 +24,14 @@ (* *) (*****************************************************************************) -module Assert_lib = Lib_test_extra.Assert_lib +(** Testing + _______ + + Component: Store + Invocation: dune exec src/lib_store/unix/test/main.exe -- --match construct + Subject: Store tests ( reconstruct ) +*) + open Test_utils (* Export mode used to export snapshot. Tar is seleceted by @@ -167,6 +174,7 @@ let make_tests_bootstrapped speed patch_context = nb_blocks_to_bake in wrap_simple_store_init_test + ~speed ~patch_context ~history_mode ~keep_dir:false @@ -318,6 +326,7 @@ let make_tests_snapshoted speed patch_context = nb_blocks_to_bake in wrap_simple_store_init_test + ~speed ~patch_context ~history_mode ~keep_dir:false diff --git a/src/lib_store/unix/test/test_snapshots.ml b/src/lib_store/unix/test/test_snapshots.ml index bfce21c214dae2d27ede773fdf1573b28d57e45e..5084c6fb27d638e6d80da2f3c16e18cca645a1ba 100644 --- a/src/lib_store/unix/test/test_snapshots.ml +++ b/src/lib_store/unix/test/test_snapshots.ml @@ -25,7 +25,14 @@ (* *) (*****************************************************************************) -module Assert_lib = Lib_test_extra.Assert_lib +(** Testing + _______ + + Component: Store + Invocation: dune exec src/lib_store/unix/test/main.exe -- --match "tezos-store: snapshots" + Subject: Store tests ( snapshots ) +*) + open Test_utils let check_import_invariants ~test_descr ~rolling @@ -469,6 +476,7 @@ let make_tests speed genesis_parameters = | None | Some _ -> Some (wrap_test + ~speed ~with_gc:true ~keep_dir:false ~history_mode @@ -486,7 +494,7 @@ let make_tests speed genesis_parameters = store )))) permutations -let test_rolling export_mode = +let test_rolling speed export_mode = let patch_context ctxt = Alpha_utils.default_patch_context ctxt in let test (store_dir, context_dir) store = let open Lwt_result_syntax in @@ -561,6 +569,7 @@ let test_rolling export_mode = return_unit in wrap_test + ~speed ~keep_dir:false ~with_gc:true ~history_mode:History_mode.default @@ -573,9 +582,9 @@ let test_rolling export_mode = export_mode, test ) -let make_tests_rolling = +let make_tests_rolling speed = let export_mode = Snapshots.[Tar; Raw] in - List.map test_rolling export_mode + List.map (test_rolling speed) export_mode (* This test aims to check that the caboose and savepoint are well dragged when the first merge occurs, after a rolling snapshot @@ -586,7 +595,7 @@ let make_tests_rolling = In this test, we need to increase the number of blocks per cycle to avoid the max_op_ttl to hide this potential issue. The exported block must be outside the max_op_ttl of the next checkpoint. *) -let test_drag_after_import export_mode = +let test_drag_after_import speed export_mode = let open Lwt_result_syntax in let constants = Default_parameters. @@ -715,6 +724,7 @@ let test_drag_after_import export_mode = return_unit in wrap_test + ~speed ~keep_dir:false ~with_gc:true ~history_mode:History_mode.default @@ -727,9 +737,9 @@ let test_drag_after_import export_mode = export_mode, test ) -let make_tests_drag_after_import = +let make_tests_drag_after_import speed = let export_mode = Snapshots.[Tar; Raw] in - List.map test_drag_after_import export_mode + List.map (test_drag_after_import speed) export_mode (* TODO: export => import => export => import from full & rolling @@ -745,8 +755,8 @@ let tests speed = parameters_of_constants {constants_sandbox with consensus_threshold = 0}) in - let tests_rolling = make_tests_rolling in - let tests_drag_after_import = make_tests_drag_after_import in + let tests_rolling = make_tests_rolling speed in + let tests_drag_after_import = make_tests_drag_after_import speed in tests_rolling @ tests_drag_after_import @ generated_tests in ("snapshots", test_cases) diff --git a/src/lib_store/unix/test/test_store.ml b/src/lib_store/unix/test/test_store.ml index 6b783fe0bc19705c24cad59081fba05221fae63b..f95d4ad6ab427de905caa82f8b3d90183d011681 100644 --- a/src/lib_store/unix/test/test_store.ml +++ b/src/lib_store/unix/test/test_store.ml @@ -24,6 +24,15 @@ (* *) (*****************************************************************************) +(** Testing + _______ + + Component: Store + Invocation: dune exec src/lib_store/unix/test/main.exe \ + -- --file test_store.ml + Subject: Store tests +*) + open Test_utils let test_cycles store = @@ -752,4 +761,4 @@ let () = let open Lwt_syntax in Lwt_main.run (let* () = Tezos_base_unix.Internal_event_unix.init () in - Alcotest_lwt.run "tezos-store" [tests]) + Alcotest_lwt.run ~__FILE__ "tezos-store" [tests]) diff --git a/src/lib_store/unix/test/test_testchain.ml b/src/lib_store/unix/test/test_testchain.ml index 63767080b50d003d347aa06820cc94220e581b1c..aea9163e7ce5aedb55e6496965a54e8e13e4014c 100644 --- a/src/lib_store/unix/test/test_testchain.ml +++ b/src/lib_store/unix/test/test_testchain.ml @@ -22,6 +22,13 @@ (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) +(** Testing + _______ + + Component: Store + Invocation: dune exec src/lib_store/unix/test/main.exe -- --file test_testchain.ml + Subject: Store tests ( testchain ) +*) open Test_utils @@ -155,4 +162,4 @@ let () = let open Lwt_syntax in Lwt_main.run (let* () = Tezos_base_unix.Internal_event_unix.init () in - Alcotest_lwt.run "tezos-store" [tests]) + Alcotest_lwt.run ~__FILE__ "tezos-store" [tests]) diff --git a/src/lib_store/unix/test/test_utils.ml b/src/lib_store/unix/test/test_utils.ml index f1d877b1f3c628e54e64882a03e948d069d20206..270b65cb274c40a096bac08e5ff36f9449505904 100644 --- a/src/lib_store/unix/test/test_utils.ml +++ b/src/lib_store/unix/test/test_utils.ml @@ -24,7 +24,6 @@ (*****************************************************************************) module Assert = Assert -module Assert_lib = Lib_test_extra.Assert_lib open Alcotest_lwt open Filename.Infix @@ -834,3 +833,5 @@ module Example_tree = struct in wrap_test ?keep_dir ?history_mode ?with_gc (name, f) end + +let speed_to_string = function `Slow -> "slow" | `Quick -> "quick" diff --git a/src/lib_test/dune b/src/lib_test/dune index 3e9eb9068d179bbab7f8af971586648c5138c941..2b36f26c20fcdf48e43c8f1fa04420edd3e6ec2f 100644 --- a/src/lib_test/dune +++ b/src/lib_test/dune @@ -26,15 +26,3 @@ testable)) (rule (alias runtest_js) (action progn)) - -(library - (name lib_test_extra) - (public_name tezos-test-helpers-extra) - (instrumentation (backend bisect_ppx)) - (libraries - tezos-base - tezos-crypto - tezos-test-helpers) - (modules assert_lib)) - -(rule (alias runtest_js_base) (action progn)) diff --git a/tezt/lib_alcotezt/alcotest.ml b/tezt/lib_alcotezt/alcotest.ml index 8c095565955b8eba46e8fd424e5a956d63b20d61..b4ffc81f6223c5aaf045eb140db384df9115028d 100644 --- a/tezt/lib_alcotezt/alcotest.ml +++ b/tezt/lib_alcotezt/alcotest.ml @@ -24,6 +24,7 @@ (*****************************************************************************) open Tezt_core +open Tezt_core.Base type return = unit @@ -45,14 +46,11 @@ let run ~__FILE__ library_name tests = |> List.iter @@ fun (test_case_name, speed_level, body) -> let tags = "alcotezt" - :: (match speed_level with `Quick -> ["quick"] | `Slow -> []) + :: (match speed_level with `Quick -> ["quick"] | `Slow -> ["slow"]) @ proto_tags in - Test.register - ~__FILE__ - ~title:(library_name ^ ": " ^ test_name ^ " (" ^ test_case_name ^ ")") - ~tags - @@ fun () -> + let title = sf "%s: %s (%s)" library_name test_name test_case_name in + Test.register ~__FILE__ ~title ~tags @@ fun () -> body () ; Base.unit diff --git a/tezt/lib_alcotezt/alcotest_lwt.ml b/tezt/lib_alcotezt/alcotest_lwt.ml index 5aeaab5c2c324fd205f16c30b2f97cfd4c119daf..ce66d3e2e04bf8f686a4e06e8f9cd350de973393 100644 --- a/tezt/lib_alcotezt/alcotest_lwt.ml +++ b/tezt/lib_alcotezt/alcotest_lwt.ml @@ -55,12 +55,9 @@ let run ~__FILE__ library_name tests = |> List.iter @@ fun (test_case_name, speed_level, body) -> let tags = "alcotezt" - :: (match speed_level with `Quick -> ["quick"] | `Slow -> []) + :: (match speed_level with `Quick -> ["quick"] | `Slow -> ["slow"]) @ proto_tags in - Test.register - ~__FILE__ - ~title:(library_name ^ ": " ^ test_name ^ " (" ^ test_case_name ^ ")") - ~tags - @@ fun () -> body ()) ; + let title = sf "%s: %s (%s)" library_name test_name test_case_name in + Test.register ~__FILE__ ~title ~tags @@ fun () -> body ()) ; unit diff --git a/tezt/tests/dune b/tezt/tests/dune index bcdd6e53ce15ec0f62e363cff8929881d939cb62..acc73cbf93241591e493a95ee080eaaa0106f54b 100644 --- a/tezt/tests/dune +++ b/tezt/tests/dune @@ -65,6 +65,7 @@ src_lib_webassembly_tests_tezt_lib src_lib_version_test_tezt_lib src_lib_tree_encoding_test_tezt_lib + src_lib_store_unix_test_tezt_lib src_lib_stdlib_unix_test__tezt_lib src_lib_stdlib_test_unix_tezt_lib src_lib_stdlib_test_tezt_lib