8

I have the following issue.

In order to speed up the integration test pipeline I want to run testcontainers with Quarkus with TMPFS option set. This will force testcontainers to run the DB with a in-memory file system.

This can be easily done according to testcontainers website like this ...

To pass this option to the container, add TC_TMPFS parameter to the URL as follows: jdbc:tc:postgresql:9.6.8:///databasename?TC_TMPFS=/testtmpfs:rw

Seems like problem solved. This is how it should work with Spring Boot

However, with Quarkus in their docs it says the following ...

All services based on containers are ran using testcontainers. Even though extra URL properties can be set in your application.properties file, specific testcontainers properties such as TC_INITSCRIPT, TC_INITFUNCTION, TC_DAEMON, TC_TMPFS are not supported.

And my question is:

How can you work around this ? How can I run my testcontainer which will be mounted on TMPFS ?

davioooh
  • 23,742
  • 39
  • 159
  • 250
Arthur Klezovich
  • 2,595
  • 1
  • 13
  • 17

2 Answers2

4

You can try to set the TMPFS using a QuarkusTestResourceLifecycleManager guide.

Quarkus Kotlin example:


class DatabaseTestLifeCycleManager : QuarkusTestResourceLifecycleManager {
    private val postgresDockerImage = DockerImageName.parse("postgres:latest")

    override fun start(): MutableMap<String, String>? {
        val container = startPostgresContainer()

        return mutableMapOf(
            "quarkus.datasource.username" to container.username,
            "quarkus.datasource.password" to container.password,
            "quarkus.datasource.jdbc.url" to container.jdbcUrl
        )
    }

    private fun startPostgresContainer(): PostgreSQLContainer<out PostgreSQLContainer<*>> {
        val container = PostgreSQLContainer(postgresDockerImage)
            .withDatabaseName("dataBaseName")
            .withUsername("username")
            .withPassword("password")
            .withEnv(mapOf("PGDATA" to "/var/lib/postgresql/data"))
            .withTmpFs(mapOf("/var/lib/postgresql/data" to "rw"))
        container.start()
        return container
    }

    override fun stop() {
        // close container
    }
}
1

You could try using the following configuration:

quarkus.datasource.url=jdbc:tc:postgresql:9.6.8:///databasename?TC_TMPFS=/testtmpfs:rw
James
  • 144
  • 6