Skip to content
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

Bean from TestConfiguration since 2.0.4.RELEASE created after Flyway migrations are executed #13950

Closed
mvitz opened this issue Jul 30, 2018 · 2 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@mvitz
Copy link
Contributor

mvitz commented Jul 30, 2018

See https://github.com/mvitz/spring-boot-jdbc-test for an example application.

We use Junit5 and ru.yandex.qatools.embed:postgresql-embedded in all of our SpringBootTest classes for integration testing against a "real" PostgreSQL because we rely on some JSON features.

The EmbeddedPostgresManager is exposed as a @Bean in a @TestConfigration class which is registered by @ImportAutoConfiguration on a custom annotation (see EmbeddedPostgresSupport).

When upgrading the application to 2.0.4.RELEASE Spring tries to execute the Flyway migrations before the EmbeddedPostgresManager bean is created and therefore fails.

I suspect that this has something to do with #13155.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 30, 2018
@snicoll
Copy link
Member

snicoll commented Jul 31, 2018

Thanks for the sample, that's very helpful.

There are quite a few things wrong with this project and it worked so far by accident:

  1. EmbeddedPostgresManager is not an auto-configuration. If you'd try to load that as a regular auto-config it would blow up as it's not registered in spring.factories.
  2. There is no ordering whatsoever in that code so you're relying on whatever default the context would apply. In particular that @TestConfiguration will kick in quite late whereas it should make sure to start EmbeddedPostgresManager before the DataSource becomes available

You may want to rework 2 in particular. @AutoConfigureTestDatabase is the closest thing that comes to mind with what you're trying to do.

As I believe the sample you've exhibited has some fundamental issue I am going to close this one. If you have more questions, please ask on StackOverflow or join us on Gitter.

@snicoll snicoll closed this as completed Jul 31, 2018
@snicoll snicoll added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 31, 2018
@mvitz
Copy link
Contributor Author

mvitz commented Jul 31, 2018

Thanks for the fast feedback.

I inherited the presented code and it was always suspect to me.

I found a solution which is more like EmbeddedMongoAutoConfiguraion because AutoConfigureTestDatabase expects that the DataSource is swapped out what we want to avoid.

Thanks for your hint and keep up the good work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants