Draft: Introduce grid containers using selenoid for video recording
What does this MR do and why?
This MR introduces the ability to run the tests against a grid using Selenoid when the USE_SELENOID
environment variable is set.
This is mostly initial work for the idea; extra plumbing has to be done in the QA framework to record video, as well as export it properly.
in qa/runtime/browser.rb:146
if QA::Runtime::Env.remote_grid
selenium_options[:browser] = :remote
selenium_options[:url] = QA::Runtime::Env.remote_grid
capabilities[:browserVersion] = 'latest'
capabilities['sauce:options'] = { tunnelIdentifier: QA::Runtime::Env.remote_tunnel_id }
# add selenoid capabilties as referenced here:
# https://aerokube.com/selenoid/latest/#_video_recording_enablevideo_videoname_videoscreensize_videoframerate_videocodec
capabilities['selenoid:options'] = {
enableVideo: true,
# set video name (will want to do this per spec)
# videoName: 'something.mp4'
}
end
Notes
- The QA framework reuses the browser session per multiple tests. It will need to spin up new sessions per test if we want separate video.
- The QA framework starts the test by generating a PAT via the UI. Caution is needed when thinking of exporting video as artifacts.
This is not necessarily the case, because pretty much all environments have admin user with PAT which is predefined via environment variable on pretty much all pipelines, so creating PAT via UI isn't necessary.
- Run locally, the video size for the Test::Integration::Integrations job (4 tests) is 540KB, so it should be doable to store as an artifact.
- Selenoid does not distinguish failed vs passing tests. It will generate video for everything. Intervention might be required.
Screenshots or screen recordings
How to set up and validate locally
- Add the snippet above to a local copy of the QA Framework, the create a local docker image
docker build -t gitlab/gitlab-ce-qa:your-custom-tag --file ./qa/Dockerfile ./
- Spin up the gitlab/selenoid containers using
USE_SELENOID=true
with./exe/gitlab-qa
and the args--no-teardown --no-tests
- Ex in gitlab-qa/:
USE_SELENOID=true ./exe/gitlab-qa Test::Instance::Image EE --no-teardown --no-tests
- This should create conatiners for gitlab and the selenoid grid that are on the network
test
- We will need the hostname of the running selenoid container and the port for the gitlab nightly container in order to point the browser to it from the test container. (
docker ps
)
- Ex in gitlab-qa/:
- Manually kick off the QA image by overriding the entrypoint
CHROME_DISABLE_DEV_SHM=true docker run -it --entrypoint="/bin/bash" --network=test gitlab/gitlab-ce-qa:your-custom-tag
- Run some tests:
QA_REMOTE_GRID="<name-of-selenoid-container>:4444" WEBDRIVER_HEADLESS=false bundle exec bin/qa Test::Instance::All <your_ip>:<port_for_nightly_image> -- path_to_some_spec.rb
- Note: We have to run it with
WEBDRIVER_HEADLESS=false
or we get a blank video.
- Note: We have to run it with
- Get the video from the volume mount from selenoid -
/opt/selenoid/video/<video>.mp4
- Easiest way to view the video is to visit
localhost:4444/video
- Easiest way to view the video is to visit
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.