Skip to content

Commit

Permalink
Fix Telemetry-related tests (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed May 2, 2023
1 parent 38b7307 commit d0fe53c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 24 deletions.
4 changes: 2 additions & 2 deletions lib/xandra/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ defmodule Xandra.Telemetry do
[:server_warnings] ->
Logger.warn("Received warnings: #{inspect(measurements.warnings)}", logger_meta)

[:prepared_cache, status] ->
query = inspect(measurements.query)
[:prepared_cache, status] when status in [:hit, :miss] ->
query = inspect(metadata.query)
Logger.debug("Prepared cache #{status} for query: #{query}", logger_meta)

[:prepare_query, :stop] ->
Expand Down
18 changes: 0 additions & 18 deletions test/integration/protocol_negotiation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,4 @@ defmodule ProtocolNegotiationTest do
conn = start_supervised!({Xandra, show_sensitive_data_on_connection_error: true})
assert %Xandra.Page{} = Xandra.execute!(conn, "SELECT * FROM system.local")
end

# C* 3 has no support for native protocol v5, so we can test this.
if System.get_env("CASSANDRA_VERSION") == "3" do
test "if a protocol version is specified, we should not gracefully downgrade" do
log =
ExUnit.CaptureLog.capture_log(fn ->
{:ok, conn} =
start_supervised(
{Xandra, show_sensitive_data_on_connection_error: true, protocol_version: :v5}
)

ref = Process.monitor(conn)
assert_receive {:DOWN, ^ref, _, _, :killed}, 500
end)

assert log =~ "Beta version of the protocol used (5/v5-beta), but USE_BETA flag is unset"
end
end
end
2 changes: 2 additions & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ excluded =
end

ExUnit.start(exclude: excluded, assert_receive_timeout: 1_000)

Xandra.Telemetry.attach_default_handler()
4 changes: 0 additions & 4 deletions test/xandra/cluster/control_connection_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ defmodule Xandra.Cluster.ControlConnectionTest do

@protocol_version XandraTest.IntegrationCase.protocol_version()

setup_all do
Xandra.Telemetry.attach_default_handler()
end

setup context do
parent = self()
mirror_ref = make_ref()
Expand Down

0 comments on commit d0fe53c

Please sign in to comment.