-
Notifications
You must be signed in to change notification settings - Fork 40.9k
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
Databases that support embedded and non-embedded modes are always detected as embedded #23693
Conversation
Thanks for the pull request. Unfortunately, it causes several tests to fail. The failures are:
This doesn't feel quite right to me. Instead, I think we'll need to update As @snicoll said this isn't going to be easy to fix and I'm not certain that what I've described above is the right fix without trying it. If you'd like to update this pull request to address the test failures and try this approach, then you are more than welcome to do so. Equally, if you'd prefer that we figure out what needs to be done then we can take care of it in due course. |
Hi Andiy, Ok, I can make the change here to fix the tests. But again, if
you don/t agree with the apporach (checking for existing url) then there's
no point.
I can also make the change to check for the "mem" in the url if you want
and give it a try if that's ok.
Let me know what you might think.
Thanks,
Asha
…On Thu, Oct 15, 2020 at 1:30 AM Andy Wilkinson ***@***.***> wrote:
Thanks for the pull request. Unfortunately, it causes several tests to
fail. The failures are:
:spring-boot-project:spring-boot-autoconfigure:test
org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties()
org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties()
org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties()
org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties()
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername()
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername()
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername()
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername()
org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword()
org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword()
org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword()
org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword()
org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername()
org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername()
org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername()
org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername()
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties()
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties()
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties()
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties()
:spring-boot-project:spring-boot-test-autoconfigure:test
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository()
org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository()
org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository()
org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository()
org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase()
org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase()
org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase()
org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase()
org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource()
org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource()
org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource()
org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource()
org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace()
org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace()
org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace()
org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace()
The jdbc username/password is now determined by evaluating the existence
of the jdbc url
This doesn't feel quite right to me. Instead, I think we'll need to update
EmbeddedDatabaseConnection so that it returns false for an H2 database
that doesn't have mem in its protocol. This would result in isEmbedded(String
driverClass) being deprecated and a new method being introduced that
takes the driverClass and the URL.
As @snicoll said
<#23538 (comment)>
this isn't going to be easy to fix and I"m not certain that what I've
described above is the right fix without trying it. If you'd like to update
this pull request to address the test failures and try this approach, then
you are more than welcome to do so. Equally, if you'd prefer that we figure
out what needs to be done then we can take care of it in due course.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#23693 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIRAZGOORFQA5WLOGWMZ7C3SK2JJXANCNFSM4SRIFC7A>
.
|
Yes, that's certainly ok. It's what I would try if I was attempting to fix the problem. |
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.
Thanks for the PR. This is heading in the right direction but I've found a number of issues.
Please run the build locally and do not use our CI as a way to test your changes.
@@ -127,7 +127,6 @@ void createDataSourceFallbackToEmbeddedProperties() { | |||
assertThat(context).hasSingleBean(Flyway.class); | |||
DataSource dataSource = context.getBean(Flyway.class).getConfiguration().getDataSource(); | |||
assertThat(dataSource).isNotNull(); | |||
assertThat(dataSource).hasFieldOrPropertyWithValue("user", "sa"); |
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 was this removed? It's configuring an embedded database.
@@ -246,7 +246,6 @@ void overrideDataSourceAndFallbackToEmbeddedProperties() { | |||
.run(assertLiquibase((liquibase) -> { | |||
DataSource dataSource = liquibase.getDataSource(); | |||
assertThat(((HikariDataSource) dataSource).isClosed()).isTrue(); | |||
assertThat(((HikariDataSource) dataSource).getUsername()).isEqualTo("sa"); |
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 was this removed? It's configuring an embedded database.
@@ -101,7 +101,7 @@ private void process(BeanDefinitionRegistry registry, ConfigurableListableBeanFa | |||
|
|||
private BeanDefinition createEmbeddedBeanDefinition(boolean primary) { | |||
BeanDefinition beanDefinition = new RootBeanDefinition(EmbeddedDataSourceFactoryBean.class); | |||
beanDefinition.setPrimary(primary); |
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.
That doesn't look right and seems unrelated. Please revert this.
*/ | ||
public static boolean isEmbedded(String driverClass, String url) | ||
{ | ||
return (driverClass != null && (matches(HSQL, driverClass) || ( matches(H2, driverClass) && !StringUtils.hasText("mem")) |
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.
The updated code does not use the url
argument. This also indicates that tests to validate the change of behaviour are missing.
The check on the url must be more narrowed, something like :h2:mem:
perhaps?
Sure, yes. My local works (when it works that is, the mac is crashing every time I try to build here...) |
Fyi, not able to find the root cause here for these, [ant:checkstyle] /root/.gradle/caches/modules-2/files-2.1/com.samskivert/jmustache/1.15/7b3b15951d13b774c76db2f4e14d977952f8b4d8/jmustache-1.15.jar(com/samskivert/mustache/Mustache.java):306: warning: no @return |
This comment has been minimized.
This comment has been minimized.
This issue is noteworthy due to the following behaviour changes:
|
This commit also removes a workaround for spring-projects/spring-boot#23735 and adds spring.datasource.username property to work with the changes made in spring-projects/spring-boot#23693.
This has been labeled as |
Thank you very much for the nudge @izeye. I've added a section in the release notes for RC1. |
… #23538
Bug fix for Can't connect to a local h2 database created without username #23538
The changes were,
#1 The jdbc username/password is now determined by evaluating the existence of the jdbc url
#2 The postProcessBeanDefinitionRegistry method in the TestDatabaseAutoConfiguration does not replace the datasource by the embedded database reference anymore.
This enables allowing a "" empty string username and password as documented in the bug description for the jdbc databases and also enables the database declarated type to define the intrinsic db type selected.
So, a configuration of the below are both supported.
#1 database=h2
spring.datasource.schema=classpath*:db/${database}/schema.sql
spring.datasource.data=classpath*:db/${database}/data.sql
#2
spring.datasource.url=jdbc:h2:~/test
spring.datasource.schema=classpath*:db/${database}/schema.sql
spring.datasource.data=classpath*:db/${database}/data.sql
spring.datasource.username=
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
Tests: I've made sure all unit tests and integration tests are working as expected.
I've used spring-petclinic (2.3.0.BUILD-SNAPSHOT)(springboot-2.4.0-SNAPSHOT) for the integration testing to validate changes.