fluent-plugin-kafka 0.19.5 → 0.19.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +1 -1
- data/.github/workflows/add-to-project.yml +9 -2
- data/.github/workflows/linux.yml +22 -7
- data/.github/workflows/stale-actions.yml +4 -1
- data/ChangeLog +9 -0
- data/README.md +4 -0
- data/ci/prepare-kafka-server.sh +13 -1
- data/fluent-plugin-kafka.gemspec +1 -1
- data/lib/fluent/plugin/in_rdkafka_group.rb +20 -3
- data/lib/fluent/plugin/out_rdkafka.rb +9 -2
- data/lib/fluent/plugin/out_rdkafka2.rb +14 -4
- data/test/plugin/test_in_kafka_group.rb +2 -0
- data/test/plugin/test_in_rdkafka_group.rb +128 -0
- data/test/plugin/test_out_rdkafka2.rb +12 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a709cad3615bca0c45f0606644142278acbb75b8e43f766dd4a1821a624aa75
|
|
4
|
+
data.tar.gz: 269bfdaa2ef8fb7b6cbb254971cc728769aba7215a472a73b34af2c04d735f6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b15df023bd526fb22752da54b460ed12ce9a2d3c35e3ad9959c86d1ba8ac06fb9915799da95135fec3c6911ae776375ee8bc13f4803cad6663e2b60351b302c1
|
|
7
|
+
data.tar.gz: f9bfe163282d53f4f583ac905bffd50cab6eeaaaf5da2b9bf7511c7dad064c3aff458252af784ff8a52a3b6b5b63c80d47fccc80677692f58dc8a9fed814e6f4
|
data/.github/dependabot.yml
CHANGED
|
@@ -10,8 +10,15 @@ jobs:
|
|
|
10
10
|
name: Add issue to project
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
steps:
|
|
13
|
-
-
|
|
13
|
+
- name: Generate token
|
|
14
|
+
id: generate_token
|
|
15
|
+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
|
16
|
+
with:
|
|
17
|
+
app-id: ${{ secrets.PROJECT_APP_ID }}
|
|
18
|
+
private-key: ${{ secrets.PROJECT_APP_PRIVATE_KEY }}
|
|
19
|
+
owner: fluent
|
|
20
|
+
- uses: actions/add-to-project@5afcf98fcd03f1c2f92c3c83f58ae24323cc57fd # v2.0.0
|
|
14
21
|
with:
|
|
15
22
|
project-url: https://github.com/orgs/fluent/projects/4
|
|
16
|
-
github-token: ${{
|
|
23
|
+
github-token: ${{ steps.generate_token.outputs.token }}
|
|
17
24
|
labeled: waiting-for-triage
|
data/.github/workflows/linux.yml
CHANGED
|
@@ -4,22 +4,38 @@ on:
|
|
|
4
4
|
branches: [master]
|
|
5
5
|
pull_request:
|
|
6
6
|
branches: [master]
|
|
7
|
+
schedule:
|
|
8
|
+
- cron: '0 0 1 * *'
|
|
7
9
|
jobs:
|
|
10
|
+
ruby-versions:
|
|
11
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
|
12
|
+
with:
|
|
13
|
+
engine: cruby
|
|
14
|
+
min_version: 3.0
|
|
8
15
|
build:
|
|
16
|
+
needs: ruby-versions
|
|
9
17
|
runs-on: ${{ matrix.os }}
|
|
10
18
|
env:
|
|
11
19
|
USE_RDKAFKA: 1
|
|
12
20
|
strategy:
|
|
13
21
|
fail-fast: false
|
|
14
22
|
matrix:
|
|
15
|
-
ruby:
|
|
23
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
|
16
24
|
os:
|
|
17
25
|
- ubuntu-latest
|
|
18
26
|
rdkafka_versions:
|
|
19
27
|
- { min: '>= 0.6.0', max: '< 0.12.0' }
|
|
20
28
|
- { min: '>= 0.12.0', max: '< 0.14.0' }
|
|
21
29
|
- { min: '>= 0.14.0', max: '< 0.16.0' }
|
|
22
|
-
- { min: '>= 0.16.0', max: '
|
|
30
|
+
- { min: '>= 0.16.0', max: '< 0.25.0' }
|
|
31
|
+
- { min: '>= 0.25.0', max: '>= 0.25.0' }
|
|
32
|
+
# rdkafka 0.25.0 supports Ruby 3.2+, so we exclude it for Ruby 3.0 and 3.1
|
|
33
|
+
exclude:
|
|
34
|
+
- ruby: head
|
|
35
|
+
- ruby: '3.1'
|
|
36
|
+
rdkafka_versions: { min: '>= 0.25.0', max: '>= 0.25.0' }
|
|
37
|
+
- ruby: '3.0'
|
|
38
|
+
rdkafka_versions: { min: '>= 0.25.0', max: '>= 0.25.0' }
|
|
23
39
|
# rdkafka 0.15.2 is the last version which supports Ruby 2.7
|
|
24
40
|
include:
|
|
25
41
|
- ruby: '2.7'
|
|
@@ -30,17 +46,17 @@ jobs:
|
|
|
30
46
|
rdkafka_versions: { min: '>= 0.12.0', max: '= 0.15.2' }
|
|
31
47
|
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }} with rdkafka gem version (min ${{ matrix.rdkafka_versions.min }} max ${{ matrix.rdkafka_versions.max }})
|
|
32
48
|
steps:
|
|
33
|
-
- uses: actions/checkout@
|
|
34
|
-
- uses: ruby/setup-ruby@v1
|
|
49
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
50
|
+
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
|
|
35
51
|
with:
|
|
36
52
|
ruby-version: ${{ matrix.ruby }}
|
|
37
53
|
- name: Install confluent-kafka
|
|
38
54
|
run: |
|
|
39
55
|
sudo apt install -V -y gnupg2 wget
|
|
40
|
-
wget https://packages.confluent.io/deb/
|
|
56
|
+
wget https://packages.confluent.io/deb/7.9/archive.key
|
|
41
57
|
sudo gpg2 --homedir /tmp --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/confluent-archive-keyring.gpg --import archive.key
|
|
42
58
|
sudo chmod 644 /usr/share/keyrings/confluent-archive-keyring.gpg
|
|
43
|
-
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/confluent-archive-keyring.gpg] https://packages.confluent.io/deb/
|
|
59
|
+
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/confluent-archive-keyring.gpg] https://packages.confluent.io/deb/7.9 stable main" > /etc/apt/sources.list.d/confluent.list'
|
|
44
60
|
sudo apt update
|
|
45
61
|
sudo apt install -y confluent-community-2.13 openjdk-11-jre netcat-openbsd
|
|
46
62
|
- name: unit testing
|
|
@@ -50,6 +66,5 @@ jobs:
|
|
|
50
66
|
RDKAFKA_VERSION_MAX_RANGE: ${{ matrix.rdkafka_versions.max }}
|
|
51
67
|
run: |
|
|
52
68
|
sudo ./ci/prepare-kafka-server.sh
|
|
53
|
-
gem install rake
|
|
54
69
|
bundle install --jobs 4 --retry 3
|
|
55
70
|
bundle exec rake test
|
|
@@ -6,8 +6,11 @@ on:
|
|
|
6
6
|
jobs:
|
|
7
7
|
stale:
|
|
8
8
|
runs-on: ubuntu-latest
|
|
9
|
+
permissions:
|
|
10
|
+
issues: write
|
|
11
|
+
pull-requests: write
|
|
9
12
|
steps:
|
|
10
|
-
- uses: actions/stale@
|
|
13
|
+
- uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0
|
|
11
14
|
with:
|
|
12
15
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
13
16
|
days-before-stale: 90
|
data/ChangeLog
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
Release 0.19.7 - 2026/06/02
|
|
2
|
+
* in_rdkafka_group: support regexp pattern in topics (#541)
|
|
3
|
+
|
|
4
|
+
Release 0.19.6 - 2026/03/04
|
|
5
|
+
* out_rdkafka2: Auto-configure SASL PLAIN when username and password are set (#547)
|
|
6
|
+
* out_rdkafka2: Fix NoMethodError during graceful reload (#546)
|
|
7
|
+
* out_rdkafka: Fix ArgumentError for ssl_client_cert_key_password (#545)
|
|
8
|
+
* out_rdkafka, out_rdkafka2: Fix deprecation warning for max_wait_timeout in rdkafka-ruby >= 0.25.0 (#544)
|
|
9
|
+
|
|
1
10
|
Release 0.19.5 - 2025/07/11
|
|
2
11
|
* in_kafka_group: Add `sasl_aws_msk_iam_access_key_id`, `sasl_aws_msk_iam_secret_access_key`
|
|
3
12
|
and `sasl_aws_msk_iam_aws_region` options (#531)
|
data/README.md
CHANGED
|
@@ -177,6 +177,10 @@ With the introduction of the rdkafka-ruby based input plugin we hope to support
|
|
|
177
177
|
|
|
178
178
|
See also [rdkafka-ruby](https://github.com/appsignal/rdkafka-ruby) and [librdkafka](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md) for more detailed documentation about Kafka consumer options.
|
|
179
179
|
|
|
180
|
+
`topics` supports POSIX Extended Regular Expression pattern (not Ruby regex syntax) since v0.19.6. If you want to use regex pattern, use `/pattern/` like `/foo.*/`.
|
|
181
|
+
|
|
182
|
+
**Note**: A caret (`^`) is automatically added to the beginning of the pattern.
|
|
183
|
+
|
|
180
184
|
Consuming topic name is used for event tag. So when the target topic name is `app_event`, the tag is `app_event`. If you want to modify tag, use `add_prefix` or `add_suffix` parameter. With `add_prefix kafka`, the tag is `kafka.app_event`.
|
|
181
185
|
|
|
182
186
|
### Output plugin
|
data/ci/prepare-kafka-server.sh
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
|
+
set -x
|
|
4
|
+
|
|
3
5
|
export KAFKA_OPTS=-Dzookeeper.4lw.commands.whitelist=ruok
|
|
4
6
|
/usr/bin/zookeeper-server-start /etc/kafka/zookeeper.properties &
|
|
5
7
|
N_POLLING=30
|
|
@@ -30,4 +32,14 @@ while true ; do
|
|
|
30
32
|
exit 1
|
|
31
33
|
fi
|
|
32
34
|
done
|
|
33
|
-
|
|
35
|
+
# kafka-topics --version fails to connect zookeeper here.
|
|
36
|
+
case "$(java -cp "/usr/share/java/kafka/*" kafka.Kafka --version 2>/dev/null)" in
|
|
37
|
+
7.*)
|
|
38
|
+
/usr/bin/kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
|
|
39
|
+
;;
|
|
40
|
+
*)
|
|
41
|
+
# Deprecated zookeeper
|
|
42
|
+
/usr/bin/kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
|
|
43
|
+
;;
|
|
44
|
+
esac
|
|
45
|
+
|
data/fluent-plugin-kafka.gemspec
CHANGED
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
14
14
|
gem.name = "fluent-plugin-kafka"
|
|
15
15
|
gem.require_paths = ["lib"]
|
|
16
|
-
gem.version = '0.19.
|
|
16
|
+
gem.version = '0.19.7'
|
|
17
17
|
gem.required_ruby_version = ">= 2.1.0"
|
|
18
18
|
|
|
19
19
|
gem.add_dependency "fluentd", [">= 0.10.58", "< 2"]
|
|
@@ -76,13 +76,25 @@ class Fluent::Plugin::RdKafkaGroupInput < Fluent::Plugin::Input
|
|
|
76
76
|
end
|
|
77
77
|
config_array
|
|
78
78
|
end
|
|
79
|
+
private :_config_to_array
|
|
80
|
+
|
|
81
|
+
def regex_pattern?(topic)
|
|
82
|
+
topic.start_with?('/') && topic.end_with?('/') ? true : false
|
|
83
|
+
end
|
|
84
|
+
private :regex_pattern?
|
|
85
|
+
|
|
86
|
+
def _config_regex_pattern(topic)
|
|
87
|
+
# librdkafka recognizes string as regex pattern if the topic name starts with '^'.
|
|
88
|
+
# https://github.com/confluentinc/librdkafka/blob/570c785e9e35812db8f50254bd2f7e0cf47def39/src/rdkafka.h#L4148
|
|
89
|
+
# https://github.com/confluentinc/librdkafka/blob/e1db7eaa517f0a6438bc846a9c49ede73b9ea211/src/rdkafka_topic.c#L2064
|
|
90
|
+
[topic[1..-2].prepend('^')]
|
|
91
|
+
end
|
|
92
|
+
private :_config_regex_pattern
|
|
79
93
|
|
|
80
94
|
def multi_workers_ready?
|
|
81
95
|
true
|
|
82
96
|
end
|
|
83
97
|
|
|
84
|
-
private :_config_to_array
|
|
85
|
-
|
|
86
98
|
def configure(conf)
|
|
87
99
|
compat_parameters_convert(conf, :parser)
|
|
88
100
|
|
|
@@ -93,7 +105,12 @@ class Fluent::Plugin::RdKafkaGroupInput < Fluent::Plugin::Input
|
|
|
93
105
|
log.info "Will watch for topics #{@topics} at brokers " \
|
|
94
106
|
"#{@kafka_configs["bootstrap.servers"]} and '#{@kafka_configs["group.id"]}' group"
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
topics = @topics.strip
|
|
109
|
+
if regex_pattern?(topics)
|
|
110
|
+
@topics = _config_regex_pattern(topics)
|
|
111
|
+
else
|
|
112
|
+
@topics = _config_to_array(topics)
|
|
113
|
+
end
|
|
97
114
|
|
|
98
115
|
parser_conf = conf.elements('parse').first
|
|
99
116
|
unless parser_conf
|
|
@@ -78,7 +78,6 @@ DESC
|
|
|
78
78
|
config_param :enqueue_retry_backoff, :integer, :default => 3
|
|
79
79
|
|
|
80
80
|
config_param :service_name, :string, :default => nil
|
|
81
|
-
config_param :ssl_client_cert_key_password, :string, :default => nil
|
|
82
81
|
|
|
83
82
|
include Fluent::KafkaPluginUtil::SSLSettings
|
|
84
83
|
include Fluent::KafkaPluginUtil::SaslSettings
|
|
@@ -87,6 +86,8 @@ DESC
|
|
|
87
86
|
super
|
|
88
87
|
@producers = {}
|
|
89
88
|
@producers_mutex = Mutex.new
|
|
89
|
+
|
|
90
|
+
@use_max_wait_timeout_ms = Gem::Version.new(Rdkafka::VERSION) >= Gem::Version.new('0.25.0')
|
|
90
91
|
end
|
|
91
92
|
|
|
92
93
|
def configure(conf)
|
|
@@ -291,7 +292,13 @@ DESC
|
|
|
291
292
|
handler = enqueue_with_retry(producer, topic, record_buf, message_key, partition, time)
|
|
292
293
|
handler
|
|
293
294
|
}.each { |handler|
|
|
294
|
-
|
|
295
|
+
if @rdkafka_delivery_handle_poll_timeout != 0
|
|
296
|
+
if @use_max_wait_timeout_ms
|
|
297
|
+
handler.wait(max_wait_timeout_ms: @rdkafka_delivery_handle_poll_timeout * 1000)
|
|
298
|
+
else
|
|
299
|
+
handler.wait(max_wait_timeout: @rdkafka_delivery_handle_poll_timeout)
|
|
300
|
+
end
|
|
301
|
+
end
|
|
295
302
|
}
|
|
296
303
|
end
|
|
297
304
|
rescue Exception => e
|
|
@@ -168,12 +168,14 @@ DESC
|
|
|
168
168
|
def initialize
|
|
169
169
|
super
|
|
170
170
|
|
|
171
|
-
@producers =
|
|
172
|
-
@producers_mutex =
|
|
171
|
+
@producers = {}
|
|
172
|
+
@producers_mutex = Mutex.new
|
|
173
173
|
@shared_producer = nil
|
|
174
174
|
@enqueue_rate = nil
|
|
175
175
|
@writing_threads_mutex = Mutex.new
|
|
176
176
|
@writing_threads = Set.new
|
|
177
|
+
|
|
178
|
+
@use_max_wait_timeout_ms = Gem::Version.new(Rdkafka::VERSION) >= Gem::Version.new('0.25.0')
|
|
177
179
|
end
|
|
178
180
|
|
|
179
181
|
def configure(conf)
|
|
@@ -266,6 +268,11 @@ DESC
|
|
|
266
268
|
config[:"sasl.kerberos.keytab"] = @keytab if @keytab
|
|
267
269
|
end
|
|
268
270
|
|
|
271
|
+
if @username && @password
|
|
272
|
+
sasl = true
|
|
273
|
+
config[:"sasl.mechanisms"] = 'PLAIN'
|
|
274
|
+
end
|
|
275
|
+
|
|
269
276
|
if ssl && sasl
|
|
270
277
|
security_protocol = "SASL_SSL"
|
|
271
278
|
elsif ssl && !sasl
|
|
@@ -301,7 +308,6 @@ DESC
|
|
|
301
308
|
@shared_producer = @rdkafka.producer
|
|
302
309
|
else
|
|
303
310
|
@producers = {}
|
|
304
|
-
@producers_mutex = Mutex.new
|
|
305
311
|
end
|
|
306
312
|
|
|
307
313
|
super
|
|
@@ -430,7 +436,11 @@ DESC
|
|
|
430
436
|
end
|
|
431
437
|
}
|
|
432
438
|
handlers.each { |handler|
|
|
433
|
-
|
|
439
|
+
if @use_max_wait_timeout_ms
|
|
440
|
+
handler.wait(max_wait_timeout_ms: @rdkafka_delivery_handle_poll_timeout * 1000)
|
|
441
|
+
else
|
|
442
|
+
handler.wait(max_wait_timeout: @rdkafka_delivery_handle_poll_timeout)
|
|
443
|
+
end
|
|
434
444
|
}
|
|
435
445
|
end
|
|
436
446
|
rescue Exception => e
|
|
@@ -39,6 +39,7 @@ class KafkaGroupInputTest < Test::Unit::TestCase
|
|
|
39
39
|
class ConsumeTest < self
|
|
40
40
|
def setup
|
|
41
41
|
@kafka = Kafka.new(["localhost:9092"], client_id: 'kafka')
|
|
42
|
+
@kafka.create_topic(TOPIC_NAME)
|
|
42
43
|
@producer = @kafka.producer
|
|
43
44
|
end
|
|
44
45
|
|
|
@@ -59,6 +60,7 @@ class KafkaGroupInputTest < Test::Unit::TestCase
|
|
|
59
60
|
d = create_driver
|
|
60
61
|
|
|
61
62
|
d.run(expect_records: 1, timeout: 10) do
|
|
63
|
+
sleep 0.1
|
|
62
64
|
@producer.produce("Hello, fluent-plugin-kafka!", topic: TOPIC_NAME)
|
|
63
65
|
@producer.deliver_messages
|
|
64
66
|
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
require 'fluent/test/driver/input'
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
class RdkafkaGroupInputTest < Test::Unit::TestCase
|
|
6
|
+
|
|
7
|
+
def have_rdkafka
|
|
8
|
+
begin
|
|
9
|
+
require 'fluent/plugin/in_rdkafka_group'
|
|
10
|
+
true
|
|
11
|
+
rescue LoadError
|
|
12
|
+
false
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def setup
|
|
17
|
+
omit_unless(have_rdkafka, "rdkafka isn't installed")
|
|
18
|
+
Fluent::Test.setup
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
TOPIC_NAME = "kafka-input-#{SecureRandom.uuid}"
|
|
22
|
+
|
|
23
|
+
CONFIG = %[
|
|
24
|
+
topics #{TOPIC_NAME}
|
|
25
|
+
kafka_configs {"bootstrap.servers": "localhost:9092", "group.id": "test_group"}
|
|
26
|
+
<parse>
|
|
27
|
+
@type none
|
|
28
|
+
</parse>
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
def create_driver(conf = CONFIG)
|
|
32
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::RdKafkaGroupInput).configure(conf)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_configure
|
|
37
|
+
d = create_driver
|
|
38
|
+
assert_equal [TOPIC_NAME], d.instance.topics
|
|
39
|
+
assert_equal 'localhost:9092', d.instance.kafka_configs['bootstrap.servers']
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_multi_worker_support
|
|
43
|
+
d = create_driver
|
|
44
|
+
assert_true d.instance.multi_workers_ready?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class ConsumeTest < self
|
|
48
|
+
TOPIC_NAME = "kafka-input-#{SecureRandom.uuid}"
|
|
49
|
+
|
|
50
|
+
def setup
|
|
51
|
+
@kafka = Kafka.new(["localhost:9092"], client_id: 'kafka')
|
|
52
|
+
@producer = @kafka.producer
|
|
53
|
+
@kafka.create_topic(TOPIC_NAME)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def teardown
|
|
57
|
+
@kafka.delete_topic(TOPIC_NAME)
|
|
58
|
+
@kafka.close
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_consume
|
|
62
|
+
conf = %[
|
|
63
|
+
topics #{TOPIC_NAME}
|
|
64
|
+
kafka_configs {"bootstrap.servers": "localhost:9092", "group.id": "test_group"}
|
|
65
|
+
<parse>
|
|
66
|
+
@type none
|
|
67
|
+
</parse>
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
d = create_driver(conf)
|
|
71
|
+
|
|
72
|
+
d.run(expect_records: 1, timeout: 10) do
|
|
73
|
+
sleep 0.1
|
|
74
|
+
@producer.produce("Hello, fluent-plugin-kafka!", topic: TOPIC_NAME)
|
|
75
|
+
@producer.deliver_messages
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
expected = {'message' => 'Hello, fluent-plugin-kafka!'}
|
|
79
|
+
assert_equal expected, d.events[0][2]
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
class ConsumeTopicWithRegexpTest < self
|
|
84
|
+
TOPIC_NAME1 = "kafka-input-1-#{SecureRandom.uuid}"
|
|
85
|
+
TOPIC_NAME2 = "kafka-input-22-#{SecureRandom.uuid}"
|
|
86
|
+
UNMATCHED_TOPIC = "kafka-input-333-#{SecureRandom.uuid}"
|
|
87
|
+
|
|
88
|
+
TOPIC_NAME_REGEXP = "/kafka-input-[0-9]{1,2}-.*/"
|
|
89
|
+
|
|
90
|
+
def setup
|
|
91
|
+
@kafka = Kafka.new(["localhost:9092"], client_id: 'kafka')
|
|
92
|
+
@producer = @kafka.producer
|
|
93
|
+
@kafka.create_topic(TOPIC_NAME1)
|
|
94
|
+
@kafka.create_topic(TOPIC_NAME2)
|
|
95
|
+
@kafka.create_topic(UNMATCHED_TOPIC)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def teardown
|
|
99
|
+
@kafka.delete_topic(TOPIC_NAME1)
|
|
100
|
+
@kafka.delete_topic(TOPIC_NAME2)
|
|
101
|
+
@kafka.delete_topic(UNMATCHED_TOPIC)
|
|
102
|
+
@kafka.close
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def test_consume_with_regexp
|
|
106
|
+
conf = %[
|
|
107
|
+
topics #{TOPIC_NAME_REGEXP}
|
|
108
|
+
kafka_configs {"bootstrap.servers": "localhost:9092", "group.id": "test_group"}
|
|
109
|
+
<parse>
|
|
110
|
+
@type none
|
|
111
|
+
</parse>
|
|
112
|
+
]
|
|
113
|
+
d = create_driver(conf)
|
|
114
|
+
|
|
115
|
+
d.run(expect_records: 2, timeout: 10) do
|
|
116
|
+
sleep 0.1
|
|
117
|
+
@producer.produce("Hello, fluent-plugin-kafka! in topic 1", topic: TOPIC_NAME1)
|
|
118
|
+
@producer.produce("Hello, fluent-plugin-kafka! in topic 2", topic: TOPIC_NAME2)
|
|
119
|
+
@producer.produce("Should be ignored", topic: UNMATCHED_TOPIC)
|
|
120
|
+
@producer.deliver_messages
|
|
121
|
+
end
|
|
122
|
+
expected_message_pattern = /Hello, fluent-plugin-kafka! in topic [12]/
|
|
123
|
+
assert_equal 2, d.events.size
|
|
124
|
+
assert_match(expected_message_pattern, d.events[0][2]['message'])
|
|
125
|
+
assert_match(expected_message_pattern, d.events[1][2]['message'])
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -55,6 +55,18 @@ class Rdkafka2OutputTest < Test::Unit::TestCase
|
|
|
55
55
|
assert_equal 'localhost:9092', d.instance.brokers
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
def test_configure_sasl_plain
|
|
59
|
+
conf = base_config + config_element('ROOT', '', {"username" => "testuser", "password" => "testpass"}, [])
|
|
60
|
+
d = create_driver(conf)
|
|
61
|
+
|
|
62
|
+
config = d.instance.build_config
|
|
63
|
+
|
|
64
|
+
assert_equal 'PLAIN', config[:"sasl.mechanisms"]
|
|
65
|
+
assert_equal 'SASL_PLAINTEXT', config[:"security.protocol"]
|
|
66
|
+
assert_equal 'testuser', config[:"sasl.username"]
|
|
67
|
+
assert_equal 'testpass', config[:"sasl.password"]
|
|
68
|
+
end
|
|
69
|
+
|
|
58
70
|
def test_mutli_worker_support
|
|
59
71
|
d = create_driver
|
|
60
72
|
assert_equal true, d.instance.multi_workers_ready?
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-kafka
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.19.
|
|
4
|
+
version: 0.19.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hidemasa Togashi
|
|
@@ -192,6 +192,7 @@ files:
|
|
|
192
192
|
- test/helper.rb
|
|
193
193
|
- test/plugin/test_in_kafka.rb
|
|
194
194
|
- test/plugin/test_in_kafka_group.rb
|
|
195
|
+
- test/plugin/test_in_rdkafka_group.rb
|
|
195
196
|
- test/plugin/test_kafka_plugin_util.rb
|
|
196
197
|
- test/plugin/test_out_kafka.rb
|
|
197
198
|
- test/plugin/test_out_kafka2.rb
|
|
@@ -215,13 +216,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
215
216
|
- !ruby/object:Gem::Version
|
|
216
217
|
version: '0'
|
|
217
218
|
requirements: []
|
|
218
|
-
rubygems_version:
|
|
219
|
+
rubygems_version: 4.0.10
|
|
219
220
|
specification_version: 4
|
|
220
221
|
summary: Fluentd plugin for Apache Kafka > 0.8
|
|
221
222
|
test_files:
|
|
222
223
|
- test/helper.rb
|
|
223
224
|
- test/plugin/test_in_kafka.rb
|
|
224
225
|
- test/plugin/test_in_kafka_group.rb
|
|
226
|
+
- test/plugin/test_in_rdkafka_group.rb
|
|
225
227
|
- test/plugin/test_kafka_plugin_util.rb
|
|
226
228
|
- test/plugin/test_out_kafka.rb
|
|
227
229
|
- test/plugin/test_out_kafka2.rb
|