-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Issue:
I am having a little difficulty in figuring out how to take advantage of docker-caching to improve the speed of using test-containers.
Here is my simple use-case. When executing a test which uses MySQLContainer provided by TestContainers:
- The container boots up and executes the init script
init_mysql.sql
every time for setting up database schema. This step can be cached.
MySQLContainer mySQLContainer = new MySQLContainer()
.withDatabaseName("test_database")
.withInitScript("mysql-container/init_mysql.sql")
.withUsername("test")
.withPassword("test")
.start();
- After the init script is executed and the container is ready, a
java.sql.connection
is created to the database and some of the tables are populated with data. This step can also be cached, by somehow included it during the creation of docker image.
All of this takes more ~1m30sec to 2m
for the container to be ready for testing.
Question:
How can above code/process be restructured so that it can advantage of docker-caching feature to enable faster testing time ?