Compare commits
2 Commits
98e79b927d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 29c032cb16 | |||
| a34e91770f |
12
LICENSE
Normal file
12
LICENSE
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
ISC License
|
||||||
|
|
||||||
|
Copyright 2024 Pascal Schmid
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
||||||
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
OF THIS SOFTWARE.
|
||||||
@@ -40,9 +40,7 @@ defmodule KafkaexLagExporter.ConsumerOffsetFetcher.Test do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "should return the calculated lags" do
|
test "should return the calculated lags" do
|
||||||
test_endpoint = {"test endpoint", 666}
|
%{sum: sum, lags: lags} = KafkaexLagExporter.ConsumerOffsetFetcher.get({"test endpoint", 666})
|
||||||
|
|
||||||
%{sum: sum, lags: lags} = KafkaexLagExporter.ConsumerOffsetFetcher.get(test_endpoint)
|
|
||||||
|
|
||||||
assert sum == [
|
assert sum == [
|
||||||
%ConsumerOffset{
|
%ConsumerOffset{
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ defmodule KafkaexLagExporter.KafkaUtils.Test do
|
|||||||
alias KafkaexLagExporter.KafkaWrapper.Behaviour, as: KafkaWrapper
|
alias KafkaexLagExporter.KafkaWrapper.Behaviour, as: KafkaWrapper
|
||||||
alias KafkaexLagExporter.KafkaUtils
|
alias KafkaexLagExporter.KafkaUtils
|
||||||
|
|
||||||
@test_host "test_host"
|
@test_endpoint {"test_host", "1234"}
|
||||||
@test_port "1234"
|
|
||||||
@test_endpoint {@test_host, @test_port}
|
|
||||||
@test_sock_opts [ssl: []]
|
@test_sock_opts [ssl: []]
|
||||||
@test_group_name1 "test-consumer_group1"
|
@test_group_name1 "test-consumer_group1"
|
||||||
@test_group_name2 "test-consumer_group"
|
@test_group_name2 "test-consumer_group"
|
||||||
@@ -28,18 +26,9 @@ defmodule KafkaexLagExporter.KafkaUtils.Test do
|
|||||||
consumer_info1 = {:a, @test_group_name1, "consumer"}
|
consumer_info1 = {:a, @test_group_name1, "consumer"}
|
||||||
consumer_info2 = {:b, @test_group_name2, "something-other"}
|
consumer_info2 = {:b, @test_group_name2, "something-other"}
|
||||||
|
|
||||||
patch(
|
patch(KafkaWrapper, :list_all_groups, fn _, _ ->
|
||||||
KafkaWrapper,
|
[{@test_endpoint, [consumer_info1, consumer_info2]}]
|
||||||
:list_all_groups,
|
end)
|
||||||
fn _, _ ->
|
|
||||||
[
|
|
||||||
{
|
|
||||||
@test_endpoint,
|
|
||||||
[consumer_info1, consumer_info2]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
group_names = KafkaUtils.get_consumer_group_names(@test_endpoint)
|
group_names = KafkaUtils.get_consumer_group_names(@test_endpoint)
|
||||||
|
|
||||||
@@ -63,10 +52,7 @@ defmodule KafkaexLagExporter.KafkaUtils.Test do
|
|||||||
consumer_id = "test_consumer_id"
|
consumer_id = "test_consumer_id"
|
||||||
member_host = "test_member_host"
|
member_host = "test_member_host"
|
||||||
|
|
||||||
patch(
|
patch(KafkaWrapper, :describe_groups, fn _, _, _ ->
|
||||||
KafkaWrapper,
|
|
||||||
:describe_groups,
|
|
||||||
fn _, _, _ ->
|
|
||||||
{
|
{
|
||||||
:ok,
|
:ok,
|
||||||
[
|
[
|
||||||
@@ -82,8 +68,7 @@ defmodule KafkaexLagExporter.KafkaUtils.Test do
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
end
|
end)
|
||||||
)
|
|
||||||
|
|
||||||
patch(KafkaexLagExporter.TopicNameParser, :parse_topic_names, fn _ -> [@test_topic_name] end)
|
patch(KafkaexLagExporter.TopicNameParser, :parse_topic_names, fn _ -> [@test_topic_name] end)
|
||||||
|
|
||||||
@@ -147,13 +132,9 @@ defmodule KafkaexLagExporter.KafkaUtils.Test do
|
|||||||
|
|
||||||
patch(KafkaWrapper, :resolve_offset, fn _, _, _, _, _ -> {:ok, resolved_offset} end)
|
patch(KafkaWrapper, :resolve_offset, fn _, _, _, _, _ -> {:ok, resolved_offset} end)
|
||||||
|
|
||||||
patch(
|
patch(KafkaWrapper, :fetch_committed_offsets, fn _, _, _ ->
|
||||||
KafkaWrapper,
|
|
||||||
:fetch_committed_offsets,
|
|
||||||
fn _, _, _ ->
|
|
||||||
{:ok, [%{name: "test name", partitions: [partition_info1, partition_info2]}]}
|
{:ok, [%{name: "test name", partitions: [partition_info1, partition_info2]}]}
|
||||||
end
|
end)
|
||||||
)
|
|
||||||
|
|
||||||
lag = KafkaUtils.lag(@test_topic_name, consumer_group, client)
|
lag = KafkaUtils.lag(@test_topic_name, consumer_group, client)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user