简体   繁体   中英

Running testcontainers on Jenkins (AKS) inside Docker image

I am trying to run a Jenkins pipeline to run my testcase. My testcase uses testcontainer frameworks. Jenkins has been installed over Azure Kube.netes Service (AKS).

When I try to execute the pipeline, Azure doesnt allow modifiy Docker socket, and this command doesnt work:

-v /var/run/docker.sock:/var/run/docker.sock

Reading AKS guidelines, I found next comment in Container limitations:

You can no longer access the docker engine, /var/run/docker.sock, or use Docker-in-Docker (DinD).

https://learn.microsoft.com/en-us/azure/aks/cluster-configuration#containerd-limitationsdifferences

How can I map Docker socket using AKS in order to execute docker images // testcontainer? Its possible to use testcontainers over AKS or I would need to change my cloud?

According to the Testcontainers documentation :

Testcontainers requires a Docker-API compatible container runtime.

This isn't available in Kube.netes, as you note, and it means you can't use Testcontainers in a Kube.netes-hosted CI system.

You might consider breaking up your test suite into a set of pure unit tests and separate integration tests. The unit tests don't depend on containers or any other external resources, possibly using stub implementations of interfaces or mocks of external API calls; they necessarily only simulate reality, but can run anywhere your build system runs. The integration tests would depend on a fully-deployed application and make API calls to your container's endpoints. This split would let you avoid needing to run external dependencies in the unit-test phase, and thereby avoid Testcontainers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM