diff --git a/postgres-testdatabaser/src/main/kotlin/com/github/navikt/tbd_libs/test_support/DatabaseContainer.kt b/postgres-testdatabaser/src/main/kotlin/com/github/navikt/tbd_libs/test_support/DatabaseContainer.kt index 8faeb72..b430f03 100644 --- a/postgres-testdatabaser/src/main/kotlin/com/github/navikt/tbd_libs/test_support/DatabaseContainer.kt +++ b/postgres-testdatabaser/src/main/kotlin/com/github/navikt/tbd_libs/test_support/DatabaseContainer.kt @@ -15,11 +15,17 @@ class DatabaseContainer( private val appnavn: String, private val poolSize: Int, private val cleanUpTables: CleanupStrategy? = null, - private val maxHikariPoolSize: Int = 2 + private val maxHikariPoolSize: Int = 2, + private val walLevelLogical: Boolean = false ) { private val instance by lazy { PostgreSQLContainer("postgres:15").apply { withCreateContainerCmdModifier { command -> command.withName(appnavn) } + if (walLevelLogical) { + // Cloud SQL har wal_level = 'logical' på grunn av flagget cloudsql.logical_decoding i + // naiserator.yaml. Vi må sette det samme lokalt for at flyway migrering skal fungere. + withCommand("postgres", "-c", "wal_level=logical") + } withReuse(true) withLabel("app-navn", appnavn) DockerClientFactory.lazyClient().apply { diff --git a/postgres-testdatabaser/src/main/kotlin/com/github/navikt/tbd_libs/test_support/DatabaseContainers.kt b/postgres-testdatabaser/src/main/kotlin/com/github/navikt/tbd_libs/test_support/DatabaseContainers.kt index 37c79bd..c0546a3 100644 --- a/postgres-testdatabaser/src/main/kotlin/com/github/navikt/tbd_libs/test_support/DatabaseContainers.kt +++ b/postgres-testdatabaser/src/main/kotlin/com/github/navikt/tbd_libs/test_support/DatabaseContainers.kt @@ -13,9 +13,9 @@ object DatabaseContainers { // gjenbruker containers med samme navn for å unngå // å spinne opp mange containers - fun container(appnavn: String, cleanUpTables: CleanupStrategy? = null, maxHikariPoolSize: Int = 2, databasePoolSize: Int = POOL_SIZE): DatabaseContainer { + fun container(appnavn: String, cleanUpTables: CleanupStrategy? = null, maxHikariPoolSize: Int = 2, databasePoolSize: Int = POOL_SIZE, walLevelLogical: Boolean = false): DatabaseContainer { return instances.getOrPut(appnavn) { - DatabaseContainer(appnavn, databasePoolSize, cleanUpTables, maxHikariPoolSize) + DatabaseContainer(appnavn, databasePoolSize, cleanUpTables, maxHikariPoolSize, walLevelLogical) } } } \ No newline at end of file