Open santosh2040 opened 6 years ago
I was struggling with the same issue. Managed to resolve it by using the Robot 'Convert To Number' keyword
${timeout_in_ms}= Convert To Number 200000 ${data}= Poll ${timeout_in_ms}
You can also use notation: ${data}= Poll ${200000}
I have an issue where Poll is not getting anything. I set up a consumer on my kafka server and subscribed to the topic. I can see the message get created. Yet polling never gets anything. I keep increasing the timeout, but when the message is created within 3 seconds, setting the Polling timeout to 200s is a bit much. And even then 200s is not returning anything.
Some more information: I set a keyword to get the number of messages prior to and after generating the new message for my topic and added a check to ensure that they were not equal. Once that was done, my test does the poll. Timeout is set to ${240000}. Poll always returns empty no matter what I try.
`Connect Consumer bootstrap_servers=kafka-dev-0.BLABLA:9092 client_id=Robot`
`${topics}= Get Kafka Topics`
`@{partition}= Get Kafka Partitions For Topic topic=transactiontopic`
`${partitionid}= Create TopicPartition topic=transactiontopic partition=${23}`
`${noofmessages}= Get Number Of Messages In Topics topics=transactiontopic`
`Assign To Topic Partition topic_partition=${partitionid}`
`${pppp}= Get Assigned Partitions`
`Seek topic_partition=${partitionid} offset=${6666}`
`Subscribe Topic pattern=transactiontopic`
`${data}= Poll max_records=${10} `
`Close`
Am I doing something incorrect?
Poll
returns an empty list although that topic has many messages in bus
Hi, thank you input. I'm working on acceptance tests for this lib. I hope test will help me find and fix such issues faster.
@venkatraju1284 I've added couple of simple tests recently. You can refer to: https://github.com/s4int/robotframework-KafkaLibrary/blob/55ce258808a49a6e49ff53982543b5ad76366d16/tests/04_poll.robot#L9-L25
Try to use Poll with Poll max_records=${10} . timeout_ms=${500}
docs: https://kafka-python.readthedocs.io/en/master/apidoc/KafkaConsumer.html#kafka.KafkaConsumer.poll
Poll | timeout_ms=0, max_records=None | Fetch data from assigned topics / partitions.
This is the description of Poll keyword which should be able to fetch data from the topic but I am facing the issue in test case 6 which is illustrated below.
${data} = KafkaLibrary . Poll 200000 Documentation: Fetch data from assigned topics / partitions. Start / End / Elapsed: 20170727 14:38:52.901 / 20170727 14:38:52.907 / 00:00:00.006 14:38:52.907 FAIL TypeError: unsupported operand type(s) for -: 'unicode' and 'float'
My test Case is as follows:
Settings Library KafkaLibrary library json
Variables ${SERVER} localhost:9092 ${TOPIC} replication
Test Case [TC-001] - Connect to Kakfa server Connect To Kafka ${SERVER}
[TC-002] - Connect to Kakfa producer Connect Producer ${SERVER}
[TC-003] - Connect to Kakfa consumer Connect Consumer ${SERVER} false
[TC-004] - Get Kakfa topics ${topics}= Get Kafka Topics ${jsontopics}= json.dumps ${topics} log ${jsontopics}
[TC-005] - Send message into Kafka topic &{data}= Create Dictionary name=John surname=Evcimen ${bytedata}= json.dumps ${data} Send ${TOPIC} ${bytedata} log ${bytedata}
[TC-006] - Identify msgs in Kafka topics ${noofmessage}= Get Number Of Messages In Topics ${TOPIC} log ${noofmessage} ${data}= Poll 200000
Please suggest me whats the issue here and the solution to get rid of this?
Thanks Santosh