When bootstrapping an ApplicationContext
using the ApplicationContextRunner
it seems like the applications HealthEndpoint
is in an unhealthy state because both the liveness and readiness probes are unhealthy. This only happens when management.health.probes.enabled
is true or when running the tests in an kubernetes environment.
Expected result: neither of the two ways of bootstrapping the application should result in healthEndpoint.health().getStatus()
returning DOWN
.
Comment From: wilkinsona
Thanks for the demo project. The behaviour that you are seeing is to be expected.
the two ways of bootstrapping the application
In this this is the reason why your expectation isn't being met. Your demo isn't using two different way of bootstrapping the application. It's using @SpringBootTest
that runs the entire SpringApplication
and ApplicationContextRunner
that only runs an application context. When using ApplicationContextRunner
you lose the functionality that SpringApplication
provides. This includes publishing of SpringApplicationEvents
, some of which update the application availability that is used by the liveness and readiness probes.
ApplicationContextRunner
is documented as a mechanism for testing your own auto-configuration and this is how we recommend that it be used. If you want to test your whole application, we recommend using @SpringBootTest
or, if you don't want to make use of the test framework, manually creating and running a SpringApplication
in your tests.