zonkyio / embedded-database-spring-test

A library for creating isolated embedded databases for Spring-powered integration tests.
Apache License 2.0
399 stars 37 forks source link

Zonky pulling from docker registry instead of ECR #227

Closed Severon96 closed 1 year ago

Severon96 commented 1 year ago

Hello together,

i'm currently facing an issue where zonky is pulling the postgres db image from the docker registry in my AWS CodePipeline. Because of this problem i've used the "zonky.test.database.postgres.docker.image"-property to set the url of the image that instead should be pulled from my own ecr. My pipeline always logs in successfully but only sometimes pulls from the Elastic Container Registry. Locally it works all the time.

In my pom, the only dependency is:

        <dependency>
            <groupId>io.zonky.test</groupId>
            <artifactId>embedded-database-spring-test</artifactId>
            <version>2.1.1</version>
            <scope>test</scope>
        </dependency>

My project has 3 .properties-Files (application.properties, application-aws.properties, application-junit.properties). Each of them got the "zonky.test.database.postgres.docker.image"-property added into them. Just to be sure that it will be pulled. But nevertheless it only randomly pulls from the ECR.

Anyone here who knows what could cause the issue?

Thanks in advance.

tomix26 commented 1 year ago

Hi @Severon96,

I've never heard of such a problem. I guess it could be caused by a wrong configuration. So please check spring profiles and other similar things that can affect the configuration. For further investigation I need a reproducer. You can use and fork embedded-database-demo for that purpose.

Severon96 commented 1 year ago

Would be hard to reproduce this topic, since I can't create a completely new build pipeline in our backend just for testing purposes. Is there another way to debug this behavior?

tomix26 commented 1 year ago

Since the problem is most likely related to your specific configuration, it is very difficult to investigate it without a reproducer. However, you can try to add some additional logging to the failing tests to detect if the error is in the configuration or in the library. Check out the example below. If all logged messages contain only ECR image, then the bug is in the library, otherwise the error is in the configuration of your project. Then you can enable trace logging on the org.springframework.core.env.PropertySourcesPropertyResolver class to trace the source of the wrong configuration.

@Autowired
private Environment environment;

@Before // or @BeforeEach
public void logDockerImageProperty() {
    String dockerImage = environment.getProperty("zonky.test.database.postgres.docker.image", "postgres:11-alpine");
    logger.info("Docker image: {}", dockerImage);
}
tomix26 commented 1 year ago

I'm closing the issue. Feel free to reopen it if the problem persists.