Skip to content

Commit

Permalink
test: cleanup prom_ex test suite (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
hauleth authored May 29, 2024
1 parent 06cd5d5 commit 61b629d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.55
1.1.56
6 changes: 4 additions & 2 deletions test/integration/proxy_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
defmodule Supavisor.Integration.ProxyTest do
require Logger
use Supavisor.DataCase, async: true

require Logger

alias Postgrex, as: P

@tenant "proxy_tenant1"
Expand Down Expand Up @@ -227,7 +229,7 @@ defmodule Supavisor.Integration.ProxyTest do
first_pass = conn.("postgres")
new_pass = conn.("postgres_new")

{:ok, pid} = parse_uri(first_pass) |> single_connection()
assert {:ok, pid} = parse_uri(first_pass) |> single_connection()

assert [%Postgrex.Result{rows: [["1"]]}] = P.SimpleConnection.call(pid, {:query, "select 1;"})

Expand Down
19 changes: 10 additions & 9 deletions test/supavisor/prom_ex_test.exs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
defmodule Supavisor.PromExTest do
use ExUnit.Case, async: true
require Logger
alias Supavisor.Monitoring.PromEx
use Supavisor.DataCase
alias Postgrex, as: P

alias Supavisor.Monitoring.PromEx

@tenant "prom_tenant"

Expand All @@ -17,21 +16,23 @@ defmodule Supavisor.PromExTest do
database: db_conf[:database],
password: db_conf[:password],
username: db_conf[:username] <> "." <> @tenant,
socket_dir: nil
socket_dir: nil,
show_sensitive_data_on_connection_error: true
)

assert :idle == DBConnection.status(proxy)

%{proxy: proxy, user: db_conf[:username], db_name: db_conf[:database]}
end

test "remove tenant tag upon termination", %{proxy: proxy, user: user, db_name: db_name} do
P.query!(proxy, "select 1;", [])
Process.sleep(500)
metrics = PromEx.get_metrics()
assert metrics =~ "tenant=\"#{@tenant}\""
assert PromEx.get_metrics() =~ "tenant=\"#{@tenant}\""

GenServer.stop(proxy)
Process.sleep(500)
Supavisor.stop({{:single, @tenant}, user, :transaction, db_name})

Process.sleep(500)

refute PromEx.get_metrics() =~ "tenant=\"#{@tenant}\""
end
end

0 comments on commit 61b629d

Please sign in to comment.