defmodule PaxosTestAditional do # Leader crashes, no concurrent ballots def run_leader_crash_simple_before_decision(name, participants, val) do {cpid, pid} = PaxosTest.init(name, participants, true) send(cpid, :ready) {status, val, a, spare} = try do receive do :start -> IO.puts("#{inspect(name)}: started") [leader | spare] = Enum.sort(participants) [new_leader | _] = spare if name == leader do # Propose when passed with :kill_before_decision will die right before a decision is selected Paxos.propose(pid, 1, val, 1000, :kill_before_decision) end if name == new_leader do Process.sleep(10) PaxosTest.propose_until_commit(pid, 1, val) end if name in spare do {status, val} = PaxosTest.wait_for_decision(pid, 1, 10000) if status != :none, do: IO.puts("#{name}: decided #{inspect(val)}"), else: IO.puts("#{name}: No decision after 10 seconds") {status, val, 10, spare} else {:killed, :none, -1, spare} end end rescue _ -> {:none, :none, 10, []} end send(cpid, :done) receive do :all_done -> Process.sleep(100) ql = if name in spare do IO.puts("#{name}: #{inspect(ql = Process.info(pid, :message_queue_len))}") ql else {:message_queue_len, -1} end PaxosTest.kill_paxos(pid, name) send(cpid, {:finished, name, pid, status, val, a, ql}) end end end