Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Automated tests TestCafe chromium作为docker构建的一部分进行测试运行_Automated Tests_Chromium_E2e Testing_Testcafe_Docker Build - Fatal编程技术网

Automated tests TestCafe chromium作为docker构建的一部分进行测试运行

Automated tests TestCafe chromium作为docker构建的一部分进行测试运行,automated-tests,chromium,e2e-testing,testcafe,docker-build,Automated Tests,Chromium,E2e Testing,Testcafe,Docker Build,出于某种原因,在我们的CI中,我们需要在docker容器中运行节点测试(包括获取依赖项等)。所以,我试图让UI测试作为docker构建的一部分运行 以下是我的Dockerfile的外观: FROM testcafe/testcafe:1.3.3 USER root #some packages needed for some dependencies RUN apk add --no-cache yarn python make build-base vim curl RUN ln -s

出于某种原因,在我们的CI中,我们需要在docker容器中运行节点测试(包括获取依赖项等)。所以,我试图让UI测试作为docker构建的一部分运行

以下是我的Dockerfile的外观:

FROM testcafe/testcafe:1.3.3

USER root

#some packages needed for some dependencies
RUN apk add --no-cache yarn python make build-base vim curl 

RUN ln -s /opt/testcafe/docker/testcafe-docker.sh /usr/local/bin/testcafe-docker

WORKDIR /usr/src/app

RUN yarn config set registry https://private-npm-registry --global

COPY package*.json ./

RUN yarn

COPY . .

RUN yarn test:ui:ci

# "test:ui:clean": "rm -rf uitests/reports"
# "test:ui:ci-debug": "yarn test:ui:clean; testcafe-docker 'chromium --no-sandbox' uitests/tests -S -s uitests/reports/screenshots --video uitests/reports/videos -r spec,json:uitests/reports/report.json,html:uitests/reports/report.html",
# "test:ui:ci": "start-server-and-test serve http://127.0.0.1:8080 test:ui:ci-debug"
我发现
错误,无法建立一个或多个指定的浏览器连接。这可能是由网络问题或远程设备故障引起的。

此外,我还尝试使用
user
user,但在运行测试之前,在
uitests
文件夹中创建
reports
文件夹时会出现权限错误

我尝试了使用和不使用
--无沙盒
选项,得到了相同的问题。还尝试了chromium:headless——无沙盒,但得到了相同的错误

有什么建议吗?谢谢

更新: 还尝试了用户:
user
(通过使用报告的
/tmp
文件夹来避免权限问题),但得到了相同的问题:

20-Jul-2019 23:53:33    > yarn test:ui:clean; whoami; ls -sail; testcafe-docker 'chromium --no-sandbox' uitests/tests -S -s /tmp/uitests/reports/screenshots --video /tmp/uitests/reports/videos -r spec,json:/tmp/uitests/reports/report.json,html:/tmp/uitests/reports/report.html
20-Jul-2019 23:53:33    
20-Jul-2019 23:53:34    $ rm -rf /tmp/uitests/reports
20-Jul-2019 23:53:34    user
20-Jul-2019 23:53:34    total 528
20-Jul-2019 23:53:34         13      4 drwxr-xr-x   10 user     user          4096 Jul 20 13:52 .
20-Jul-2019 23:53:34         12      4 drwxr-xr-x    8 root     root          4096 Jul 20 13:52 ..
20-Jul-2019 23:53:34         79      4 -rw-r--r--    1 root     root            20 Jul 19 07:06 .dockerignore
20-Jul-2019 23:53:34         75      4 -rw-r--r--    1 root     root            45 Jul 19 07:06 .eslintignore
20-Jul-2019 23:53:34         83      4 -rw-r--r--    1 root     root           790 Jul 19 07:06 .eslintrc
20-Jul-2019 23:53:34         78      4 drwxr-xr-x    8 root     root          4096 Jul 20 13:48 .git
20-Jul-2019 23:53:34         82      4 -rw-r--r--    1 root     root           326 Jul 20 13:48 .gitignore
20-Jul-2019 23:53:34         87      4 -rw-r--r--    1 root     root           189 Jul 19 07:06 Dockerfile
20-Jul-2019 23:53:34         81      4 -rw-r--r--    1 root     root           592 Jul 20 13:48 DockerfileUITest
20-Jul-2019 23:53:34         89      4 -rw-r--r--    1 root     root           451 Jul 19 07:06 README.md
20-Jul-2019 23:53:34         90      4 drwxr-xr-x    3 root     root          4096 Jul 19 07:06 backend
20-Jul-2019 23:53:34       4096      4 drwxr-xr-x    3 user     user          4096 Jul 20 13:53 build
20-Jul-2019 23:53:34         85      4 -rwxr-xr-x    1 root     root           959 Jul 19 07:06 build.sh
20-Jul-2019 23:53:34         84      4 -rw-r--r--    1 root     root          1124 Jul 19 07:06 deploy.yaml
20-Jul-2019 23:53:34         91      4 drwxr-xr-x 1348 user     user          4096 Jul 20 13:52 node_modules
20-Jul-2019 23:53:34         74      4 -rw-r--r--    1 root     root          2959 Jul 20 13:48 package.json
20-Jul-2019 23:53:34         76      4 drwxr-xr-x    2 root     root          4096 Jul 19 07:06 public
20-Jul-2019 23:53:34         88      4 -rwxr-xr-x    1 root     root           742 Jul 19 07:06 runUITestsInCI.sh
20-Jul-2019 23:53:34         77      4 drwxr-xr-x    8 root     root          4096 Jul 19 07:06 src
20-Jul-2019 23:53:34         80      4 drwxr-xr-x    7 root     root          4096 Jul 19 07:06 uitests
20-Jul-2019 23:53:34         86    448 -rw-r--r--    1 root     root        454847 Jul 20 13:48 yarn.lock
20-Jul-2019 23:53:34    Using locally installed version of TestCafe.
20-Jul-2019 23:55:36    ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.
20-Jul-2019 23:55:36    
20-Jul-2019 23:55:36    Type "testcafe -h" for help.
更新-2: 也尝试使用firefox,但出现相同问题:
错误无法建立一个或多个指定的浏览器连接。这可能是由网络问题或远程设备故障引起的。

更新-3: 抱歉耽搁了。在别的事情上分心了。在CI和本地机器中都进行了尝试,结果是相同的行为。还尝试了在评论
echo-e'中的建议/bin/sh\n/usr/bin/chromium浏览器--无沙箱--远程调试端口=9222--无头'>/usr/local/bin/testcafe docker
,并在CI和本地环境中获得以下输出

02-Dec-2019 18:45:17    DevTools listening on ws://127.0.0.1:9222/devtools/browser/711c6409-be9a-4e08-959e-0c994c8c5742
02-Dec-2019 18:45:17    [1202/074517.060637:ERROR:gl_implementation.cc(282)] Failed to load /usr/lib/chromium/swiftshader/libGLESv2.so: Error loading shared library /usr/lib/chromium/swiftshader/libGLESv2.so: No such file or directory
02-Dec-2019 18:45:17    [1202/074517.064824:ERROR:viz_main_impl.cc(176)] Exiting GPU process due to errors during initialization
02-Dec-2019 18:45:17    [1202/074517.072317:WARNING:dns_config_service_posix.cc(341)] Failed to read DnsConfig.
02-Dec-2019 18:45:17    [1202/074517.072782:WARNING:gpu_process_host.cc(1220)] The GPU process has crashed 1 time(s)
02-Dec-2019 18:45:17    [1202/074517.135149:ERROR:gl_implementation.cc(282)] Failed to load /usr/lib/chromium/swiftshader/libGLESv2.so: Error loading shared library /usr/lib/chromium/swiftshader/libGLESv2.so: No such file or directory
02-Dec-2019 18:45:17    [1202/074517.139203:ERROR:viz_main_impl.cc(176)] Exiting GPU process due to errors during initialization
02-Dec-2019 18:45:17    [1202/074517.143251:WARNING:gpu_process_host.cc(1220)] The GPU process has crashed 2 time(s)
02-Dec-2019 18:45:17    [1202/074517.208950:WARNING:gpu_process_host.cc(990)] Reinitialized the GPU process after a crash. The reported initialization time was 0 ms
02-Dec-2019 18:45:17    [1202/074517.209227:ERROR:gpu_channel_manager.cc(397)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.

最近的“Chromium”版本不允许您在
root
用户下运行它们。在运行TestCafe测试之前,将用户从“root”更改为
user
。 此外,您还需要设置创建新文件夹的权限。 请参见中的详细说明

。。。
用户用户
运行纱线测试:ui:ci

这是因为代理。我们使用代理来访问互联网。我在docker图像中添加了
http\u代理
https\u代理
no\u代理(127.0.0.1)
。docker容器中的浏览器试图通过代理访问testcafe服务器(在同一容器中运行),因为它不使用
127.0.0.1/localhost
,而是使用
172.17.0.2
作为容器中的testcafe服务器主机。因此,将
172.17.0.2
添加到
no_proxy
中是行不通的。

我也尝试了
user
。。但它是一样的。。更新了原始问题。你能提供一个没有你私人物品的docker图像的例子吗?已解决。我的测试试图打开url:
localhost:8080
。。将其更改为
127.0.0.1:8080
有效。可能是docker容器中的某些解决方案问题。。但如果错误信息更清楚,那就太好了。。e、 g.
无法访问localhost:8080
。未来的改进空间。实际上是因为代理。我们使用代理来访问互联网。我在docker图像中添加了
http\u proxy
https\u proxy
no\u proxy
。docker容器中的浏览器可能试图通过代理访问testcafe服务器(在同一容器中运行)。(因为它不使用127.0.0.1/localhost?)删除代理设置暂时有效,因为我不需要在此测试中访问internet。将
172.17.0.2
添加到
无代理
对我有效。将
0,1,2,3,4,5,6,7,8,9
添加到
no_proxy
。。我们不会通过ip地址在internet上访问任何内容。请检查此问题是否可重复:-在您的本地计算机上的Docker中?-在Docker中的CI上显示TestCafe图像?此外,您可能希望将docker文件中的
运行ln-s/opt/testcafe/docker/testcafe-docker.sh/usr/local/bin/testcafe-docker
替换为以下行:
运行echo-e'#/bin/sh\n/usr/bin/chromium浏览器--无沙箱--远程调试端口=9222--无头'>/usr/local/bin/testcafe docker;chmod+x/usr/local/bin/testcafe docker
并向我们提供Chrome输出。更新了原始问题。抱歉耽搁了。它有vnc吗?是否可能在docker容器内看到浏览器(无头)?