Connection timeout when testing in VM

When I am trying to run tests in a VM in gitlab, I get the following error only on the first test. All other tests pass without any problem. I do not have this issue when I run the tests locally on my local host.

[info]   java.sql.SQLTransientConnectionException: db - Connection is not available, request timed out after 1000ms.
[info]   at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(
[info]   at com.zaxxer.hikari.pool.HikariPool.getConnection(
[info]   at com.zaxxer.hikari.pool.HikariPool.getConnection(
[info]   at com.zaxxer.hikari.HikariDataSource.getConnection(
[info]   at slick.jdbc.hikaricp.HikariCPJdbcDataSource.createConnection(HikariCPJdbcDataSource.scala:18)
[info]   at slick.jdbc.JdbcBackend$BaseSession.<init>(JdbcBackend.scala:439)
[info]   at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:47)
[info]   at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:38)
[info]   at slick.basic.BasicBackend$DatabaseDef.acquireSession(BasicBackend.scala:218)
[info]   at slick.basic.BasicBackend$DatabaseDef.acquireSession$(BasicBackend.scala:217)

It seemed to me to be a connection problem: play/slick/hikari does not have enough time to connect to the database and then, timeout. Therefore, I tried to change the configuration with the following parameters:

play.db.prototype.hikaricp.hikaricp = 60 seconds
play.db.prototype.hikaricp.initializationFailTimeout = 60 seconds

However, I still have the same issues. Rarely, the tests pass (with or without the configuration change). Any idea about how to troubleshoot further and/or what to investigate or change?

Note: I am on Play 2.6.20
Note2: for testing, I am using gitlab and pull the image openjdk:11

Shouldnt establishment of the DB connection be a pre-requisite to test execution? I mean to say execute tests only after DB connection established, so even if that takes time, your tests can wait and then pass?

I believe that the DB connection is established before running any code. But I have no idea why only the first test fail and how such error can be raised then.