From fff63f50ca4aba643eadc02892d60bd2bf2fe43c Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 22 Sep 2023 12:55:49 +0200 Subject: [PATCH 1/4] switch to kraft --- docker-compose.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b867d9a9..e4c98d11 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,23 +1,23 @@ version: '2' services: - zookeeper: - container_name: waterdrop_zookeeper - image: confluentinc/cp-zookeeper:7.5.0 - environment: - ZOOKEEPER_CLIENT_PORT: 2181 - kafka: - container_name: waterdrop_kafka + container_name: rdkafka_kafka image: confluentinc/cp-kafka:7.5.0 - depends_on: - - zookeeper + ports: - 9092:9092 + environment: - KAFKA_BROKER_ID: 1 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092,PLAINTEXT_HOST://localhost:9092 - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT + CLUSTER_ID: adqr22r231e223131231ww KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 + KAFKA_PROCESS_ROLES: broker,controller + KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER + KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092 + KAFKA_BROKER_ID: 1 + KAFKA_CONTROLLER_QUORUM_VOTERS: 1@127.0.0.1:9093 + ALLOW_PLAINTEXT_LISTENER: 'yes' + KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true' From 89410fab2344cba7916e3e1507b9e7c036abaf05 Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 22 Sep 2023 12:56:02 +0200 Subject: [PATCH 2/4] name --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index e4c98d11..26c569ca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '2' services: kafka: - container_name: rdkafka_kafka + container_name: waterdrop_kafka image: confluentinc/cp-kafka:7.5.0 ports: From 2862dc1f5ac87680ff50e5336d2274f9856a0ccb Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 22 Sep 2023 13:22:37 +0200 Subject: [PATCH 3/4] cleanup --- .../vendors/datadog/metrics_listener_spec.rb | 2 +- spec/lib/waterdrop/producer/async_spec.rb | 10 ++++++---- spec/lib/waterdrop/producer/sync_spec.rb | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/lib/waterdrop/instrumentation/vendors/datadog/metrics_listener_spec.rb b/spec/lib/waterdrop/instrumentation/vendors/datadog/metrics_listener_spec.rb index b1a14069..ccd42c21 100644 --- a/spec/lib/waterdrop/instrumentation/vendors/datadog/metrics_listener_spec.rb +++ b/spec/lib/waterdrop/instrumentation/vendors/datadog/metrics_listener_spec.rb @@ -96,7 +96,7 @@ def initialize let(:counts) { dummy_client.buffer[:count] } let(:histograms) { dummy_client.buffer[:histogram] } let(:guages) { dummy_client.buffer[:gauge] } - let(:broker_tag) { { tags: %w[broker:localhost:9092] } } + let(:broker_tag) { { tags: %w[broker:127.0.0.1:9092] } } # We add all expectations in one example not to sleep each time it 'expect to have proper metrics in place' do diff --git a/spec/lib/waterdrop/producer/async_spec.rb b/spec/lib/waterdrop/producer/async_spec.rb index 42e50457..5da5a475 100644 --- a/spec/lib/waterdrop/producer/async_spec.rb +++ b/spec/lib/waterdrop/producer/async_spec.rb @@ -27,7 +27,11 @@ end context 'when producing with good middleware' do + let(:message) { build(:valid_message, payload: nil) } + before do + producer.produce_sync(topic: message[:topic], payload: nil) + mid = lambda do |msg| msg[:partition_key] = '1' msg @@ -36,12 +40,12 @@ producer.middleware.append mid end - let(:message) { build(:valid_message, payload: nil) } - it { expect(delivery).to be_a(Rdkafka::Producer::DeliveryHandle) } end context 'when producing with corrupted middleware' do + let(:message) { build(:valid_message, payload: nil) } + before do mid = lambda do |msg| msg[:partition_key] = -1 @@ -51,8 +55,6 @@ producer.middleware.append mid end - let(:message) { build(:valid_message, payload: nil) } - it { expect { delivery }.to raise_error(WaterDrop::Errors::MessageInvalidError) } end diff --git a/spec/lib/waterdrop/producer/sync_spec.rb b/spec/lib/waterdrop/producer/sync_spec.rb index 266d8241..f3e663d9 100644 --- a/spec/lib/waterdrop/producer/sync_spec.rb +++ b/spec/lib/waterdrop/producer/sync_spec.rb @@ -58,6 +58,8 @@ let(:message) { build(:valid_message, partition_key: rand.to_s, topic: 'example_topic') } + before { producer.produce_sync(topic: 'example_topic', payload: '1') } + it { expect(delivery).to be_a(Rdkafka::Producer::DeliveryReport) } end From 94d4352dc68c333330fdbc52e90b303ccd2019f8 Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 22 Sep 2023 13:23:28 +0200 Subject: [PATCH 4/4] better name --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 26c569ca..2551449f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '2' services: kafka: - container_name: waterdrop_kafka + container_name: kafka image: confluentinc/cp-kafka:7.5.0 ports: