From f0d3d8c2e2c8836caa3241b1fb2c15a50e6865b2 Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 22 Sep 2023 10:36:46 +0200 Subject: [PATCH 1/5] beter docker --- docker-compose.yml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 23b1d880..bb25a146 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,24 @@ version: '2' + services: zookeeper: - image: wurstmeister/zookeeper - ports: - - "2181:2181" + container_name: waterdrop_zookeeper + image: confluentinc/cp-zookeeper:7.5.0 + environment: + ZOOKEEPER_CLIENT_PORT: 2181 + ZOOKEEPER_TICK_TIME: 100 + kafka: - image: wurstmeister/kafka:2.12-2.5.0 + container_name: waterdrop_zookeeper + image: confluentinc/cp-kafka:7.5.0 + depends_on: + - zookeeper ports: - - "9092:9092" + - 9092:9092 environment: - KAFKA_ADVERTISED_HOST_NAME: localhost - KAFKA_ADVERTISED_PORT: 9092 + KAFKA_BROKER_ID: 1 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true' - KAFKA_CREATE_TOPICS: 'example_topic:1:1' - volumes: - - /var/run/docker.sock:/var/run/docker.sock + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092,PLAINTEXT_HOST://localhost:9092 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT + KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 From 4b94530aec1406bef3865923ee7b098903d6cfc5 Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 22 Sep 2023 10:38:31 +0200 Subject: [PATCH 2/5] fix name --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index bb25a146..f58b52f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: ZOOKEEPER_TICK_TIME: 100 kafka: - container_name: waterdrop_zookeeper + container_name: waterdrop_kafka image: confluentinc/cp-kafka:7.5.0 depends_on: - zookeeper From e97209d7368e0f2cd4fab254bf17f1442e7eb04c Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 22 Sep 2023 10:45:32 +0200 Subject: [PATCH 3/5] move wait and cleanup --- .github/workflows/ci.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aaf84901..efdab3ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,28 +25,37 @@ jobs: coverage: 'true' steps: - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + - name: Install package dependencies run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS" + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{matrix.ruby}} + bundler-cache: true + - name: Remove libzstd-dev to check no supported compressions run: sudo apt-get -y remove libzstd-dev + - name: Run Kafka with docker-compose - # We need to give Kafka enough time to start and create all the needed topics, etc - # If anyone has a better idea on how to do it smart and easily, please contact me run: | docker-compose up -d + + - name: Wait for Kafka + run: | sleep 5 + - name: Install latest bundler run: | gem install bundler --no-document bundle config set without 'tools benchmarks docs' + - name: Bundle install run: | bundle config set without development bundle install --jobs 4 --retry 3 + - name: Run all tests env: GITHUB_COVERAGE: ${{matrix.coverage}} From 9f6ba5cb44ab6e06b811b98cea0307d166c1082c Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 22 Sep 2023 10:54:45 +0200 Subject: [PATCH 4/5] remarks --- .github/workflows/ci.yml | 3 --- spec/lib/waterdrop/producer/sync_spec.rb | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efdab3ef..81649a8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,9 +35,6 @@ jobs: ruby-version: ${{matrix.ruby}} bundler-cache: true - - name: Remove libzstd-dev to check no supported compressions - run: sudo apt-get -y remove libzstd-dev - - name: Run Kafka with docker-compose run: | docker-compose up -d diff --git a/spec/lib/waterdrop/producer/sync_spec.rb b/spec/lib/waterdrop/producer/sync_spec.rb index e11bde76..266d8241 100644 --- a/spec/lib/waterdrop/producer/sync_spec.rb +++ b/spec/lib/waterdrop/producer/sync_spec.rb @@ -112,10 +112,10 @@ it { expect(delivery).to be_a(Rdkafka::Producer::DeliveryReport) } end - context 'when it is not installed zstd' do + context 'when it is installed zstd' do let(:codec) { 'zstd' } - it { expect { delivery }.to raise_error(Rdkafka::Config::ConfigError) } + it { expect(delivery).to be_a(Rdkafka::Producer::DeliveryReport) } end context 'when it is installed lz4' do From d01ff2e7b98db32e156d96e22b9e92bc0d27fa47 Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 22 Sep 2023 10:59:54 +0200 Subject: [PATCH 5/5] remark --- spec/lib/waterdrop/instrumentation/callbacks/delivery_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/waterdrop/instrumentation/callbacks/delivery_spec.rb b/spec/lib/waterdrop/instrumentation/callbacks/delivery_spec.rb index 2d77263e..1981d255 100644 --- a/spec/lib/waterdrop/instrumentation/callbacks/delivery_spec.rb +++ b/spec/lib/waterdrop/instrumentation/callbacks/delivery_spec.rb @@ -56,7 +56,7 @@ context 'when there is a message that was not successfully delivered async' do let(:changed) { [] } - let(:event) { changed.first } + let(:event) { changed.last } before do producer.monitor.subscribe('error.occurred') do |event|