饾攪饾敘饾敱饾敘饾敮饾敧饾敠饾敨饾敠饾敯饾敱饾敠饾敔 饾敯饾敠饾敧饾敳饾敥饾敒饾敱饾敠饾敩饾敨 饾敱饾敘饾敯饾敱饾敠饾敨饾敜
饾攪饾敘饾敱饾敘饾敮饾敧饾敠饾敨饾敠饾敯饾敱饾敠饾敔 饾敯饾敠饾敧饾敳饾敥饾敒饾敱饾敠饾敩饾敨 饾敱饾敘饾敯饾敱饾敠饾敨饾敜 deterministic: of or relating to a process or model in which the output is determined solely by the input and initial conditions, thereby always returning the same results ( stochastic ): The algorithms are simple and deterministic, so the results are predictable and reproducible. Example based testing Example based testing works fine for simple cases where there鈥檚 only a small number of actions that matter. let%test_unit "append entries: truncates the log on entry conflict" = let storage = make { dir = Test_util.temp_dir () } in (* Leader adds some entries to the replica's log. *) append_entries storage (last_log_index storage) [ { term = 1L; data = "1" }; { term = 2L; data = "2" }; { term = 3L; data = "3" }; ]; (* Another leader overrides the replica's log. *) append_entries storage 2L [ { term = 4L; data = "3" }; { term = 4L; data = "4" } ]; assert (entry_at_index storage 1L = Some { term = 1L; data = "1" }); assert (entry_at_index storage 2L = Some { term = 2L; data = "2" }); (* Entry at index 3 has been overwritten. *) assert (entry_at_index storage 3L = Some { term = 4L; data = "3" }); (* Entry at index 4 is new. *) assert (entry_at_index storage 4L = Some { term = 4L; data = "4" }) It becomes way harder to think of and write the examples when the bugs you鈥檙e looking for only happen after several events that need to happen in a specific order. ...