Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

FacPowErr OTP tests

fac_pow_err/test.livemd

FacPowErr OTP tests

Section

Mix.install([
  {:httpoison, "~> 2.1"}
])
req_time_in_milliseconds = 40000
number_of_connections = 5
delay_time = 8000
Enum.map(1..number_of_connections, fn x ->
  spawn(fn ->
    IO.inspect("start req process #{x}")
    # fac = Enum.random(2_000_000_000..2_000_099_999)
    fac = 34
    before = :os.system_time(:millisecond)

    %HTTPoison.Response{body: body, status_code: sc} =
      HTTPoison.post!(
        "http://localhost:4000/test",
        "{\"value\": #{fac}}",
        [{"Content-Type", "application/json"}],
        recv_timeout: req_time_in_milliseconds,
        hackney: [pool: false]
      )

    after_time = :os.system_time(:millisecond)

    duration = after_time - before - delay_time

    IO.inspect({body, sc, duration}, label: "req #{x}")
  end)
end)