gitlab-qa 10.2.2 → 10.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/docs/running_against_remote_grid.md +10 -5
- data/fixtures/selenoid/browsers.json +25 -0
- data/lib/gitlab/qa/component/selenoid.rb +88 -0
- data/lib/gitlab/qa/component/specs.rb +15 -0
- data/lib/gitlab/qa/runtime/env.rb +20 -1
- data/lib/gitlab/qa/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2851a74117f3479437a3e355883c7a407d4f56c41aac2700028cd9686790f0ea
|
4
|
+
data.tar.gz: a284df28173a258c4948ead8be3c677df487c585b60cc73ffe88d5c12b6281b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44a1c9743ce4fafbaad0e20f2de55598c4686598a2c3ac50d9da69565e72a477e3a0ab90f909fb32ed2b153129912b365db19ee9af91814bf6db707dc4bc70f4
|
7
|
+
data.tar.gz: f2d8e7accf348103ff3f7ab85467186dd11a7c51a5cdb691e3e8999716272ba54a06204257395a7594ea832c60b93d33a11fd198c57b957609599638ab3b2672
|
data/Gemfile.lock
CHANGED
@@ -9,12 +9,17 @@ I.e, if you have a Selenium server set up at http://localhost:4444 or if you hav
|
|
9
9
|
| Variable | Description | Default | Example(s) |
|
10
10
|
|---------------------------|----------------------------------------------------------------|----------|--------------------------------|
|
11
11
|
| QA_BROWSER | Browser to run against | "chrome" | "chrome" "firefox" "safari" |
|
12
|
+
| QA_BROWSER_VERSION | Version of browser to run against | "latest" | "latest" "111.0" "mobile-111.0"|
|
12
13
|
| QA_REMOTE_GRID_PROTOCOL | Protocol to use | "http" | "http" "https" |
|
13
|
-
| QA_REMOTE_GRID | Remote grid to run tests against | | "localhost:3000" "provider:80" |
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
| QA_REMOTE_GRID | Remote grid to run tests against | | "localhost:3000" "provider:80" "selenoid:4444" |
|
15
|
+
| QA_LAYOUT | Used with Selenoid. Tells test nav to expect collapsed menus. "phone" expects collapsed top and left nav bars, "tablet" expects collapsed left nav bar only. | | "phone", "tablet" |
|
16
|
+
| SELENOID_DIRECTORY | Used with Selenoid. Directory to save videos to | "<host_artifacts_dir>/selenoid" | |
|
17
|
+
| USE_SELENOID | Used with Selenoid. Sets up selenoid containers. | false | false, true |
|
18
|
+
| QA_RECORD_VIDEO | Used with Selenoid. Triggers video recording. | false | false, true |
|
19
|
+
| QA_REMOTE_GRID_USERNAME | Used with Sauce Labs. Username to specify in the remote grid. "USERNAME@provider:80" | | "gitlab-sl" |
|
20
|
+
| QA_REMOTE_GRID_ACCESS_KEY | Used with Sauce Labs. Key/Token paired with `QA_REMOTE_GRID_USERNAME` | | |
|
21
|
+
| QA_REMOTE_TUNNEL_ID | Used with Sauce Labs. Name of the remote tunnel to use | "gitlab-sl_tunnel_id" | |
|
22
|
+
| QA_REMOTE_MOBILE_DEVICE_NAME | Used with Sauce Labs. Name of mobile device to test against. `QA_BROWSER` must be set to `safari` for iOS devices and `chrome` for Android devices. | | "iPhone 12 Simulator" |
|
18
23
|
|
19
24
|
## Testing with Sauce Labs
|
20
25
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"chrome": {
|
3
|
+
"default": "111.0",
|
4
|
+
"versions": {
|
5
|
+
"111.0": {
|
6
|
+
"image": "selenoid/chrome:111.0",
|
7
|
+
"port": "4444"
|
8
|
+
},
|
9
|
+
"mobile-111.0": {
|
10
|
+
"image": "registry.gitlab.com/gitlab-org/gitlab-qa/selenoid-chrome-gitlab:mobile-111.0",
|
11
|
+
"path": "/wd/hub",
|
12
|
+
"port": "4444"
|
13
|
+
}
|
14
|
+
}
|
15
|
+
},
|
16
|
+
"MicrosoftEdge": {
|
17
|
+
"default": "111.0",
|
18
|
+
"versions": {
|
19
|
+
"111.0": {
|
20
|
+
"image": "browsers/edge:111.0",
|
21
|
+
"port": "4444"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'http'
|
4
|
+
|
5
|
+
module Gitlab
|
6
|
+
module QA
|
7
|
+
module Component
|
8
|
+
# Component for the Selenoid Grid
|
9
|
+
# https://aerokube.com/selenoid/latest/
|
10
|
+
class Selenoid < Base
|
11
|
+
DOCKER_IMAGE = 'aerokube/selenoid'
|
12
|
+
DOCKER_IMAGE_TAG = 'latest-release'
|
13
|
+
|
14
|
+
def name
|
15
|
+
@name ||= 'selenoid'
|
16
|
+
end
|
17
|
+
|
18
|
+
def instance
|
19
|
+
Runtime::Env.webdriver_headless = '0'
|
20
|
+
Runtime::Env.chrome_disable_dev_shm = 'true'
|
21
|
+
Runtime::Env.remote_grid = "#{hostname}:4444"
|
22
|
+
Runtime::Env.remote_grid_protocol = 'http'
|
23
|
+
raise 'Please provide a block!' unless block_given?
|
24
|
+
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def start
|
29
|
+
pull_images
|
30
|
+
docker.run(image: image, tag: tag, args: ['-container-network', network]) do |command|
|
31
|
+
set_command_args(command)
|
32
|
+
set_volumes(command)
|
33
|
+
end
|
34
|
+
|
35
|
+
wait_until_ready
|
36
|
+
end
|
37
|
+
|
38
|
+
def wait_until_ready(max_attempts: 20, wait: 2)
|
39
|
+
Runtime::Logger.info("Waiting for Selenoid ...")
|
40
|
+
|
41
|
+
max_attempts.times do
|
42
|
+
return Runtime::Logger.info("Selenoid ready!") if grid_healthy?
|
43
|
+
|
44
|
+
sleep wait
|
45
|
+
end
|
46
|
+
|
47
|
+
raise "Retried #{max_attempts} times. Selenoid is not responding. Aborting."
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def grid_healthy?
|
53
|
+
HTTP.get('http://localhost:4444/ping').status&.success?
|
54
|
+
rescue HTTP::ConnectionError => _e
|
55
|
+
false
|
56
|
+
end
|
57
|
+
|
58
|
+
def pull_images
|
59
|
+
docker.pull(image: "selenoid/chrome", tag: Runtime::Env.browser_version) if Runtime::Env.browser == :chrome && !Runtime::Env.mobile_layout?
|
60
|
+
docker.pull(image: "selenoid/video-recorder", tag: "latest-release")
|
61
|
+
end
|
62
|
+
|
63
|
+
# Set custom run command arguments
|
64
|
+
#
|
65
|
+
# @param [Docker::Command] command
|
66
|
+
# @return [void]
|
67
|
+
def set_command_args(command)
|
68
|
+
command << '-d '
|
69
|
+
command << "--name #{name}"
|
70
|
+
command << "--net #{network}"
|
71
|
+
command << "--hostname #{hostname}"
|
72
|
+
command << "--publish 4444:4444"
|
73
|
+
command << "-e OVERRIDE_VIDEO_OUTPUT_DIR=#{Runtime::Env.selenoid_directory}/video"
|
74
|
+
end
|
75
|
+
|
76
|
+
# Set volumes
|
77
|
+
#
|
78
|
+
# @param [Docker::Command] command
|
79
|
+
# @return [void]
|
80
|
+
def set_volumes(command)
|
81
|
+
command.volume('/var/run/docker.sock', '/var/run/docker.sock')
|
82
|
+
command.volume("#{__dir__}/../../../../fixtures/selenoid", "/etc/selenoid")
|
83
|
+
command.volume("#{Runtime::Env.selenoid_directory}/video", '/opt/selenoid/video')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# rubocop:disable Metrics/CyclomaticComplexity
|
3
|
+
# rubocop:disable Metrics/AbcSize
|
3
4
|
|
4
5
|
require 'securerandom'
|
5
6
|
|
@@ -27,6 +28,19 @@ module Gitlab
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def perform
|
31
|
+
if Runtime::Env.use_selenoid?
|
32
|
+
Component::Selenoid.perform do |selenoid|
|
33
|
+
selenoid.network = network
|
34
|
+
selenoid.instance do
|
35
|
+
internal_perform
|
36
|
+
end
|
37
|
+
end
|
38
|
+
else
|
39
|
+
internal_perform
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def internal_perform
|
30
44
|
return Runtime::Logger.info("Skipping tests.") if skip_tests?
|
31
45
|
|
32
46
|
raise ArgumentError unless [suite, release].all?
|
@@ -114,3 +128,4 @@ module Gitlab
|
|
114
128
|
end
|
115
129
|
end
|
116
130
|
# rubocop:enable Metrics/CyclomaticComplexity
|
131
|
+
# rubocop:enable Metrics/AbcSize
|
@@ -41,6 +41,7 @@ module Gitlab
|
|
41
41
|
'QA_INFLUXDB_TOKEN' => :qa_influxdb_token,
|
42
42
|
'QA_SKIP_PULL' => :qa_skip_pull,
|
43
43
|
'QA_VALIDATE_RESOURCE_REUSE' => :qa_validate_resource_reuse,
|
44
|
+
'WEBDRIVER_HEADLESS' => :webdriver_headless,
|
44
45
|
'GITLAB_API_BASE' => :api_base,
|
45
46
|
'GITLAB_ADMIN_USERNAME' => :admin_username,
|
46
47
|
'GITLAB_ADMIN_PASSWORD' => :admin_password,
|
@@ -148,7 +149,9 @@ module Gitlab
|
|
148
149
|
'RELEASE' => :release,
|
149
150
|
'RELEASE_REGISTRY_URL' => :release_registry_url,
|
150
151
|
'RELEASE_REGISTRY_USERNAME' => :release_registry_username,
|
151
|
-
'RELEASE_REGISTRY_PASSWORD' => :release_registry_password
|
152
|
+
'RELEASE_REGISTRY_PASSWORD' => :release_registry_password,
|
153
|
+
'SELENOID_DIRECTORY' => :selenoid_directory,
|
154
|
+
'USE_SELENOID' => :use_selenoid
|
152
155
|
}.freeze
|
153
156
|
|
154
157
|
ENV_VARIABLES.each do |env_name, method_name|
|
@@ -349,6 +352,22 @@ module Gitlab
|
|
349
352
|
enabled?(env_var_value_if_defined('QA_EXPORT_TEST_METRICS'), default: true)
|
350
353
|
end
|
351
354
|
|
355
|
+
def selenoid_directory
|
356
|
+
env_var_value_if_defined('SELENOID_DIRECTORY') || "#{host_artifacts_dir}/selenoid"
|
357
|
+
end
|
358
|
+
|
359
|
+
def use_selenoid?
|
360
|
+
enabled?(env_var_value_if_defined('USE_SELENOID'), default: false)
|
361
|
+
end
|
362
|
+
|
363
|
+
def mobile_layout?
|
364
|
+
env_var_value_if_defined('QA_LAYOUT')&.match?(/tablet|phone/i)
|
365
|
+
end
|
366
|
+
|
367
|
+
def browser_version
|
368
|
+
env_var_value_if_defined('QA_BROWSER_VERSION')
|
369
|
+
end
|
370
|
+
|
352
371
|
def qa_run_type
|
353
372
|
return env_var_value_if_defined('QA_RUN_TYPE') if env_var_value_valid?('QA_RUN_TYPE')
|
354
373
|
|
data/lib/gitlab/qa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-qa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.
|
4
|
+
version: 10.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab Quality
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|
@@ -360,6 +360,7 @@ files:
|
|
360
360
|
- fixtures/ldap/2_add_users.ldif
|
361
361
|
- fixtures/ldap/3_add_groups.ldif
|
362
362
|
- fixtures/ldap/tanuki.ldif
|
363
|
+
- fixtures/selenoid/browsers.json
|
363
364
|
- gitlab-qa.gemspec
|
364
365
|
- lefthook.yml
|
365
366
|
- lib/gitlab/qa.rb
|
@@ -382,6 +383,7 @@ files:
|
|
382
383
|
- lib/gitlab/qa/component/production.rb
|
383
384
|
- lib/gitlab/qa/component/release.rb
|
384
385
|
- lib/gitlab/qa/component/saml.rb
|
386
|
+
- lib/gitlab/qa/component/selenoid.rb
|
385
387
|
- lib/gitlab/qa/component/specs.rb
|
386
388
|
- lib/gitlab/qa/component/staging.rb
|
387
389
|
- lib/gitlab/qa/component/staging_ref.rb
|