Giter Club home page Giter Club logo

Comments (6)

mensfeld avatar mensfeld commented on July 18, 2024

Hey man, sorry for the delay. I've been traveling. Feq questions:

  • are you using most recent karafka-testing of most recent for 1.3?
  • did you try to upgrade to 1.4? While I still support 1.3 it's close to EOL.
  • do your specs run in multiple threads or anything are that?
  • are you using some sort of thread storage that would be cleared with each spec running?

from karafka-testing.

mib32 avatar mib32 commented on July 18, 2024

Also have same issue.

  • using karafka-testing 1.4.2, karafka 1.4.9, ruby-kafka 1.4.0
  • No, very simple setup rspec setup.
  • Not sure what this question means... Kinda very plain test. I am using VCR though.

Example of failing test

require_relative '../../karafka_app'

RSpec.describe RuleNotificationsConsumer, vcr: true do
  # This will create a consumer instance with all the settings defined for the given topic
  subject(:consumer) { karafka_consumer_for(:scheduled_rule_events) }

  let(:app) { create(:app) }
  let(:rule1_no_log) { create(:butler_rule, app: app) }
  let(:rule2) { create(:butler_rule, :manual, app: app) }
  let!(:log_rule_2) { create(:butler_rule_log, rule: rule2) }
  let(:rule3) { create(:butler_rule, :manual, app: app) }
  let!(:log_rule_3) { create(:butler_rule_log, rule: rule3) }

  before do
    # Sends messages to Karafka consumer
    publish_for_karafka(encode(rule1_no_log.id, 'opened'))
    publish_for_karafka(encode(rule2.id, 'opened'))
    publish_for_karafka(encode(rule2.id, 'opened'))
    publish_for_karafka(encode(rule2.id, 'errored'))
    publish_for_karafka(encode(rule3.id, 'errored'))
    publish_for_karafka(encode('nonexistent_id', 'errored'))
  end

  def avro
    @avro ||= AvroRegistry.instance
  end

  def encode(rule_id, type)
    avro.encode({
                  'rule_id' => rule_id,
                  'type' => type,
                  'timestamp' => Time.now
                }, subject: 'scheduled_rule_event', version: 1)
  end

  it 'expects to log a proper message' do
    consumer.consume
    expect(log_rule_2.reload.opened_count).to eq 2
    expect(log_rule_2.errored_count).to eq 1
    expect(log_rule_3.reload.opened_count).to eq 0
    expect(log_rule_3.errored_count).to eq 1
  end
end

from karafka-testing.

mensfeld avatar mensfeld commented on July 18, 2024

@mib32 would you be willing to narrow it down to a reproduction repo? With this I could fix it in minutes. Otherwise I will have to do my best to replicate your gems setup, etc.

from karafka-testing.

mensfeld avatar mensfeld commented on July 18, 2024

@diogoleitao @mib32 I was able to reproduce. I will fix it today.

from karafka-testing.

mensfeld avatar mensfeld commented on July 18, 2024

ref #71 and moving to testing lib

from karafka-testing.

mensfeld avatar mensfeld commented on July 18, 2024

new karafka-testing has been released. it fixes this problem.

from karafka-testing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.