首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Selenium视频不能由network_mode作为坞-组合的主机工作

Selenium视频不能由network_mode作为坞-组合的主机工作
EN

Stack Overflow用户
提问于 2021-08-20 16:35:59
回答 1查看 928关注 0票数 3

在docker文件中,我设置了包含铬独立映像和另一个节点(名为test)的测试运行程序。Cloudbuild.yaml文件触发测试,它可以工作。

下面是docker-组合文件:

代码语言:javascript
复制
version: "3"
services:
  selenium:
    image: selenium/standalone-chrome:4
    volumes:
    - /dev/shm:/dev/shm
    network_mode: host

  test:
    image:  node:16-alpine
    entrypoint:
    - sh
    - -c
    - |-
      cd /test
      npm install
      sleep 3
      npm run test
    volumes:
    - .:/test
    depends_on:
    - selenium
    network_mode: host

我不能添加selenium录像机服务。

代码语言:javascript
复制
chrome_video:
    image: selenium/video:ffmpeg-4.3.1-20210804
    volumes:
      - /Users/videos:/videos 
    depends_on:
      - selenium
    environment:
      - DISPLAY_CONTAINER_NAME=selenium
      - FILE_NAME=chrome_video.mp4

network_mode:host作为参数添加到chrome_video中是行不通的。他们没有得到对方的平安。

初始化chrome_video容器后,它的日志文件:

代码语言:javascript
复制
2021-08-20 16:23:05,910 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.

2021-08-20 16:23:05,913 INFO supervisord started with pid 10

2021-08-20 16:23:06,915 INFO spawned: 'video-recording' with pid 12

2021-08-20 16:23:06,920 INFO spawned: 'video-ready' with pid 13

Checking if the display is open...

2021-08-20 16:23:06,924 INFO success: video-recording entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

2021-08-20 16:23:06,924 INFO success: video-ready entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Waiting before next display check...

Waiting before next display check...

ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers

built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)

configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --enable-libaribb24 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib

libavutil 56. 51.100 / 56. 51.100

libavcodec 58. 91.100 / 58. 91.100

libavformat 58. 45.100 / 58. 45.100

libavdevice 58. 10.100 / 58. 10.100

libavfilter 7. 85.100 / 7. 85.100

libavresample 4. 0. 0 / 4. 0. 0

libswscale 5. 7.100 / 5. 7.100

libswresample 3. 7.100 / 3. 7.100

libpostproc 55. 7.100 / 55. 7.100

[x11grab @ 0x55f0bf04fb80] Cannot open display selenium:99.0, error 1.

selenium:99.0: Input/output error

2021-08-20 16:23:32,692 INFO exited: video-recording (exit status 1; not expected)Waiting before next display check...

Waiting before next display check...


Waiting before next display check...

Waiting before next display check...

ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers

built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)

configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --enable-libaribb24 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib

libavutil 56. 51.100 / 56. 51.100

libavcodec 58. 91.100 / 58. 91.100

libavformat 58. 45.100 / 58. 45.100

libavdevice 58. 10.100 / 58. 10.100

libavfilter 7. 85.100 / 7. 85.100

libavresample 4. 0. 0 / 4. 0. 0

libswscale 5. 7.100 / 5. 7.100

libswresample 3. 7.100 / 3. 7.100

libpostproc 55. 7.100 / 55. 7.100

[x11grab @ 0x55f0bf04fb80] Cannot open display selenium:99.0, error 1.

selenium:99.0: Input/output error

2021-08-20 16:23:32,692 INFO exited: video-recording (exit status 1; not expected)



 Waiting before next display check...
    
    Waiting before next display check...
    
    Waiting before next display check...
    
    Waiting before next display check...
    
    ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
    
    built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
    
    configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --enable-libaribb24 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib
    
    libavutil 56. 51.100 / 56. 51.100
    
    libavcodec 58. 91.100 / 58. 91.100
    
    libavformat 58. 45.100 / 58. 45.100
    
    libavdevice 58. 10.100 / 58. 10.100
    
    libavfilter 7. 85.100 / 7. 85.100
    
    libavresample 4. 0. 0 / 4. 0. 0
    
    libswscale 5. 7.100 / 5. 7.100
    
    libswresample 3. 7.100 / 3. 7.100
    
    libpostproc 55. 7.100 / 55. 7.100
    
    [x11grab @ 0x55f0bf04fb80] Cannot open display selenium:99.0, error 1.
    
    selenium:99.0: Input/output error
    
    2021-08-20 16:23:32,692 INFO exited: video-recording (exit status 1; not expected)

如果我按下面的方式编辑docker-composer,我会得到预期目录中的视频记录,但是测试似乎无法达到以下目标:

代码语言:javascript
复制
version: "3"
services:
  selenium:
    image: selenium/standalone-chrome:4
    volumes:
    - /dev/shm:/dev/shm

  test:
    image:  node:16-alpine
    entrypoint:
    - sh
    - -c
    - |-
      cd /test
      npm install
      sleep 3
      npm run test
    volumes:
    - .:/test
    depends_on:
    - selenium

  chrome_video:
    image: selenium/video:ffmpeg-4.3.1-20210804 
    volumes:
      - /Users/videos:/videos # /artifacts/videos:/videos
    depends_on:
      - selenium
    environment:
      - DISPLAY_CONTAINER_NAME=selenium
      - FILE_NAME=chrome_video.mp4

当运行上述停靠-组合文件时出错:

test_1 test_1 1)端到端测试的初步步骤: test_1登录: test_1 \x{e76f}错误: ECONNREFUSED连接ECONNREFUSED 127.0.0.1:4444 test_1 at ClientRequest。(node_modules/selenium-webdriver/http/index.js:273:15) test_1

ClientRequest.emit (节点:事件:394:28)

在Socket.socketErrorListener (node:_http_client:447:9) test_1

在Socket.emit (节点:事件:394:28),在emitErrorNT (节点:内部/流/销毁:157:8)

在emitErrorCloseNT (节点:内部/流/销毁:122:3) test_1

在processTicksAndRejections (节点:内部/进程/任务队列:83:21)

2)端到端测试的初步步骤( test_1 )

在“登录”的每个“钩子”之后: test_1 / test_1错误: ECONNREFUSED ECONNREFUSED 127.0.0.1:4444 test_1 1-x

在ClientRequest。(node_modules/selenium-webdriver/http/index.js:273:15) test_1

ClientRequest.emit (节点:事件:394:28)

在Socket.socketErrorListener (node:_http_client:447:9) test_1

在Socket.emit (节点:事件:394:28),在emitErrorNT (节点:内部/流/销毁:157:8)

在emitErrorCloseNT (节点:内部/流/销毁:122:3) test_1

在processTicksAndRejections (节点:内部/进程/任务队列:83:21)

顺便说一句,所有的容器都在同一个网络中(公共网络的名称是e2e-tests_default):)

测试% docker网络检查e2e-test_default -f“{json .Containers }”

"MacAddress":"02:42:c0:a8:70:04","IPv4Address":"192.168.112.4/20",“IPv6Address”:“},"972490a8a2e94adc1cb2e73daf5c0b206a89e483330e3d736fef0eca6cd5b170":{"Name":"e2e-tests_test_1","EndpointID":"abce602dc1c22ab21b760b50aeca2a77de07304c2c7cc224a7164078f8af56bd",”"MacAddress":"02:42:c0:a8:70:03","IPv4Address":"192.168.112.3/20",“IPv6Address”:“}”,"MacAddress":"02:42:c0:a8:70:02","IPv4Address":"192.168.112.2/20",“IPv6Address:”}

是否有为此设置启用视频记录的方法?

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-08-23 08:57:29

除非需要在主机上运行服务,否则不需要使用network_mode: host

此外,视频容器需要知道VNC运行的服务/容器的名称,记录流。在这种情况下,基于您共享的docker-compose文件,DISPLAY_CONTAINER_NAME=chrome实际上应该是DISPLAY_CONTAINER_NAME=selenium

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68865436

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档