-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix 1831 #1863
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
Fix 1831 #1863
Conversation
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
@@ -49,6 +49,13 @@ | |||
</dependency> | |||
|
|||
<!-- Testing Dependencies --> | |||
|
|||
<dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what you think about this.. In order to properly test that things are indeed fixed, I need this dependency as test
scope. It surely looks a bit weird, since the discovery pom is requesting config one, even if it does so for tests only. Let me know your thoughts here please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the test need to be in the discovery module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to reproduce the issue in a test, we need two classes :
Fabric8ConfigServerBootstrapper
KubernetesConfigDataLocationResolver
. Since this one is abstract, we need an implementation, so I chose :Fabric8ConfigDataLocationResolver
, thus the maven modulespring-cloud-kubernetes-fabric8-config
as a test dependency here.
So the test is either here with that test dependency, or I move it to the integration tests project. Though I did not try that, so not sure if extra work would not be needed, but this is the explanation. I hope it makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the unit test could we provide an implementation of KubernetesConfigDataLocationResolver
to simulate a real implementation and test it that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah nice! just did that, thank you
kubernetesClientProperties = context.getBootstrapContext() | ||
.get(KubernetesClientProperties.class) | ||
.withNamespace(namespace); | ||
if (bootstrapContext.isRegistered(PROPERTIES_CLASS) && bootstrapContext.get(PROPERTIES_CLASS) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we used to do :
if ( bootstrapContext.isRegistered(PROPERTIES_CLASS) { ... }
but now, we will do :
bootstrapContext.isRegistered(PROPERTIES_CLASS) && bootstrapContext.get(PROPERTIES_CLASS) != null
.getBeanFactory() | ||
.registerSingleton(name, event.getBootstrapContext().get(cls)); | ||
|
||
T singleton = event.getBootstrapContext().get(cls); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have missed this one if it was not for the test tbh.
@ryanjbaxter ready to be looked at. Thank you |
* | ||
* @author wind57 | ||
*/ | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without the fix, this test fails
Signed-off-by: wind57 <[email protected]>
No description provided.