Skip to content

Commit

Permalink
fix pipeline tests + refactor state table init
Browse files Browse the repository at this point in the history
  • Loading branch information
sudeepdino008 committed Aug 3, 2023
1 parent 3f276cd commit 7d4436b
Show file tree
Hide file tree
Showing 5 changed files with 30,238 additions and 5 deletions.
26 changes: 25 additions & 1 deletion lib/rudder/pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -160,33 +160,57 @@ defmodule Rudder.Pipeline do
Logger.warn("key #{bsp_key} written to backlog with #{urls}; error: #{inspect(err)}")
end

def init_state() do
defp init_state() do
GVA.gnew(:state)
GVA.gput(:state, :retry_failed_bsp, false)
GVA.gput(:state, :bsp_upload_status, :ok)
end

def set_retry_failed_bsp() do
if !GVA.gexists(:state) do
init_state()
end

GVA.gput(:state, :retry_failed_bsp, true)
end

def clear_retry_failed_bsp() do
if !GVA.gexists(:state) do
init_state()
end

GVA.gput(:state, :retry_failed_bsp, false)
end

def is_retry_failed_bsp() do
if !GVA.gexists(:state) do
init_state()
end

GVA.gget(:state, :retry_failed_bsp)
end

def is_bsp_upload_status_ok() do
if !GVA.gexists(:state) do
init_state()
end

:ok == GVA.gget(:state, :bsp_upload_status)
end

def bsp_upload_success() do
if !GVA.gexists(:state) do
init_state()
end

GVA.gput(:state, :bsp_upload_status, :ok)
end

def bsp_upload_failure() do
if !GVA.gexists(:state) do
init_state()
end

GVA.gput(:state, :bsp_upload_status, :err)
end
end
2 changes: 0 additions & 2 deletions lib/rudder/proof_chain/block_specimen_event_listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ defmodule Rudder.ProofChain.BlockSpecimenEventListener do

case Process.whereis(register_name) do
nil ->
Logger.info("initializing state for GVA")
Rudder.Pipeline.init_state()
:ok

_pid ->
Expand Down
9 changes: 9 additions & 0 deletions lib/rudder/util/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ defmodule Rudder.Util do
end
end

@doc """
Check if a table exists.
"""
defmacro gexists(name) do
quote do
:ets.info(unquote(name)) != :undefined
end
end

@doc """
Put a value in a variable table.
"""
Expand Down
30,201 changes: 30,200 additions & 1 deletion test/evm/data/15548376-segment.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion test/evm/evm_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ defmodule SupervisionTreeTest do
block_id = "1234_f_"

specimen = get_sample_specimen!()
{:ok, bpid} = Rudder.BlockProcessor.start_link(["http://evm-server:3002"])

{:ok, bpid} =
Rudder.BlockProcessor.start_link([Application.get_env(:rudder, :evm_server_url)])

{:error, error_msg} = GenServer.call(bpid, {:process, "invalid content"}, 60_000)

assert error_msg ==
Expand Down

0 comments on commit 7d4436b

Please sign in to comment.