Skip to content

Commit

Permalink
test: remove troublesome test
Browse files Browse the repository at this point in the history
That test was mocking some ERTS internals and was causing Mix panic on
exit. We need to find a better way to test this functionality rather
than mocking so low level stuff in the VM, as it could break anytime.
  • Loading branch information
hauleth committed Feb 4, 2025
1 parent 4555887 commit a8324f9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 35 deletions.
1 change: 1 addition & 0 deletions test/integration/proxy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ defmodule Supavisor.Integration.ProxyTest do
P.query!(origin, "select * from public.test where details = 'test_insert'", [])
end

@tag cluster: true
test "query via another node", %{proxy: proxy, user: user} do
assert {:ok, _pid, node2} = Cluster.start_node()

Expand Down
37 changes: 2 additions & 35 deletions test/supavisor/db_handler_test.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
defmodule Supavisor.DbHandlerTest do
use ExUnit.Case, async: false

alias Supavisor.DbHandler, as: Db
alias Supavisor.Protocol.Server

# import Mock
@id {{:single, "tenant"}, "user", :transaction, "postgres", nil}

Expand Down Expand Up @@ -152,40 +153,6 @@ defmodule Supavisor.DbHandlerTest do
end
end

describe "handle_event/4 with write replica message" do
test "updates caller in data for session mode" do
proto = :tcp
bin = "response_data" <> Server.ready_for_query()
caller_pid = self()

data = %{
id: @id,
caller: caller_pid,
sock: {:gen_tcp, nil},
stats: %{},
mode: :session,
sent: false
}

state = :some_state
event = {proto, :dummy_value, bin}

:meck.new(:prim_inet, [:unstick, :passthrough])
:meck.new(:inet, [:unstick, :passthrough])

:meck.expect(:prim_inet, :getstat, fn _, _ ->
{:ok, [{:recv_oct, 21}, {:send_oct, 37}]}
end)

:meck.expect(:inet, :setopts, fn _, _ -> :ok end)

:keep_state_and_data = Db.handle_event(:info, event, state, data)

:meck.unload(:prim_inet)
:meck.unload(:inet)
end
end

describe "check_ready/1" do
test "ready_for_query valid" do
assert {:ready_for_query, :transaction_block} == Db.check_ready(<<90, 0, 0, 0, 5, ?T>>)
Expand Down
1 change: 1 addition & 0 deletions test/supavisor/syn_handler_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule Supavisor.SynHandlerTest do

@id {{:single, "syn_tenant"}, "postgres", :session, "postgres", nil}

@tag cluster: true
test "resolving conflict" do
{:ok, _pid, node2} = Cluster.start_node()

Expand Down
1 change: 1 addition & 0 deletions test/supavisor_web/controllers/metrics_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule SupavisorWeb.MetricsControllerTest do
{:ok, conn: new_conn}
end

@tag cluster: true
test "exporting metrics", %{conn: conn} do
{:ok, _pid, node2} = Cluster.start_node()

Expand Down

0 comments on commit a8324f9

Please sign in to comment.