spring-cloud / spring-cloud-stream-binder-kafka

Spring Cloud Stream binders for Apache Kafka and Kafka Streams
Apache License 2.0
331 stars 301 forks source link

The problem with testing state store using Interactive Query Service #1080

Closed inspector44 closed 3 years ago

inspector44 commented 3 years ago

I'm trying to test multiple stream processors at the same application. I can produce data for processors and after proceeding data to the processor my business logic works and materializes results in the store. I saw the store directory created successfully and some results in it. But the problem when injecting the InteractiveQueryService and calling the getQueryableStore. Can't see any results from the getQueryableStore method. In the main application there isn't any problem I can send the rest request to the controller and can see the correct result. But, the problem is in the test application.

I asked a question on the StackOverflow. You can reproduce with it; https://stackoverflow.com/questions/67621964/how-to-test-state-store-in-apache-kafka-using-spring-cloud-stream/67626796#67626796

Application.ymls are almost the same as the main application except for brokers, application servers, and state-store-retry config.

sobychacko commented 3 years ago

@kadiralan Here is a test in the framework that verifies interactive queries from state store. In this test, querying the state-store works. Could you compare with this and see what is different in your setup?

inspector44 commented 3 years ago

@sobychacko thank you for the support. But, I've already come across it. They are testing with Mockito but I'm using Embedded Kafka Broker. And my goal is to build with Embedded Broker and using the InteractiveQueryService.

sobychacko commented 3 years ago

This test does not have any mock interactions: https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/blob/main/spring-cloud-stream-binder-kafka-streams/src/test/java/org/springframework/cloud/stream/binder/kafka/streams/KafkaStreamsInteractiveQueryIntegrationTests.java#L124

See here: https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/blob/main/spring-cloud-stream-binder-kafka-streams/src/test/java/org/springframework/cloud/stream/binder/kafka/streams/KafkaStreamsInteractiveQueryIntegrationTests.java#L172

sabbyanandan commented 3 years ago

Closing due to no activity.