在docker ptrthomas/karate-chrome中进行第二次执行驱动程序/ui空手道测试后的Connexion拒绝 [英] 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项目本身使用的回归测试:
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空手道测试后的Connexion拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!