3

在 docker-compose 文件中,我设置包含 chrome-standalone 图像和另一个节点(名为 test)作为测试运行程序。Cloudbuild.yaml 文件触发测试并且它工作。

这是 docker-compose 文件:

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

我无法添加硒录像机服务。

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的参数不起作用。他们没有得到对方的 ping。

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

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,我会在预期目录中录制视频,但似乎测试无法到达:

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

上面的 docker-compose 文件运行时出错:

测试_1 | 1) 端到端测试 test_1 | 的初步步骤 登录:test_1 | 错误:ECONNREFUSED 连接 ECONNREFUSED 127.0.0.1:4444 test_1 | 在客户端请求。(node_modules/selenium-webdriver/http/index.js:273:15) test_1
| 在 ClientRequest.emit (node:events:394:28) test_1 |
在 Socket.socketErrorListener (node:_http_client:447:9) test_1
| 在 Socket.emit (node:events:394:28) test_1 | 在 emitErrorNT (node:internal/streams/destroy:157:8) test_1 |
在 emitErrorCloseNT (node:internal/streams/destroy:122:3) test_1
| 在 processTicksAndRejections (node:internal/process/task_queues:83:21) test_1 | 测试_1
| 2) 端到端测试 test_1 | 的初步步骤
“登录”的“每个之后”挂钩:test_1 | 错误:ECONNREFUSED 连接 ECONNREFUSED 127.0.0.1:4444 test_1 |
在客户端请求。(node_modules/selenium-webdriver/http/index.js:273:15) test_1
| 在 ClientRequest.emit (node:events:394:28) test_1 |
在 Socket.socketErrorListener (node:_http_client:447:9) test_1
| 在 Socket.emit (node:events:394:28) test_1 | 在 emitErrorNT (node:internal/streams/destroy:157:8) test_1 |
在 emitErrorCloseNT (node:internal/streams/destroy:122:3) test_1
| 在 processTicksAndRejections (节点:internal/process/task_queues:83:21)

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

e2e-tests % docker network inspect e2e-tests_default -f "{{json .Containers }}" {"26858f4ebf7cda76aaa100c8f3db8df14c319a6e3d4c54f839202affde72ad11":{"Name":"e2e-tests_chrome_video_1","EndpointID":"8d3beeb215b524e573db0d6f9a001c04ba9a77823b42e10f45160868af16bd4b","MacAddress":" 02:42:c0:a8:70:04","IPv4Address":"192.168.112.4/20","IPv6Address":""},"972490a8a2e94adc1cb2e73daf5c0b206a89e483330e3d736fef0eca6cd5b170":{"Name","s_EndpointID-test ":"abce602dc1c22ab21b760b50aeca2a77de07304c2c7cc224a7164078f8af56bd","MacAddress":"02:42:c0:a8:70:03","IPv4Address":"192.168.112.3/20","IPv6Address":""},"9ed9962e468cba1cd0fdfe1511fc23c931fd2f0dbf6d95bdb3009809ca097939":{"Name":"e2e-tests_selenium_1",​​"EndpointID":"448b560b932501edb66204f492af8edc38a1bd5ec0c19eb217b6d51ebf48aab0","MacAddress":"02:42:c0:a8:70:02","IPv4Address":"192.168.112.2/20 ","IPv6 地址":""}}

有没有办法为此设置启用视频录制?

提前致谢。

4

1 回答 1

0

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

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

于 2021-08-23T08:57:29.347 回答