Demand backgroundThe team has the need for integration testing, which requires reliance on some middleware, such as mysql and rabbitmq. Every developer has the need to write tests and run tests on the code they develop. In order to avoid mutual interference, you can choose to build your own dependent environment locally in the R&D center. We hope that these environments will be easy, fast, and easy to clean up. Use Docker to build the environment Docker can well meet the above demands.
In summary, using docker can help us quickly build a project dependency environment, but localized docker dependencies still make our code not pure enough during testing, and each operating environment requires local docker installation. Improving integration testing with a centralized docker serverIn fact, Docker itself provides a remote connection mode, which allows us to centrally deploy Docker, and then integrate the test code to build and test dependent middleware using Docker server via TCP connection. Docker Server remote link configurationTaking centos 7.6 as an example, this article explains how to configure a docker to be able to connect remotely. Open the remote connection port in {"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]} Add the file [Service] ExecStart= ExecStart=/usr/bin/dockerd
Testcontainers frameworkAfter deploying the remote docker, the problem that follows is
Fortunately, the Testcontainers framework helps us solve the above problems well.
Testcontainers integrated with spring boot Furthermore, the game company Playtika provides a test framework that integrates Testcontainers with Spring Boot Environment variable dependenciesWhen using Testcontainers or playtika's testcontainers-spring-boot for remote docker links, there is no need to install the docker client locally. However, relevant environment variables need to be configured so that the code can know the address of the remote docker. There are several ways to configure this address:
Use and manage Docker remotely via command lineThe above test code does not require the installation of the Docker client. But if we need to manage docker via the command line, we can install some docker clients to communicate with the remote docker. Of course, the above Testcontainers are equivalent to a kind of client. For client program installation methods for different operating systems, see: https://gist.github.com/kekru/4e6d49b4290a4eebc7b597c07eaf61f2 References https://www.testcontainers.org/ This is the end of this article about using remote Docker for integration testing. For more information about Docker integration testing, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Analysis of the causes of accidents caused by Unicode signature BOM
>>: Vue3 setup() advanced usage examples detailed explanation
Previous This is a classic old question. Since a ...
This article records the detailed installation tu...
Official documentation: JSON Functions Name Descr...
Table of contents What is the listener property? ...
Here is a Vue single sign-on demo for your refere...
I upgraded my Raspberry Pi server to Ubuntu 20 tw...
JavaScript now releases a new version every year,...
Solution 1 Completely uninstall and delete all da...
Installation environment: CentOS7 64-bit MINI ver...
Preface It took two days to reconstruct a puzzle ...
Adding the extra_hosts keyword in docker-compose....
Download image Selecting a MySQL Image docker sea...
1. Conclusion Syntax: limit offset, rows Conclusi...
question: When I was doing project statistics rec...
In HTML, the <img> tag is used to define an...