https://kotlinlang.org logo
Title
s

sam

12/10/2021, 12:15 PM
5.0.2 is out with a bunch of fixes https://kotest.io/docs/changelog.html
šŸŽ‰ 6
:kotlin-intensifies: 1
t

thanksforallthefish

12/10/2021, 12:17 PM
I just merged a dependency update to 5.0.1 5 minutes ago šŸ˜ž
s

sam

12/10/2021, 12:17 PM
ha sorry
Now you get to make another commit!
šŸ˜‰ 1
b

Big Chungus

12/10/2021, 12:37 PM
Are the new MPP engine setup docs available already?
s

sam

12/10/2021, 12:45 PM
No need to do that still, help is always welcomed.
b

Big Chungus

12/10/2021, 12:46 PM
I would if I wouldn't need the docs myself to understand the changes :D
s

sam

12/10/2021, 12:46 PM
hah
definitely by the end of the weekend, I have time on sunday if not before
b

Big Chungus

12/10/2021, 12:46 PM
Can you make a release-like announcement on #kotest once they're out so I could stop bugging you with the same questions?
s

sam

12/10/2021, 12:47 PM
yep
b

Big Chungus

12/10/2021, 12:47 PM
Much appreciated!
s

sam

12/10/2021, 12:47 PM
reminders set
p

Peter

12/10/2021, 3:24 PM
still having my testcontainers startup issue with 5.0.2 😢
s

sam

12/10/2021, 3:31 PM
yeah I'm publishing 1.1.0 which will work with 5.0.2
šŸ¤ž 1
šŸ™ 1
1.1.0 is out if you want to try it
p

Peter

12/10/2021, 3:53 PM
ok cool šŸ‘€
still the same problem unfortunately šŸ˜ž
s

sam

12/10/2021, 4:01 PM
can you recap your issue
p

Peter

12/10/2021, 4:01 PM
yep, working on a minimal case, brb
class UserSpec: WordSpec() {
    private val network = Network.newNetwork()

    private val postgresContainer = PostgreSQLContainer(DockerImageName.parse("postgres:13"))
        .withDatabaseName(config.databaseConfig.databaseName)
        .withUsername(config.databaseConfig.username)
        .withPassword(config.databaseConfig.password.value)
        .withExposedPorts(5432)
        .withNetwork(network)

    init {
        listener(postgresContainer.perSpec())

        "Users Route" should {
            "" {
                
            }

        }
    }

    override fun beforeSpec(spec: Spec) {
        println(" ${postgresContainer.firstMappedPort}")
    }
}
the
postgresContainer.firstMappedPort
fails with
Caused by: java.lang.IllegalStateException: Mapped port can only be obtained after the container is started
      at org.testcontainers.shaded.com.google.common.base.Preconditions.checkState(Preconditions.java:174)
      at org.testcontainers.containers.ContainerState.getMappedPort(ContainerState.java:142)
      at java.base/java.util.Optional.map(Optional.java:265)
s

sam

12/10/2021, 4:02 PM
the perSpec listener is probably firing after your before spec
p

Peter

12/10/2021, 4:02 PM
100% worked in 4.6.3, 100% failure in 5.x
s

sam

12/10/2021, 4:03 PM
the order is not guaranteed and probably changed between releases
p

Peter

12/10/2021, 4:03 PM
😢
s

sam

12/10/2021, 4:03 PM
we can fix that by moving to a test case extension
p

Peter

12/10/2021, 4:04 PM
i use the
beforeSpec
to setup the connection pool & do flyway etc
s

sam

12/10/2021, 4:04 PM
Yeah that's fine, you just need the container to be guaranteed to fire first, I'll fix it, might take 30 mins
p

Peter

12/10/2021, 4:04 PM
thank you!
s

sam

12/10/2021, 4:52 PM
If you use the new jdbc container stuff, then you should be good
class UserSpec: WordSpec() {
    private val network = Network.newNetwork()

    private val postgresContainer = PostgreSQLContainer(DockerImageName.parse("postgres:13"))
        .withDatabaseName(config.databaseConfig.databaseName)
        .withUsername(config.databaseConfig.username)
        .withPassword(config.databaseConfig.password.value)
        .withExposedPorts(5432)
        .withNetwork(network)

    val ds = install(JdbcTestContainerExtension(postgresContainer)) {
       maximumPoolSize = 8
       minimumIdle = 4
    }

    init {

        "Users Route" should {
            "" {
                
            }

        }
    }

    override fun beforeSpec(spec: Spec) {
        println(" ${postgresContainer.firstMappedPort}")
    }
}
āœ… 1
šŸ‘€ 1