Five Databases – Test containers for Integration

For my current LLM training, I had to work on a feeder system that would produce text files for the learning model to learn. The LLM is going to work with five different running apps that I use: Strava, Garmin, Runkeeper, and Nike. The intention of the design is to keep up with the DDD motto and use one Database per microservice.

I ended up using five different databases for

As you can see in the picture above, there are four write Databases and one Read store that feeds the front-end application.

All of this code is dockerized, and I had to do some unit and IT testing for all these databases before I was comfortable with the releases. Maintaining the attributes of each domain database and having the domain thinking for each run system allowed the LLM to compose all the data to be the feeder.

Each system’s DBs and Test containers were a great help with the testing. In order to add to the Boot APP, here is a simple POM entry that I had to add

For the Postgres Test Container, the entry gives me a Test database that I can take over to create a new Postgres instance every time I run their test.

Add this entry for the config file information

@TestConfiguration(proxyBeanMethods = false)
public class ContainersConfig {

    @Bean
    @ServiceConnection
    PostgreSQLContainer<?> postgreSQLContainer() {
        return new PostgreSQLContainer<>(DockerImageName.parse("postgres:16.0-alpine"));
    }
}

Now, to quickly test, all the container configurations are ready to go. This entry helps to validate the same for the Database.

package me.sathish;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;

@DataJpaTest(
        properties = {
            "spring.jpa.hibernate.ddl-auto=create",
            "spring.test.database.replace=none",
            "spring.datasource.url=jdbc:tc:postgresql:16.0-alpine:///appdb"
        })
class SchemaValidationTest {

    @Test
    void validateJpaMappingsWithDbSchema() {}
}


If you happen to follow the boot tool provided by Siva, this code will be automatically generated for your project.

Test Containers has been a great tool for me. Working with so many databases and configuring them is very easy, provides a lot of foolproofing of the system, and allows a lot of shift-left testing when developing microservices.

The entire code base that is outlined is in my GitHub.