Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels