在 docker ptrthomas/karate-chrome 中第二次执行驱动程序/ui karate 测试后连接拒绝 [英] Connexion Refuse after second execution driver/ui karate test in docker ptrthomas/karate-chrome
问题描述
我尝试使用 ptrthomas/karate-chrome 图像泊坞窗.我希望在 docker 映像中执行多个驱动程序/ui 空手道测试.目前使用,你的镜像docker ptrthomas/karate-chrome,但是只有1个场景驱动/ui成功执行.
I try to use ptrthomas/karate-chrome image docker. I wish execute multiple driver/ui karate tests in the docker image. Currently use, your image docker ptrthomas/karate-chrome, but only 1 scenario driver/ui is successful execute.
场景是基本的:
Scenario:
Given driver 'https://github.com/login'
执行后出现这个错误:
[ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 3][route: {}->http://localhost:9222][total available: 0; route allocated: 1 of 5; total allocated: 1 of 10]
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {}->http://localhost:9222
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to localhost/127.0.0.1:9222
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 127.0.0.1:54604<->127.0.0.1:9222
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-3: set socket timeout to 30000
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request GET /json HTTP/1.1
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
我尝试使用 2 个 docker(一个用于执行测试 -maven:3.6-jdk-11,一个用于针对 UI chrome -justinribeiro/chrome-headless:stable )但已经出现问题:连接失败所以,我尝试了对驱动程序的许多配置:
And I try to use 2 dockers (one to execute tests -maven:3.6-jdk-11 and one to target UI chrome -justinribeiro/chrome-headless:stable ) But already issues: connection failed So, I try many configuration to drivers:
karate.configure(
'driver', {
type: 'chrome',
executable: 'chrome',
// port: 9222, //default value
// host: 'localhost', //default value
showDriverLog: true,
showProcessLog: true,
start: false,
headless: true
}
)
Docker_compose:
Docker_compose :
version: '3.7'
networks:
karate: {}
services:
karate-chrome-runner:
image: ptrthomas/karate-chrome
container_name: "karate-chrome-runner_docker"
volumes:
- "~/.m2:/var/maven/.m2"
- "./:/usr/src/mymaven"
environment:
- MAVEN_CONFIG=/var/maven/.m2
working_dir: "/usr/src/mymaven"
entrypoint: "./entrypoint.sh"
networks:
- karate
请你帮我理解正确的操作?你有项目 docker 的例子吗?
Please, would you help me to understand the correct operation? Have you an example to project docker ?
感谢您的帮助
推荐答案
我不知道docker compose,但是请看空手道项目本身使用的回归测试:karate-e2e-tests
I don't know about docker compose, but please look at the regression tests that the Karate project itself uses: karate-e2e-tests
所以 docker 容器是在本地构建的,并且测试在其中运行.这是批处理脚本:build-docker.sh代码>
So the docker container is built locally and the tests are run within it. This is the batch script: build-docker.sh
这里的方法是启动名为 karate
的 docker 容器,并将当前文件夹中的现有测试挂载到 /karate
The approach here is to start the docker container with name karate
and mount your existing tests in the current folder to /karate
docker run --name karate --rm --cap-add=SYS_ADMIN -v "$PWD":/karate -v "$HOME"/.m2:/root/.m2 ptrthomas/karate-chrome &
由于上述是在后台运行的,您现在可以轻松调用命令来运行测试:
Since the above is run in the background you can now easily invoke the command to run tests:
docker exec -w /karate karate mvn test -Dtest=com.myco.MyTestRunner
这篇关于在 docker ptrthomas/karate-chrome 中第二次执行驱动程序/ui karate 测试后连接拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!