gitlab-qa 5.13.5 → 5.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +2 -0
- data/README.md +52 -5
- data/docs/run_qa_against_gdk.md +3 -0
- data/docs/what_tests_can_be_run.md +20 -5
- data/lib/gitlab/qa.rb +1 -0
- data/lib/gitlab/qa/component/base.rb +22 -3
- data/lib/gitlab/qa/component/gitlab.rb +2 -1
- data/lib/gitlab/qa/component/specs.rb +9 -1
- data/lib/gitlab/qa/docker/engine.rb +17 -2
- data/lib/gitlab/qa/release.rb +15 -3
- data/lib/gitlab/qa/runner.rb +23 -15
- data/lib/gitlab/qa/runtime/env.rb +4 -6
- data/lib/gitlab/qa/scenario/test/instance/airgapped.rb +68 -0
- data/lib/gitlab/qa/scenario/test/integration/praefect.rb +18 -7
- data/lib/gitlab/qa/scenario/test/sanity/version.rb +1 -1
- data/lib/gitlab/qa/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32ae85f17e98b415ac5fddd505d5cf9d37462bbcc5b0eabee7584c3a26803542
|
4
|
+
data.tar.gz: 62ea7475a8d3eddb193a975c440fc19b2177ea612ecf8a02d9bbf9a8c926f177
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35e187728145ac187fda0dbe3b41b24d44adc52a3cb8718083736ccf0e36f06a089c74e97db983b4b40f2eb432fa847c440208e083df24d8f9a5df76a495b0d7
|
7
|
+
data.tar.gz: a7e08091352126ada545f61b6d7a940e0eb87f4ec9d9753fa0521244c2f35b209a0474eb158b7e82486ee7fe5ae59047d3748fd6aadd36922d96b9520081b177
|
data/.gitlab-ci.yml
CHANGED
@@ -31,6 +31,8 @@ workflow:
|
|
31
31
|
- if: '$CI_COMMIT_BRANCH == "master"'
|
32
32
|
# For tags, create a pipeline.
|
33
33
|
- if: '$CI_COMMIT_TAG'
|
34
|
+
# For triggers from GitLab MR pipelines (and pipelines from other projects), create a pipeline
|
35
|
+
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
|
34
36
|
|
35
37
|
.default-rules:
|
36
38
|
rules:
|
data/README.md
CHANGED
@@ -121,11 +121,58 @@ All the scenarios you can run are described in the
|
|
121
121
|
|
122
122
|
Note: The GitLab QA tool requires that [Docker](https://docs.docker.com/install/) is installed.
|
123
123
|
|
124
|
-
###
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
124
|
+
### Command-line options
|
125
|
+
|
126
|
+
In addition to the [arguments you can use to specify the scenario and
|
127
|
+
tests to run](/docs/what_tests_can_be_run.md), you can use the
|
128
|
+
following options to control the tool's behavior.
|
129
|
+
|
130
|
+
**Note:** These are `gitlab-qa` options so if you specify RSpec
|
131
|
+
options as well, including test file paths, be sure to add these
|
132
|
+
options before the `--` that indicates that subsequent arguments are
|
133
|
+
intended for RSpec.
|
134
|
+
|
135
|
+
| Option | Description |
|
136
|
+
| ------ | ----------- |
|
137
|
+
| `--no-teardown` | Skip teardown of containers after the scenario completes |
|
138
|
+
| `--no-tests` | Orchestrates the docker containers but does not run the tests. Implies `--no-teardown` |
|
139
|
+
|
140
|
+
For example, the following command would start an EE GitLab Docker
|
141
|
+
container and would leave the instance running, but would not run the
|
142
|
+
tests:
|
143
|
+
|
144
|
+
```plaintext
|
145
|
+
$ gitlab-qa Test::Instance::Image EE --no-tests
|
146
|
+
```
|
147
|
+
|
148
|
+
GitLab QA will have automatically run the `docker ps` command to show
|
149
|
+
the port that container is running on, for example:
|
150
|
+
|
151
|
+
```plaintext
|
152
|
+
...
|
153
|
+
Skipping tests.
|
154
|
+
The orchestrated docker containers have not been removed.
|
155
|
+
Docker shell command: `docker ps`
|
156
|
+
CONTAINER ID IMAGE ... PORTS
|
157
|
+
fdeffd791b69 gitlab/gitlab-ee:nightly 22/tcp, 443/tcp, 0.0.0.0:32768->80/tcp
|
158
|
+
```
|
159
|
+
|
160
|
+
You could then run tests against that instance in a similar way to
|
161
|
+
[running tests against GDK](/docs/run_qa_against_gdk.md). This can be
|
162
|
+
useful if you want to run and debug a specific test, for example:
|
163
|
+
|
164
|
+
```plaintext
|
165
|
+
# From /path/to/gdk/gitlab/qa
|
166
|
+
$ bundle exec bin/qa Test::Instance::All http://localhost:32768 -- qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb
|
167
|
+
```
|
168
|
+
|
169
|
+
### How to add new tests
|
170
|
+
|
171
|
+
Please see the [Beginner's guide to writing end-to-end tests](https://docs.gitlab.com/ee/development/testing_guide/end_to_end/beginners_guide.html).
|
172
|
+
|
173
|
+
Test cases and scripts to run them are located in the
|
174
|
+
[GitLab FOSS](https://gitlab.com/gitlab-org/gitlab-foss/tree/master/qa) and
|
175
|
+
[GitLab](https://gitlab.com/gitlab-org/gitlab/tree/master/qa)
|
129
176
|
repositories under the `qa/` directory, so please also check the documentation
|
130
177
|
there.
|
131
178
|
|
data/docs/run_qa_against_gdk.md
CHANGED
@@ -42,6 +42,9 @@ make a few changes to your `gdk/gitlab/config/gitlab.yml` file.
|
|
42
42
|
$ exe/gitlab-qa Test::Instance::Any gitlab/gitlab-ce:your-custom-tag http://192.168.0.12:3000 -- qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb
|
43
43
|
```
|
44
44
|
|
45
|
+
**Note:** The hostname of the URL provided to `gitlab-qa` must match the hostname configured for GDK.
|
46
|
+
If they do not match, a test will be signed out when it visits a page directly because the hostname of the URL visited will be different from the hostname that was used when signing in.
|
47
|
+
|
45
48
|
### Running EE tests
|
46
49
|
|
47
50
|
When running EE tests you'll need to have a license available. GitLab engineers can [request a license](https://about.gitlab.com/handbook/developer-onboarding/#working-on-gitlab-ee).
|
@@ -57,14 +57,14 @@ For more details on the internals, please read the
|
|
57
57
|
| `QA_ARTIFACTS_DIR` |`/tmp/gitlab-qa`| Path to a directory where artifacts (logs and screenshots) for failing tests will be saved. | No|
|
58
58
|
| `DOCKER_HOST` |`http://localhost`| Docker host to run tests against. | No|
|
59
59
|
| `CHROME_HEADLESS` |- | When running locally, set to `false` to allow Chrome tests to be visible - watch your tests being run. | No|
|
60
|
-
| `QA_ADDITIONAL_REPOSITORY_STORAGE` |- | The name of additional, non-default storage to be used with tests tagged `repository_storage`, run via the `Test::Instance::RepositoryStorage` scenario. | No|
|
61
|
-
| `QA_PRAEFECT_REPOSITORY_STORAGE` |- | The name of repository storage using Praefect. | No|
|
60
|
+
| `QA_ADDITIONAL_REPOSITORY_STORAGE` |- | The name of additional, non-default storage to be used with tests tagged `repository_storage`, run via the `Test::Instance::RepositoryStorage` scenario. Note: Admin access is required to change repository storage. | No|
|
61
|
+
| `QA_PRAEFECT_REPOSITORY_STORAGE` |- | The name of repository storage using Praefect. Note: Admin access is required to change repository storage. | No|
|
62
62
|
| `QA_COOKIES` |- | Optionally set to "cookie1=value;cookie2=value" in order to add a cookie to every request. This can be used to set the canary cookie by setting it to "gitlab_canary=true". | No|
|
63
63
|
| `QA_DEBUG` |- | Set to `true` to verbosely log page object actions. Note: if enabled be aware that sensitive data might be logged. If an input element has a QA selector with `password` in the name, data entered into the input element will be masked. If the element doesn't have `password` in its name it won't be masked. | No|
|
64
64
|
| `QA_LOG_PATH` |- | Path to output debug logging to. If not set logging will be output to STDOUT. | No|
|
65
|
-
| `QA_CAN_TEST_GIT_PROTOCOL_V2`
|
66
|
-
| `QA_CAN_TEST_ADMIN_FEATURES`
|
67
|
-
| `QA_CAN_TEST_PRAEFECT`
|
65
|
+
| `QA_CAN_TEST_GIT_PROTOCOL_V2` | `true` | Set to `false` to skip tests that require Git protocol v2 if your environment doesn't support it. | No|
|
66
|
+
| `QA_CAN_TEST_ADMIN_FEATURES` | `true` | Set to `false` to skip tests that require admin access. | No|
|
67
|
+
| `QA_CAN_TEST_PRAEFECT` | `true` | Set to `false` to skip tests that require Praefect to be running. | No|
|
68
68
|
| `QA_DISABLE_RSPEC_RETRY` |- | Set to `true` to turn off retrying tests on failure. | No|
|
69
69
|
| `QA_SIMULATE_SLOW_CONNECTION` |- | Set to `true` to configure Chrome's network settings to simulate a slow connection. | No|
|
70
70
|
| `QA_SLOW_CONNECTION_LATENCY_MS` | `2000` | The additional latency (in ms) of the simulated slow connection. | No|
|
@@ -618,6 +618,21 @@ $ export QA_ADDITIONAL_REPOSITORY_STORAGE=secondary
|
|
618
618
|
$ gitlab-qa Test::Instance::RepositoryStorage
|
619
619
|
```
|
620
620
|
|
621
|
+
### `Test::Instance::Airgapped`
|
622
|
+
|
623
|
+
This scenario will run tests from the test suite against an airgapped instance.
|
624
|
+
The airgapped instance is set up by using `iptables` in the GitLab container to block network traffic other than testable ports, and by using runners
|
625
|
+
in a shared internal network.
|
626
|
+
|
627
|
+
Example:
|
628
|
+
|
629
|
+
```
|
630
|
+
# For EE
|
631
|
+
$ export EE_LICENSE=$(cat /path/to/gitlab_license)
|
632
|
+
|
633
|
+
$ gitlab-qa Test::Instance::Airgapped EE -- --tag smoke
|
634
|
+
```
|
635
|
+
|
621
636
|
----
|
622
637
|
|
623
638
|
[Back to README.md](../README.md)
|
data/lib/gitlab/qa.rb
CHANGED
@@ -29,6 +29,7 @@ module Gitlab
|
|
29
29
|
autoload :Release, 'gitlab/qa/scenario/test/instance/release'
|
30
30
|
autoload :Geo, 'gitlab/qa/scenario/test/instance/geo'
|
31
31
|
autoload :StagingGeo, 'gitlab/qa/scenario/test/instance/staging_geo'
|
32
|
+
autoload :Airgapped, 'gitlab/qa/scenario/test/instance/airgapped'
|
32
33
|
end
|
33
34
|
|
34
35
|
module Omnibus
|
@@ -5,7 +5,7 @@ module Gitlab
|
|
5
5
|
include Scenario::Actable
|
6
6
|
|
7
7
|
attr_reader :docker
|
8
|
-
attr_accessor :volumes, :network, :environment
|
8
|
+
attr_accessor :volumes, :network, :environment, :runner_network
|
9
9
|
attr_writer :name, :exec_commands
|
10
10
|
|
11
11
|
def initialize
|
@@ -61,12 +61,14 @@ module Gitlab
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def prepare_docker_image
|
64
|
-
return if Runtime::Env.skip_pull?
|
65
|
-
|
66
64
|
pull
|
67
65
|
end
|
68
66
|
|
69
67
|
def prepare_network
|
68
|
+
if runner_network && !docker.network_exists?(runner_network)
|
69
|
+
docker.network_create("--driver=bridge --internal #{runner_network}")
|
70
|
+
end
|
71
|
+
|
70
72
|
return if docker.network_exists?(network)
|
71
73
|
|
72
74
|
docker.network_create(network)
|
@@ -102,6 +104,17 @@ module Gitlab
|
|
102
104
|
end
|
103
105
|
|
104
106
|
def teardown
|
107
|
+
unless teardown?
|
108
|
+
puts "The orchestrated docker containers have not been removed."
|
109
|
+
docker.ps
|
110
|
+
|
111
|
+
return
|
112
|
+
end
|
113
|
+
|
114
|
+
teardown!
|
115
|
+
end
|
116
|
+
|
117
|
+
def teardown!
|
105
118
|
assert_name!
|
106
119
|
|
107
120
|
return unless docker.running?(name)
|
@@ -111,6 +124,8 @@ module Gitlab
|
|
111
124
|
end
|
112
125
|
|
113
126
|
def pull
|
127
|
+
return if Runtime::Env.skip_pull?
|
128
|
+
|
114
129
|
docker.pull(image, tag)
|
115
130
|
end
|
116
131
|
|
@@ -125,6 +140,10 @@ module Gitlab
|
|
125
140
|
def assert_name!
|
126
141
|
raise 'Invalid instance name!' unless name
|
127
142
|
end
|
143
|
+
|
144
|
+
def teardown?
|
145
|
+
!Runtime::Scenario.attributes.include?(:teardown) || Runtime::Scenario.teardown
|
146
|
+
end
|
128
147
|
end
|
129
148
|
end
|
130
149
|
end
|
@@ -11,7 +11,7 @@ module Gitlab
|
|
11
11
|
extend Forwardable
|
12
12
|
|
13
13
|
attr_reader :release
|
14
|
-
attr_accessor :tls, :disable_animations, :skip_availability_check
|
14
|
+
attr_accessor :tls, :disable_animations, :skip_availability_check, :runner_network
|
15
15
|
attr_writer :name, :relative_path
|
16
16
|
|
17
17
|
def_delegators :release, :tag, :image, :edition
|
@@ -116,6 +116,7 @@ module Gitlab
|
|
116
116
|
command << "--network-alias #{network_alias}"
|
117
117
|
end
|
118
118
|
end
|
119
|
+
Docker::Command.execute("network connect --alias #{name}.#{network} --alias #{name}.#{runner_network} #{runner_network} #{name}") if runner_network
|
119
120
|
end
|
120
121
|
|
121
122
|
def reconfigure
|
@@ -8,7 +8,7 @@ module Gitlab
|
|
8
8
|
# the `qa/` directory located in GitLab CE / EE repositories.
|
9
9
|
#
|
10
10
|
class Specs < Scenario::Template
|
11
|
-
attr_accessor :suite, :release, :network, :args, :volumes, :env
|
11
|
+
attr_accessor :suite, :release, :network, :args, :volumes, :env, :runner_network
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
@docker = Docker::Engine.new
|
@@ -17,6 +17,8 @@ module Gitlab
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def perform # rubocop:disable Metrics/AbcSize
|
20
|
+
return puts "Skipping tests." if skip_tests?
|
21
|
+
|
20
22
|
raise ArgumentError unless [suite, release].all?
|
21
23
|
|
22
24
|
@docker.login(**release.login_params) if release.login_params
|
@@ -42,6 +44,12 @@ module Gitlab
|
|
42
44
|
command.name(name)
|
43
45
|
end
|
44
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def skip_tests?
|
51
|
+
Runtime::Scenario.attributes.include?(:run_tests) && !Runtime::Scenario.run_tests
|
52
|
+
end
|
45
53
|
end
|
46
54
|
end
|
47
55
|
end
|
@@ -3,13 +3,14 @@ module Gitlab
|
|
3
3
|
module Docker
|
4
4
|
class Engine
|
5
5
|
DOCKER_HOST = ENV['DOCKER_HOST'] || 'http://localhost'
|
6
|
+
PRIVILEGED_COMMANDS = [/^iptables.*/].freeze
|
6
7
|
|
7
8
|
def hostname
|
8
9
|
URI(DOCKER_HOST).host
|
9
10
|
end
|
10
11
|
|
11
12
|
def login(username:, password:, registry:)
|
12
|
-
Docker::Command.execute(
|
13
|
+
Docker::Command.execute(%(login --username "#{username}" --password "#{password}" #{registry}))
|
13
14
|
end
|
14
15
|
|
15
16
|
def pull(image, tag)
|
@@ -27,8 +28,18 @@ module Gitlab
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
31
|
+
def privileged_command?(command)
|
32
|
+
PRIVILEGED_COMMANDS.each do |privileged_regex|
|
33
|
+
return true if command.match(privileged_regex)
|
34
|
+
end
|
35
|
+
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
30
39
|
def exec(name, command)
|
31
|
-
|
40
|
+
cmd = ['exec']
|
41
|
+
cmd << '--privileged' if privileged_command?(command)
|
42
|
+
Docker::Command.execute("#{cmd.join(' ')} #{name} bash -c '#{command}'")
|
32
43
|
end
|
33
44
|
|
34
45
|
def read_file(image, tag, path, &block)
|
@@ -71,6 +82,10 @@ module Gitlab
|
|
71
82
|
def running?(name)
|
72
83
|
Docker::Command.execute("ps -f name=#{name}").include?(name)
|
73
84
|
end
|
85
|
+
|
86
|
+
def ps(name = nil)
|
87
|
+
Docker::Command.execute(['ps', name].compact.join(' '))
|
88
|
+
end
|
74
89
|
end
|
75
90
|
end
|
76
91
|
end
|
data/lib/gitlab/qa/release.rb
CHANGED
@@ -136,6 +136,8 @@ module Gitlab
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def login_params
|
139
|
+
return if Runtime::Env.skip_pull?
|
140
|
+
|
139
141
|
if dev_gitlab_org?
|
140
142
|
Runtime::Env.require_qa_dev_access_token!
|
141
143
|
|
@@ -145,11 +147,17 @@ module Gitlab
|
|
145
147
|
registry: DEV_REGISTRY
|
146
148
|
}
|
147
149
|
elsif omnibus_mirror?
|
148
|
-
Runtime::Env.
|
150
|
+
username, password = if Runtime::Env.ci_job_token
|
151
|
+
['gitlab-ci-token', Runtime::Env.ci_job_token]
|
152
|
+
else
|
153
|
+
Runtime::Env.require_qa_access_token!
|
154
|
+
|
155
|
+
[Runtime::Env.gitlab_username, Runtime::Env.qa_access_token]
|
156
|
+
end
|
149
157
|
|
150
158
|
{
|
151
|
-
username:
|
152
|
-
password:
|
159
|
+
username: username,
|
160
|
+
password: password,
|
153
161
|
registry: COM_REGISTRY
|
154
162
|
}
|
155
163
|
end
|
@@ -167,6 +175,10 @@ module Gitlab
|
|
167
175
|
canonical? || release.match?(CUSTOM_GITLAB_IMAGE_REGEX)
|
168
176
|
end
|
169
177
|
|
178
|
+
def api_project_name
|
179
|
+
project_name.gsub('ce', 'foss').gsub('-ee', '')
|
180
|
+
end
|
181
|
+
|
170
182
|
private
|
171
183
|
|
172
184
|
def canonical?
|
data/lib/gitlab/qa/runner.rb
CHANGED
@@ -4,22 +4,20 @@ module Gitlab
|
|
4
4
|
module QA
|
5
5
|
# rubocop:disable Metrics/AbcSize
|
6
6
|
class Runner
|
7
|
-
# These options are implemented in the QA framework (i.e., in the CE/EE codebase)
|
8
|
-
# They're included here so that gitlab-qa treats them as valid options
|
9
|
-
PASS_THROUGH_OPTS = [
|
10
|
-
['--address URL', 'Address of the instance to test'],
|
11
|
-
['--enable-feature FEATURE_FLAG', 'Enable a feature before running tests'],
|
12
|
-
['--mattermost-address URL', 'Address of the Mattermost server'],
|
13
|
-
['--parallel', 'Execute tests in parallel'],
|
14
|
-
['--loop', 'Execute tests in a loop']
|
15
|
-
].freeze
|
16
|
-
|
17
7
|
def self.run(args)
|
18
|
-
|
8
|
+
Runtime::Scenario.define(:teardown, true)
|
9
|
+
Runtime::Scenario.define(:run_tests, true)
|
10
|
+
|
11
|
+
@options = OptionParser.new do |opts|
|
19
12
|
opts.banner = 'Usage: gitlab-qa [options] Scenario URL [[--] path] [rspec_options]'
|
20
13
|
|
21
|
-
|
22
|
-
|
14
|
+
opts.on('--no-teardown', 'Skip teardown of containers after the scenario completes.') do
|
15
|
+
Runtime::Scenario.define(:teardown, false)
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on('--no-tests', 'Orchestrates the docker containers but does not run the tests. Implies --no-teardown') do
|
19
|
+
Runtime::Scenario.define(:run_tests, false)
|
20
|
+
Runtime::Scenario.define(:teardown, false)
|
23
21
|
end
|
24
22
|
|
25
23
|
opts.on_tail('-v', '--version', 'Show the version') do
|
@@ -33,19 +31,29 @@ module Gitlab
|
|
33
31
|
exit
|
34
32
|
end
|
35
33
|
|
36
|
-
|
34
|
+
begin
|
35
|
+
opts.parse(args)
|
36
|
+
rescue OptionParser::InvalidOption
|
37
|
+
# Ignore invalid options and options that are passed through to the tests
|
38
|
+
end
|
37
39
|
end
|
38
40
|
|
41
|
+
args.reject! { |arg| gitlab_qa_options.include?(arg) }
|
42
|
+
|
39
43
|
if args.size >= 1
|
40
44
|
Scenario
|
41
45
|
.const_get(args.shift)
|
42
46
|
.perform(*args)
|
43
47
|
else
|
44
|
-
puts options
|
48
|
+
puts @options
|
45
49
|
exit 1
|
46
50
|
end
|
47
51
|
end
|
48
52
|
# rubocop:enable Metrics/AbcSize
|
53
|
+
|
54
|
+
def self.gitlab_qa_options
|
55
|
+
@gitlab_qa_options ||= @options.top.list.map(&:long).flatten
|
56
|
+
end
|
49
57
|
end
|
50
58
|
end
|
51
59
|
end
|
@@ -104,6 +104,10 @@ module Gitlab
|
|
104
104
|
ENV['CI_JOB_NAME']
|
105
105
|
end
|
106
106
|
|
107
|
+
def ci_job_token
|
108
|
+
ENV['CI_JOB_TOKEN']
|
109
|
+
end
|
110
|
+
|
107
111
|
def ci_job_url
|
108
112
|
ENV['CI_JOB_URL']
|
109
113
|
end
|
@@ -207,12 +211,6 @@ module Gitlab
|
|
207
211
|
end
|
208
212
|
end
|
209
213
|
|
210
|
-
def require_gitlab_bot_multi_project_pipeline_polling_token!
|
211
|
-
return unless ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN'].to_s.strip.empty?
|
212
|
-
|
213
|
-
raise ArgumentError, "Please provide GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN"
|
214
|
-
end
|
215
|
-
|
216
214
|
def skip_pull?
|
217
215
|
enabled?(ENV['QA_SKIP_PULL'], default: false)
|
218
216
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Gitlab
|
2
|
+
module QA
|
3
|
+
module Scenario
|
4
|
+
module Test
|
5
|
+
module Instance
|
6
|
+
class Airgapped < Scenario::Template
|
7
|
+
require 'resolv'
|
8
|
+
attr_accessor :commands
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
gitlab_ip = Resolv.getaddress('registry.gitlab.com')
|
12
|
+
@commands = <<~AIRGAP_AND_VERIFY_COMMAND.split(/\n+/)
|
13
|
+
# Should not fail before airgapping due to eg. DNS failure
|
14
|
+
# Ping and wget check
|
15
|
+
apt-get update && apt-get install -y iptables netcat
|
16
|
+
nc -zv -w 10 #{gitlab_ip} 80 && (echo \"Regular connectivity netcat check passed.\" && exit 0) || (echo \"Regular connectivity netcat check failed.\" && exit 1)
|
17
|
+
echo "Checking regular connectivity..." \
|
18
|
+
&& wget --retry-connrefused --waitretry=1 --read-timeout=15 --timeout=10 -t 2 http://registry.gitlab.com > /dev/null 2>&1 \
|
19
|
+
&& (echo "Regular connectivity wget check passed." && exit 0) || (echo "Regular connectivity wget check failed." && exit 1)
|
20
|
+
|
21
|
+
iptables -P INPUT DROP && iptables -P OUTPUT DROP
|
22
|
+
iptables -A INPUT -i lo -j ACCEPT && iptables -A OUTPUT -o lo -j ACCEPT # LOOPBACK
|
23
|
+
iptables -I INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
|
24
|
+
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
25
|
+
|
26
|
+
# Jenkins on port 8080 and 50000
|
27
|
+
iptables -A OUTPUT -p tcp -m tcp --dport 8080 -m state --state NEW,ESTABLISHED -j ACCEPT \
|
28
|
+
&& iptables -A OUTPUT -p tcp -m tcp --dport 50000 -m state --state NEW,ESTABLISHED -j ACCEPT
|
29
|
+
iptables -A OUTPUT -p tcp -m tcp --sport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
|
30
|
+
iptables -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
|
31
|
+
iptables -A OUTPUT -p tcp -m tcp --sport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
|
32
|
+
iptables -A INPUT -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
|
33
|
+
|
34
|
+
# Should now fail to ping and wget, port 80 should be open
|
35
|
+
nc -zv -w 10 #{gitlab_ip} 80 && (echo \"Airgapped network faulty. Connectivity netcat check failed.\" && exit 1) || (echo \"Connectivity netcat check passed.\" && exit 0)
|
36
|
+
nc -zv -w 10 127.0.0.1 22 && (echo "Airgapped connectivity port 22 check passed." && exit 0) || (echo "Airgapped connectivity port 22 check failed." && exit 1)
|
37
|
+
nc -zv -w 10 127.0.0.1 80 && (echo "Airgapped connectivity port 80 check passed." && exit 0) || (echo "Airgapped connectivity port 80 check failed." && exit 1)
|
38
|
+
echo "Checking airgapped connectivity..." \
|
39
|
+
&& wget --retry-connrefused --waitretry=1 --read-timeout=15 --timeout=10 -t 2 http://registry.gitlab.com > /dev/null 2>&1 \
|
40
|
+
&& (echo "Airgapped network faulty. Connectivity wget check failed." && exit 1) || (echo "Airgapped network confirmed. Connectivity wget check passed." && exit 0)
|
41
|
+
AIRGAP_AND_VERIFY_COMMAND
|
42
|
+
end
|
43
|
+
|
44
|
+
def perform(release, *rspec_args)
|
45
|
+
Component::Gitlab.perform do |gitlab|
|
46
|
+
gitlab.release = release
|
47
|
+
gitlab.network = 'test'
|
48
|
+
gitlab.runner_network = 'airgapped'
|
49
|
+
gitlab.exec_commands = @commands
|
50
|
+
rspec_args << "--" unless rspec_args.include?('--')
|
51
|
+
rspec_args << %w[--tag ~orchestrated]
|
52
|
+
gitlab.instance do
|
53
|
+
Component::Specs.perform do |specs|
|
54
|
+
specs.suite = 'Test::Instance::Airgapped'
|
55
|
+
specs.release = gitlab.release
|
56
|
+
specs.network = gitlab.network
|
57
|
+
specs.runner_network = gitlab.runner_network
|
58
|
+
specs.args = [gitlab.address, *rspec_args]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -13,7 +13,11 @@ module Gitlab
|
|
13
13
|
gitlab.name = 'gitlab'
|
14
14
|
gitlab.network = 'test'
|
15
15
|
gitlab.volumes = volumes
|
16
|
-
gitlab.exec_commands = [
|
16
|
+
gitlab.exec_commands = [
|
17
|
+
'gitlab-psql -d template1 -c "CREATE DATABASE praefect_production OWNER gitlab"',
|
18
|
+
'mkdir -p /var/opt/gitlab/git-data/repositories/praefect',
|
19
|
+
'chown -R git:root /var/opt/gitlab/git-data/repositories'
|
20
|
+
]
|
17
21
|
|
18
22
|
gitlab.act do
|
19
23
|
prepare
|
@@ -21,7 +25,7 @@ module Gitlab
|
|
21
25
|
reconfigure
|
22
26
|
process_exec_commands
|
23
27
|
wait
|
24
|
-
teardown
|
28
|
+
teardown!
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
@@ -61,21 +65,25 @@ module Gitlab
|
|
61
65
|
def omnibus_config_with_praefect
|
62
66
|
<<~OMNIBUS
|
63
67
|
gitaly['enable'] = true;
|
64
|
-
gitaly['auth_token'] = '
|
68
|
+
gitaly['auth_token'] = 'secret-token';
|
65
69
|
gitaly['storage'] = [
|
66
70
|
{
|
67
71
|
'name' => 'praefect-gitaly-0',
|
68
|
-
'path' => '/var/opt/gitlab/git-data/repositories'
|
72
|
+
'path' => '/var/opt/gitlab/git-data/repositories/praefect'
|
73
|
+
},
|
74
|
+
{
|
75
|
+
'name' => 'gitaly',
|
76
|
+
'path' => '/var/opt/gitlab/git-data/repositories/gitaly'
|
69
77
|
}
|
70
78
|
];
|
71
79
|
praefect['enable'] = true;
|
72
80
|
praefect['listen_addr'] = '0.0.0.0:2305';
|
73
|
-
praefect['auth_token'] = '
|
81
|
+
praefect['auth_token'] = 'secret-token';
|
74
82
|
praefect['virtual_storages'] = {
|
75
83
|
'default' => {
|
76
84
|
'praefect-gitaly-0' => {
|
77
85
|
'address' => 'unix:/var/opt/gitlab/gitaly/gitaly.socket',
|
78
|
-
'token' => '
|
86
|
+
'token' => 'secret-token',
|
79
87
|
'primary' => true
|
80
88
|
}
|
81
89
|
}
|
@@ -84,10 +92,13 @@ module Gitlab
|
|
84
92
|
praefect['database_user'] = 'gitlab';
|
85
93
|
praefect['database_dbname'] = 'praefect_production';
|
86
94
|
praefect['postgres_queue_enabled'] = true;
|
87
|
-
gitlab_rails['gitaly_token'] = '
|
95
|
+
gitlab_rails['gitaly_token'] = 'secret-token';
|
88
96
|
git_data_dirs({
|
89
97
|
'default' => {
|
90
98
|
'gitaly_address' => 'tcp://localhost:2305'
|
99
|
+
},
|
100
|
+
'gitaly' => {
|
101
|
+
'path' => '/var/opt/gitlab/git-data/repositories/gitaly'
|
91
102
|
}
|
92
103
|
});
|
93
104
|
OMNIBUS
|
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: 5.
|
4
|
+
version: 5.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grzegorz Bizon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06
|
11
|
+
date: 2020-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|
@@ -269,6 +269,7 @@ files:
|
|
269
269
|
- lib/gitlab/qa/scenario/actable.rb
|
270
270
|
- lib/gitlab/qa/scenario/cli_commands.rb
|
271
271
|
- lib/gitlab/qa/scenario/template.rb
|
272
|
+
- lib/gitlab/qa/scenario/test/instance/airgapped.rb
|
272
273
|
- lib/gitlab/qa/scenario/test/instance/any.rb
|
273
274
|
- lib/gitlab/qa/scenario/test/instance/deployment_base.rb
|
274
275
|
- lib/gitlab/qa/scenario/test/instance/geo.rb
|
@@ -329,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
329
330
|
- !ruby/object:Gem::Version
|
330
331
|
version: '0'
|
331
332
|
requirements: []
|
332
|
-
rubygems_version: 3.1.
|
333
|
+
rubygems_version: 3.1.4
|
333
334
|
signing_key:
|
334
335
|
specification_version: 4
|
335
336
|
summary: Integration tests for GitLab
|