Tests that use h2 in-mem db fail on Heroku

Viewed 802

My Spring boot app has some tests that pass fine on my local, but fail on Heroku:

org.h2.jdbc.JdbcSQLException: Exception opening port "8082" (port may be in use), cause: "java.net.BindException: Address already in use (Bind failed)" [90061-196]

The data source configuration for the test profile:

@Configuration
public class TestDataSourceConfiguration {
    @Bean
    @ConfigurationProperties(prefix = "spring.datasource")
    @Profile("test")
    public DataSource testDataSource() throws URISyntaxException {
        return DataSourceBuilder.create().build();
    }
}

application-test.properties: spring.datasource.url=jdbc:h2:mem:tesdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password=

spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1

I know Heroku doesn't support h2, but this shouldn't be the case here as the app itself brings up the db, right?

Maybe I'm wrong, and it is not failing because of Heroku not supporting h2, but I don't have any other process listening on port 8082 (at least that I know of and being initiated from within my app)

3 Answers
Related