Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

info: Can kafta addon be used to create imposters #3

Open
fjvierap opened this issue Jan 19, 2024 · 3 comments
Open

info: Can kafta addon be used to create imposters #3

fjvierap opened this issue Jan 19, 2024 · 3 comments

Comments

@fjvierap
Copy link

I would like to use kafka addon as imposter. Our scenario is that will have an EDA application which will consume a message from a third party will do some logic, produce a message to be consumer by another third party and the process will sleep until the third party application will respond will another message. My idea was to create a feature which consume message and based on conditions will producer other messages:

Feature: karate-kafka demo

Background:
* configure kafka =
"""
{
  'bootstrap.servers': '127.0.0.1:9092',
  'schema.registry.url': 'http://localhost:8082',
  'schema.registry.basic.auth.credentials.source' : 'USER_INFO',
  'schema.registry.basic.auth.user.info' : 'farbod:test_secret'

}
"""

* register { name: 'order-notification', path: 'classpath:karate/order-notification-avro.avsc' }

Scenario:
* def session = karate.consume('kafka')
* session.topic = 'order'
* session.count = 1
* session.start()

* def response = session.collect()
* if (response[0].value == { id: 'id' }) print 'here produce a message'

Then in some other feature call this mock feature.

Feature: karate-kafka demo

Background:
* configure kafka =
"""
{
  'bootstrap.servers': '127.0.0.1:9092',
  'schema.registry.url': 'http://localhost:8082',
  'schema.registry.basic.auth.credentials.source' : 'USER_INFO',
  'schema.registry.basic.auth.user.info' : 'farbod:test_secret'

}
"""

* register { name: 'order-notification', path: 'classpath:karate/order-notification-avro.avsc' }

Scenario:
* karate.callSingle('mock.feature')

* topic 'order'
* schema 'order-notification'
* headers { foo: 'bar1', baz: 'ban1' }
* key 'first'
* value { id: 'someid' }
* produce kafka

But this approach does not work as the threat keep in the mock expecting to consumer message and the main feature got stuck and not progress..

I guess I am not doing it in the best way. What is the proper approach to use kafka addon for this scenatrio?

Thanks in advance

@ptrthomas
Copy link
Member

@fjvierap a kafka mock would need a different design - mainly it has to start as a server and "listen" all the time and manage threads better. we have this on the roadmap and I can get back to you on timelines.

@fjvierap
Copy link
Author

@ptrthomas it would be very convenient to know the timelines for it and if it would be some alternative for mocking kafka consumers.

Thanks in advance

@ptrthomas
Copy link
Member

@fjvierap give me a day or two to confirm, but It can be as soon as by Q1 (March). for alternatives, this may help, but requires some custom Java code: https://twitter.com/getkarate/status/1417023536082812935

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants