Packages
exq
0.12.0
0.23.0
0.22.0
0.21.0
0.20.0
0.19.0
0.18.0
0.17.0
0.16.2
0.16.1
0.16.0
0.15.0
0.14.0
0.13.5
0.13.4
0.13.3
0.13.2
0.13.1
0.13.0
0.12.2
0.12.1
0.12.0
0.11.0
0.10.1
0.10.0
0.9.1
0.9.0
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.3
0.7.2
0.7.1
0.7.0
0.6.5
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
0.5.0
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.0
0.2.3
0.2.2
0.2.1
0.2.0
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.2
Exq is a job processing library compatible with Resque / Sidekiq for the Elixir language.
Current section
Files
Jump to
Current section
Files
test/flaky_connection_test.exs
defmodule FlakyConnectionTest do
use ExUnit.Case
require Logger
import ExqTestUtil
@moduletag :failure_scenarios
setup do
TestRedis.setup
on_exit fn ->
TestRedis.teardown
end
:ok
end
defmodule Worker do
def perform(_) do
send(:tester, :done)
end
end
test "redis_timeout allows for higher latency" do
Application.start(:ranch)
conn = FlakyConnection.start(redis_host(), redis_port())
#Needs to be x2 latency + ~10
Mix.Config.persist([exq: [redis_timeout: 2010]])
Process.register(self(), :tester)
{:ok, sup} = Exq.start_link([name: ExqPerf, port: conn.port])
FlakyConnection.set_latency(conn, 1000)
{:ok, _} = Exq.enqueue(ExqPerf.Enqueuer, "default", FlakyConnectionTest.Worker, ["work"])
stop_process(sup)
end
test "redis_timeout higher than 5000 without genserver_timeout" do
Application.start(:ranch)
conn = FlakyConnection.start(redis_host(), redis_port())
#Needs to be x2 latency + ~10
Mix.Config.persist([exq: [redis_timeout: 11010]])
Process.register(self(), :tester)
{:ok, sup} = Exq.start_link(port: conn.port)
FlakyConnection.set_latency(conn, 5500)
result = try do
{:ok, _} = Exq.enqueue(Exq.Enqueuer, "default", FlakyConnectionTest.Worker, ["work"])
catch
:exit, {:timeout, _} -> :failed
end
assert result == :failed
stop_process(sup)
end
test "redis_timeout higher than 5000 with genserver_timeout" do
Application.start(:ranch)
conn = FlakyConnection.start(redis_host(), redis_port())
#redis_timeout needs to be x2 latency + ~10
#genserver_timeout needs to be x2 latency + ~30
Mix.Config.persist([exq: [redis_timeout: 11010, genserver_timeout: 11030]])
Process.register(self(), :tester)
{:ok, sup} = Exq.start_link(port: conn.port)
FlakyConnection.set_latency(conn, 5500)
{:ok, _} = Exq.enqueue(Exq.Enqueuer, "default", FlakyConnectionTest.Worker, ["work"])
stop_process(sup)
end
end