Open alexandrepa opened 3 weeks ago
Hey. As I said in previous discussions, I'm a strong supporter of this proposal. However, we have to consider the backward compatibility. Some people might not be happy that a Tzatziki upgrade make their test fail because they need time for undoing all their fixes in their Gherkin files they had to do to stabilize their tests. This is why I would suggest to provide an option to disable this check to give people time to migrate. In that case, the check could log an error instead of failing.
I agree with you, seems a good way to operate. By default, the tests will failed if there is no KafkaInterceptor, and the failure should mention the issue and the possibility to disable the failing of the test with a property.
Exactly
Hello ! Maybe this is worth giving a try ?
We do this by adding the name of the class in the standard file resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports:
com.baeldung.autoconfiguration.MySQLAutoconfiguration
Adding the interceptor as an auto-import candidate should work but I might be wrong and maybe the mechanism comes too late for this case.
I just did a test and it seems to be working 😄 thanks !
The only issue is how do we handle the users that are currently wrongly using the kafka lib in their test. Adding this could lead to failing test in their projects.
Maybe creating a major version with a warrant int the README. And add the possibility to disable the KafkaInterceptor.
I'm not sure why it would fail those and in any case I think it's better in every aspect to auto-inject, otherwise you just don't take this dependency as the whole Kafka module is based-off the interceptor. So IMO just make the change without caring about that (and if some users complain we can find a solution and maybe add a switch but pretty sure it's not needed)
I'm not sure why it would fail
Some projets have adjusted/hacked their expected values in their test just make their tests repeatable, instead of fixing the tests using KafkaInterceptor
. For these projects, enabling KafkaInterceptor
will bring their test back to a normal behaviour, making their hacks fail. They need time to migrate their legacy tests by removing their hacks
I have changed my mind about the need for a switch: these users can stick to the previous version of Tzatziki while migrating, and upgrade to the latest Tzatziki version when their migration is complete.
Using the tzatziki-kafka module, we have seen some users complaining about instability and struggling to test their kafka topics. It was due to the fact that KafkaInterceptor was not in the classpath. Tzatziki could not add some aspectj around kafka consumer. We already added some instructions in the README to avoid that.
Second thing we can do is to check that the component is in the spring context. If it's not the case we could stops the test and log a message.
The purpose of this issue is to discuss how can we assure the KafkaInterceptor is initialized and also how do we want to address it to the user.
To check if KafkaInterceptor is initialized, maybe the best way is to
@Autowired (optional)
it in KafkaSteps and check in@Before
method if its not null.