1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
# frozen_string_literal: true
module QA
RSpec.describe Service::DockerRun::Video do
include QA::Support::Helpers::StubEnv
let(:rspec_config) { instance_double('RSpec::Core::Configuration', prepend_before: nil, prepend_after: nil) }
let(:video_recorder_image) { 'presidenten/selenoid-manual-video-recorder' }
let(:video_recorder_version) { 'latest' }
let(:selenoid_browser_image) { 'selenoid/chrome' }
let(:selenoid_browser_version) { '111.0' }
let(:remote_grid) { 'selenoid:4444' }
let(:record_video) { 'true' }
let(:use_selenoid) { 'true' }
let(:allure_report) { 'false' }
let(:docs_link) do
'https://gitlab.com/gitlab-org/gitlab-qa/-/blob/master/docs/running_against_remote_grid.md#testing-with-selenoid'
end
shared_examples 'video set up fails' do
it 'does not perform configuration' do
aggregate_failures do
expect(QA::Runtime::Logger).to have_received(:warn)
.with(/Test failure video recording setup failed!/)
expect(RSpec).not_to have_received(:configure)
end
end
end
shared_examples 'video set up missing variable' do |missing_variable|
let(:failure_message) do
<<~FAIL.tr("\n", ' ').strip
Aborting video recording setup!
Missing variables: #{missing_variable} is required!
See docs: #{docs_link}
FAIL
end
it 'aborts video setup with warning' do
aggregate_failures do
expect(QA::Runtime::Logger).to have_received(:warn)
.with(failure_message)
expect(described_class).not_to have_received(:get_container_name)
expect(RSpec).not_to have_received(:configure)
end
end
end
before do
stub_env('QA_VIDEO_RECORDER_IMAGE', video_recorder_image)
stub_env('QA_VIDEO_RECORDER_VERSION', video_recorder_version)
stub_env('QA_SELENOID_BROWSER_IMAGE', selenoid_browser_image)
stub_env('QA_SELENOID_BROWSER_VERSION', selenoid_browser_version)
stub_env('QA_REMOTE_GRID', remote_grid)
stub_env('USE_SELENOID', use_selenoid)
stub_env('QA_RECORD_VIDEO', record_video)
stub_env('QA_GENERATE_ALLURE_REPORT', allure_report)
allow(RSpec).to receive(:configure).and_yield(rspec_config)
allow(described_class).to receive(:get_container_name)
allow(described_class).to receive(:shell)
allow(QA::Runtime::Logger).to receive(:warn)
allow(QA::Runtime::Logger).to receive(:info)
end
context 'with video disabled' do
let(:record_video) { 'false' }
before do
described_class.configure!
end
it 'skips configuration' do
aggregate_failures do
expect(described_class).not_to have_received(:get_container_name)
expect(described_class).not_to have_received(:shell)
expect(RSpec).not_to have_received(:configure)
end
end
end
context 'with use_selenoid disabled' do
let(:use_selenoid) { 'false' }
before do
described_class.configure!
end
it_behaves_like 'video set up missing variable', 'USE_SELENOID'
end
context 'without video_recorder_image set' do
let(:video_recorder_image) { nil }
before do
described_class.configure!
end
it_behaves_like 'video set up missing variable', 'QA_VIDEO_RECORDER_IMAGE'
end
context 'without selenoid_browser_image set' do
let(:selenoid_browser_image) { nil }
before do
described_class.configure!
end
it_behaves_like 'video set up missing variable', 'QA_SELENOID_BROWSER_IMAGE'
end
context 'without selenoid_browser_version set' do
let(:selenoid_browser_version) { nil }
before do
described_class.configure!
end
it_behaves_like 'video set up missing variable', 'QA_SELENOID_BROWSER_VERSION'
end
context 'without browser_container_hostname' do
before do
allow(described_class).to receive(:get_container_name)
.with(video_recorder_image)
.and_return('recorder_container_name')
allow(described_class).to receive(:get_container_name)
.with("#{selenoid_browser_image}:#{selenoid_browser_version}")
.and_return('browser_image_hostname')
allow(described_class).to receive(:shell)
.and_return(false)
described_class.configure!
end
it_behaves_like 'video set up fails'
end
context 'without recorder_container_name' do
before do
allow(described_class).to receive(:get_container_name)
.with(video_recorder_image)
.and_return('')
allow(described_class).to receive(:get_container_name)
.with("#{selenoid_browser_image}:#{selenoid_browser_version}")
.and_return('browser_image_hostname')
allow(described_class).to receive(:shell)
.and_return('browser_container_hostname')
described_class.configure!
end
it_behaves_like 'video set up fails'
end
context 'with recorder_container_name and browser_container_hostname' do
before do
allow(described_class).to receive(:get_container_name)
.with(video_recorder_image)
.and_return('recorder_container_name')
allow(described_class).to receive(:get_container_name)
.with("#{selenoid_browser_image}:#{selenoid_browser_version}")
.and_return('browser_image_hostname')
allow(described_class).to receive(:shell)
.and_return('browser_container_hostname')
described_class.configure!
end
it 'performs configuration' do
aggregate_failures do
expect(QA::Runtime::Logger).to have_received(:info)
.with(/Test failure video recording setup complete!/)
expect(RSpec).to have_received(:configure)
expect(rspec_config).to have_received(:prepend_before)
expect(rspec_config).to have_received(:prepend_after)
end
end
context 'with generate_allure_report' do
let(:rspec_config) do
instance_double('RSpec::Core::Configuration',
prepend_before: nil,
prepend_after: nil,
append_after: nil)
end
let(:allure_report) { 'true' }
it 'performs configuration with allure report' do
aggregate_failures do
expect(QA::Runtime::Logger).to have_received(:info)
.with(/Test failure video recording setup complete!/)
expect(RSpec).to have_received(:configure).twice
expect(rspec_config).to have_received(:prepend_before)
expect(rspec_config).to have_received(:prepend_after)
expect(rspec_config).to have_received(:append_after)
end
end
end
end
end
end
|