diff --git a/test/integration/kayrock/timestamp_test.exs b/test/integration/kayrock/timestamp_test.exs index 0563d115..0c66448e 100644 --- a/test/integration/kayrock/timestamp_test.exs +++ b/test/integration/kayrock/timestamp_test.exs @@ -111,7 +111,7 @@ defmodule KafkaEx.KayrockTimestampTest do test "log with append time - v0", %{client: client} do topic = "test_log_append_timestamp_#{:rand.uniform(2_000_000)}" - {:ok, topic} = + {:ok, ^topic} = TestHelper.ensure_append_timestamp_topic( client, topic @@ -148,7 +148,7 @@ defmodule KafkaEx.KayrockTimestampTest do test "log with append time - v3", %{client: client} do topic = "test_log_append_timestamp_#{:rand.uniform(2_000_000)}" - {:ok, topic} = + {:ok, ^topic} = TestHelper.ensure_append_timestamp_topic( client, topic @@ -186,7 +186,7 @@ defmodule KafkaEx.KayrockTimestampTest do test "log with append time - v5", %{client: client} do topic = "test_log_append_timestamp_#{:rand.uniform(2_000_000)}" - {:ok, topic} = + {:ok, ^topic} = TestHelper.ensure_append_timestamp_topic( client, topic diff --git a/test/test_helper.exs b/test/test_helper.exs index 3b54e08b..ee2ee16d 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -116,7 +116,7 @@ defmodule TestHelper do topic_errors: [%{error_code: error_code}] }} = resp - wait_for_topic_to_appear(client, topic_name) + wait_for_topic_to_appear(client, topic_name) if error_code in [0, 36] do {:ok, topic_name} @@ -128,15 +128,20 @@ defmodule TestHelper do defp wait_for_topic_to_appear(_client, _topic_name, attempts \\ 10) - defp wait_for_topic_to_appear(_client, _topic_name, attempts) when attempts <= 0 do + defp wait_for_topic_to_appear(_client, _topic_name, attempts) + when attempts <= 0 do raise "Timeout while waiting for topic to appear" end defp wait_for_topic_to_appear(client, topic_name, attempts) do {:ok, %{topic_metadata: topic_metadata}} = - Client.send_request(client, %Kayrock.Metadata.V0.Request{}, NodeSelector.controller()) + Client.send_request( + client, + %Kayrock.Metadata.V0.Request{}, + NodeSelector.topic_partition(topic_name, 0) + ) - topics = topic_metadata |> Enum.map(&(&1.topic)) + topics = topic_metadata |> Enum.map(& &1.topic) unless topic_name in topics do wait_for_topic_to_appear(client, topic_name, attempts - 1)