-
Notifications
You must be signed in to change notification settings - Fork 434
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
Cannot reference Stub Runner random port in Feign Client #1303
Comments
That was supposed to be working. I guess I was too fast to state that. Thanks for the demo, I'll take a look at that. |
When I turn on trace debugging, I see that the DemoFeignClient gets created just before the 'org.springframework.cloud.contract.stubrunner.spring.StubRunnerPortBeanPostProcessor' |
This issue is preventing my entire team from implementing CDC, unfortunately. Just to clarify, our current working tests use As soon as we add Using a fixed port on We use Feign clients only so it seems like there is no way for us to use Spring Cloud Contract, which is a huge shame. Is there anything we could do to help fix this issue? |
I remember that I started to work on this some time ago. The fix is not trivial... The problem lays in Feign not in Spring Cloud Contract. AFAIR Feign is registering its beans early and eagerly - so it can't understand the provided stub runner property. I'll try to look into this again. As a workaround, what you can do is something of the following:
I know that it's not perfect but at least it's a start. |
Thank for your reply @marcingrzejszczak I wonder what the relation between
What do you think? |
|
We currently use @AutoConfigureWireMock, but the proof of concept I am working on doesn't. From what I understand, assuming there are no other subs involved, it's either or - no point in having both annotations. The POC looks like this at the moment (I have removed manually everything I believe irrelevant, so hopefully there won't any silly mistakes):
application-test.properties:
ThirdPartyClient.java:
The above fails because ${stubrunner.runningstubs.some-service.port} is not populated in time. I understand " |
The functionality doesn't overlap really. So what you're showing is a known issue and I'll try to resolve it soonish. |
Thank you. That would be hugly appreciated. |
@lukasz-gryzbon you can check this out spring-cloud/spring-cloud-openfeign#455 to see how this could be fixed . After building it locally feign stuff gets registered later thus the property gets properly resolved |
Thanks @marcingrzejszczak for such a quick reaction. I have tried to test it, but I must be doing something wrong... I keep getting the old version resolved in Gradle. Any tips on how to test it? It may be because our projects use:
I just don't know how to include the version I built locally.... :( |
You'd have to point Gradle to cloud mavenBom 2020.0.0-SNAPSHOT cause the pr is against the master branch of openfeign. So locally you'd have to install feign stuff from my branch. Then you'd have to point in your gradle build to use the mavenLocal repository. Then you have to keep your fingers crossed that gradle resolves it correctly. Remember to also bump boot to 2.4.1. |
Yes! It worked! After several hours of attempts, tweaking and changing approaches, I managed to run the tests against the Many thanks! |
Fixed via spring-cloud/spring-cloud-openfeign#455 |
I have a FeignClient interface that I want to test against my stubs.
@FeignClient(name = "demo", url = "${test.url}")
I would like the stubs to run on a random port
#147 and #1225 suggest that this works. My tests fail because the client tries to connect to port 8082 and the server is started on some random port.
I tried this with SB 2.2.2 and Hoxton.SR1 (see attached zip file)
What am I missing?
demo.zip
The text was updated successfully, but these errors were encountered: