gitlab-qa 5.13.6 → 5.16.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 +42 -1
- data/README.md +52 -5
- data/docs/run_qa_against_gdk.md +3 -0
- data/docs/what_tests_can_be_run.md +21 -6
- data/lib/gitlab/qa.rb +4 -1
- data/lib/gitlab/qa/component/base.rb +156 -0
- data/lib/gitlab/qa/component/elasticsearch.rb +5 -32
- data/lib/gitlab/qa/component/gitlab.rb +16 -88
- data/lib/gitlab/qa/component/internet_tunnel.rb +6 -29
- data/lib/gitlab/qa/component/jira.rb +5 -44
- data/lib/gitlab/qa/component/ldap.rb +8 -51
- data/lib/gitlab/qa/component/mail_hog.rb +5 -44
- data/lib/gitlab/qa/component/minio.rb +9 -34
- data/lib/gitlab/qa/component/postgresql.rb +4 -36
- data/lib/gitlab/qa/component/saml.rb +5 -54
- data/lib/gitlab/qa/component/specs.rb +10 -11
- data/lib/gitlab/qa/docker/command.rb +15 -3
- data/lib/gitlab/qa/docker/engine.rb +24 -1
- data/lib/gitlab/qa/docker/shellout.rb +2 -2
- data/lib/gitlab/qa/release.rb +33 -0
- data/lib/gitlab/qa/runner.rb +23 -15
- data/lib/gitlab/qa/runtime/env.rb +32 -1
- data/lib/gitlab/qa/runtime/scenario.rb +36 -0
- data/lib/gitlab/qa/scenario/test/instance/airgapped.rb +68 -0
- data/lib/gitlab/qa/scenario/test/integration/geo.rb +4 -2
- data/lib/gitlab/qa/scenario/test/integration/gitaly_cluster.rb +201 -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 +7 -4
- data/lib/gitlab/qa/scenario/test/integration/gitaly_ha.rb +0 -166
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc79855be61afd8dfaef793cb1a6520bde1f07f6c44a18b9fdd605e26ac947c4
|
4
|
+
data.tar.gz: d326f64befb861020097fd55b9772b54d7014509e87c5c13c71e619c11a21a65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e497734ed2d4d9d58c2dcdf051eb3a4a6ad02adcfc7954ae54ac83ee912b47ff0d6f8478ea6e272a8a93feb14cdda8d55632fb0f92e97379596a12b67ee25f57
|
7
|
+
data.tar.gz: fc927589ca591708a7b61341acf69d48125812642ce9ca87f0183cf11bcf14c55d6bfa8bb04fe1cf3c4685e1d4da0781bab6af15a942c0675ae149fac8b20704
|
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:
|
@@ -830,6 +832,44 @@ ee:praefect-quarantine:
|
|
830
832
|
QA_CAN_TEST_PRAEFECT: "true"
|
831
833
|
QA_RSPEC_TAGS: "--tag quarantine --tag ~orchestrated"
|
832
834
|
|
835
|
+
ce:gitaly-cluster:
|
836
|
+
extends:
|
837
|
+
- .test
|
838
|
+
- .high-capacity
|
839
|
+
- .ce-qa
|
840
|
+
- .rspec-report-opts
|
841
|
+
variables:
|
842
|
+
QA_SCENARIO: "Test::Integration::GitalyCluster"
|
843
|
+
|
844
|
+
ce:gitaly-cluster-quarantine:
|
845
|
+
extends:
|
846
|
+
- .test
|
847
|
+
- .high-capacity
|
848
|
+
- .ce-qa
|
849
|
+
- .quarantine
|
850
|
+
- .rspec-report-opts
|
851
|
+
variables:
|
852
|
+
QA_SCENARIO: "Test::Integration::GitalyCluster"
|
853
|
+
|
854
|
+
ee:gitaly-cluster:
|
855
|
+
extends:
|
856
|
+
- .test
|
857
|
+
- .high-capacity
|
858
|
+
- .ee-qa
|
859
|
+
- .rspec-report-opts
|
860
|
+
variables:
|
861
|
+
QA_SCENARIO: "Test::Integration::GitalyCluster"
|
862
|
+
|
863
|
+
ee:gitaly-cluster-quarantine:
|
864
|
+
extends:
|
865
|
+
- .test
|
866
|
+
- .high-capacity
|
867
|
+
- .ee-qa
|
868
|
+
- .quarantine
|
869
|
+
- .rspec-report-opts
|
870
|
+
variables:
|
871
|
+
QA_SCENARIO: "Test::Integration::GitalyCluster"
|
872
|
+
|
833
873
|
ce:smtp:
|
834
874
|
extends:
|
835
875
|
- .test
|
@@ -891,7 +931,8 @@ ee:jira-quarantine:
|
|
891
931
|
staging:
|
892
932
|
script:
|
893
933
|
- unset EE_LICENSE
|
894
|
-
- exe/gitlab-qa Test::Instance::Staging
|
934
|
+
- 'echo "Running: exe/gitlab-qa Test::Instance::Staging ${RELEASE:=$DEFAULT_RELEASE} -- $QA_TESTS $QA_RSPEC_TAGS"'
|
935
|
+
- exe/gitlab-qa Test::Instance::Staging ${RELEASE:=$DEFAULT_RELEASE} -- $QA_TESTS $QA_RSPEC_TAGS
|
895
936
|
extends:
|
896
937
|
- .test
|
897
938
|
- .high-capacity
|
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,19 +57,19 @@ 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|
|
71
71
|
| `QA_SLOW_CONNECTION_THROUGHPUT_KBPS` | `32` | The maximum throughput (in kbps) of the simulated slow connection. | No|
|
72
|
-
| `QA_SKIP_PULL`
|
72
|
+
| `QA_SKIP_PULL` | `false` | Set to `true` to skip pulling docker images (e.g., to use one you built locally). | No|
|
73
73
|
| `GITHUB_USERNAME` |- | Username for authenticating with GitHub. | No|
|
74
74
|
| `GITHUB_PASSWORD` |- | Password for authenticating with GitHub. | No|
|
75
75
|
| `GITLAB_QA_LOOP_RUNNER_MINUTES` | `1` | Minutes to run and repeat a spec while using the '--loop' option; default value is 1 minute. | 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
@@ -6,6 +6,7 @@ module Gitlab
|
|
6
6
|
|
7
7
|
module Runtime
|
8
8
|
autoload :Env, 'gitlab/qa/runtime/env'
|
9
|
+
autoload :Scenario, 'gitlab/qa/runtime/scenario'
|
9
10
|
autoload :TokenFinder, 'gitlab/qa/runtime/token_finder'
|
10
11
|
end
|
11
12
|
|
@@ -28,6 +29,7 @@ module Gitlab
|
|
28
29
|
autoload :Release, 'gitlab/qa/scenario/test/instance/release'
|
29
30
|
autoload :Geo, 'gitlab/qa/scenario/test/instance/geo'
|
30
31
|
autoload :StagingGeo, 'gitlab/qa/scenario/test/instance/staging_geo'
|
32
|
+
autoload :Airgapped, 'gitlab/qa/scenario/test/instance/airgapped'
|
31
33
|
end
|
32
34
|
|
33
35
|
module Omnibus
|
@@ -52,7 +54,7 @@ module Gitlab
|
|
52
54
|
autoload :Praefect, 'gitlab/qa/scenario/test/integration/praefect'
|
53
55
|
autoload :Elasticsearch, 'gitlab/qa/scenario/test/integration/elasticsearch'
|
54
56
|
autoload :SMTP, 'gitlab/qa/scenario/test/integration/smtp'
|
55
|
-
autoload :
|
57
|
+
autoload :GitalyCluster, 'gitlab/qa/scenario/test/integration/gitaly_cluster'
|
56
58
|
autoload :Jira, 'gitlab/qa/scenario/test/integration/jira'
|
57
59
|
end
|
58
60
|
|
@@ -63,6 +65,7 @@ module Gitlab
|
|
63
65
|
end
|
64
66
|
|
65
67
|
module Component
|
68
|
+
autoload :Base, 'gitlab/qa/component/base'
|
66
69
|
autoload :Gitlab, 'gitlab/qa/component/gitlab'
|
67
70
|
autoload :InternetTunnel, 'gitlab/qa/component/internet_tunnel'
|
68
71
|
autoload :LDAP, 'gitlab/qa/component/ldap'
|
@@ -0,0 +1,156 @@
|
|
1
|
+
module Gitlab
|
2
|
+
module QA
|
3
|
+
module Component
|
4
|
+
class Base
|
5
|
+
include Scenario::Actable
|
6
|
+
|
7
|
+
attr_reader :docker
|
8
|
+
attr_accessor :volumes, :network, :environment, :runner_network
|
9
|
+
attr_writer :name, :exec_commands
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@docker = Docker::Engine.new
|
13
|
+
@environment = {}
|
14
|
+
@volumes = {}
|
15
|
+
@network_aliases = []
|
16
|
+
|
17
|
+
self.exec_commands = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_network_alias(name)
|
21
|
+
@network_aliases.push(name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def name
|
25
|
+
raise NotImplementedError, "#{self.class.name} must specify a default name"
|
26
|
+
end
|
27
|
+
|
28
|
+
def hostname
|
29
|
+
"#{name}.#{network}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def image
|
33
|
+
return self.class.const_get('DOCKER_IMAGE') if self.class.const_defined?('DOCKER_IMAGE')
|
34
|
+
|
35
|
+
raise NotImplementedError, "#{self.class.name} must specify a docker image as DOCKER_IMAGE"
|
36
|
+
end
|
37
|
+
|
38
|
+
def tag
|
39
|
+
return self.class.const_get('DOCKER_IMAGE_TAG') if self.class.const_defined?('DOCKER_IMAGE_TAG')
|
40
|
+
|
41
|
+
raise NotImplementedError, "#{self.class.name} must specify a docker image tag as DOCKER_IMAGE_TAG"
|
42
|
+
end
|
43
|
+
|
44
|
+
def instance
|
45
|
+
instance_no_teardown do
|
46
|
+
yield self if block_given?
|
47
|
+
end
|
48
|
+
ensure
|
49
|
+
teardown
|
50
|
+
end
|
51
|
+
|
52
|
+
alias_method :launch_and_teardown_instance, :instance
|
53
|
+
|
54
|
+
def instance_no_teardown
|
55
|
+
prepare
|
56
|
+
start
|
57
|
+
reconfigure
|
58
|
+
wait_until_ready
|
59
|
+
process_exec_commands
|
60
|
+
|
61
|
+
yield self if block_given?
|
62
|
+
end
|
63
|
+
|
64
|
+
def prepare
|
65
|
+
prepare_docker_image
|
66
|
+
prepare_network
|
67
|
+
end
|
68
|
+
|
69
|
+
def prepare_docker_image
|
70
|
+
pull
|
71
|
+
end
|
72
|
+
|
73
|
+
def prepare_network
|
74
|
+
if runner_network && !docker.network_exists?(runner_network)
|
75
|
+
docker.network_create("--driver=bridge --internal #{runner_network}")
|
76
|
+
end
|
77
|
+
|
78
|
+
return if docker.network_exists?(network)
|
79
|
+
|
80
|
+
docker.network_create(network)
|
81
|
+
end
|
82
|
+
|
83
|
+
def start # rubocop:disable Metrics/AbcSize
|
84
|
+
docker.run(image, tag) do |command|
|
85
|
+
command << "-d"
|
86
|
+
command << "--name #{name}"
|
87
|
+
command << "--net #{network}"
|
88
|
+
command << "--hostname #{hostname}"
|
89
|
+
|
90
|
+
@volumes.to_h.each do |to, from|
|
91
|
+
command.volume(to, from, 'Z')
|
92
|
+
end
|
93
|
+
|
94
|
+
command.volume(File.join(Runtime::Env.host_artifacts_dir, name, 'logs'), '/var/log/gitlab', 'Z')
|
95
|
+
|
96
|
+
@environment.to_h.each do |key, value|
|
97
|
+
command.env(key, value)
|
98
|
+
end
|
99
|
+
|
100
|
+
@network_aliases.to_a.each do |network_alias|
|
101
|
+
command << "--network-alias #{network_alias}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def restart
|
107
|
+
assert_name!
|
108
|
+
|
109
|
+
docker.restart(name)
|
110
|
+
end
|
111
|
+
|
112
|
+
def teardown
|
113
|
+
unless teardown?
|
114
|
+
puts "The orchestrated docker containers have not been removed."
|
115
|
+
docker.ps
|
116
|
+
|
117
|
+
return
|
118
|
+
end
|
119
|
+
|
120
|
+
teardown!
|
121
|
+
end
|
122
|
+
|
123
|
+
def teardown!
|
124
|
+
assert_name!
|
125
|
+
|
126
|
+
return unless docker.running?(name)
|
127
|
+
|
128
|
+
docker.stop(name)
|
129
|
+
docker.remove(name)
|
130
|
+
end
|
131
|
+
|
132
|
+
def pull
|
133
|
+
return if Runtime::Env.skip_pull?
|
134
|
+
|
135
|
+
docker.pull(image, tag)
|
136
|
+
end
|
137
|
+
|
138
|
+
def process_exec_commands
|
139
|
+
exec_commands.each { |command| docker.exec(name, command) }
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
|
144
|
+
attr_reader :exec_commands, :wait_until_ready, :reconfigure
|
145
|
+
|
146
|
+
def assert_name!
|
147
|
+
raise 'Invalid instance name!' unless name
|
148
|
+
end
|
149
|
+
|
150
|
+
def teardown?
|
151
|
+
!Runtime::Scenario.attributes.include?(:teardown) || Runtime::Scenario.teardown
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -1,41 +1,19 @@
|
|
1
1
|
module Gitlab
|
2
2
|
module QA
|
3
3
|
module Component
|
4
|
-
class Elasticsearch
|
5
|
-
|
6
|
-
|
7
|
-
ELASTIC_IMAGE = 'docker.elastic.co/elasticsearch/elasticsearch'.freeze
|
8
|
-
|
9
|
-
attr_reader :docker
|
10
|
-
attr_accessor :environment, :network
|
11
|
-
attr_writer :name
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@docker = Docker::Engine.new
|
15
|
-
@environment = {}
|
16
|
-
end
|
4
|
+
class Elasticsearch < Base
|
5
|
+
DOCKER_IMAGE = 'docker.elastic.co/elasticsearch/elasticsearch'.freeze
|
17
6
|
|
18
7
|
def name
|
19
8
|
@name ||= "elastic68"
|
20
9
|
end
|
21
10
|
|
22
|
-
def
|
23
|
-
|
24
|
-
start
|
25
|
-
yield self
|
26
|
-
ensure
|
27
|
-
teardown
|
28
|
-
end
|
29
|
-
|
30
|
-
def prepare
|
31
|
-
@docker.pull(ELASTIC_IMAGE, Runtime::Env.elastic_version)
|
32
|
-
return if @docker.network_exists?(network)
|
33
|
-
|
34
|
-
@docker.network_create(network)
|
11
|
+
def tag
|
12
|
+
Runtime::Env.elastic_version
|
35
13
|
end
|
36
14
|
|
37
15
|
def start
|
38
|
-
@docker.run(
|
16
|
+
@docker.run(image, tag) do |command|
|
39
17
|
command << "-d"
|
40
18
|
command << "--name #{name}"
|
41
19
|
command << "--net #{network}"
|
@@ -45,11 +23,6 @@ module Gitlab
|
|
45
23
|
command.env("discovery.type", "single-node")
|
46
24
|
end
|
47
25
|
end
|
48
|
-
|
49
|
-
def teardown
|
50
|
-
@docker.stop(name)
|
51
|
-
@docker.remove(name)
|
52
|
-
end
|
53
26
|
end
|
54
27
|
end
|
55
28
|
end
|
@@ -7,13 +7,12 @@ require 'openssl'
|
|
7
7
|
module Gitlab
|
8
8
|
module QA
|
9
9
|
module Component
|
10
|
-
class Gitlab
|
10
|
+
class Gitlab < Base
|
11
11
|
extend Forwardable
|
12
|
-
include Scenario::Actable
|
13
12
|
|
14
|
-
attr_reader :release
|
15
|
-
attr_accessor :
|
16
|
-
attr_writer :name, :relative_path
|
13
|
+
attr_reader :release
|
14
|
+
attr_accessor :tls, :disable_animations, :skip_availability_check, :runner_network
|
15
|
+
attr_writer :name, :relative_path
|
17
16
|
|
18
17
|
def_delegators :release, :tag, :image, :edition
|
19
18
|
|
@@ -21,17 +20,14 @@ module Gitlab
|
|
21
20
|
SSL_PATH = '/etc/gitlab/ssl'.freeze
|
22
21
|
|
23
22
|
def initialize
|
24
|
-
|
25
|
-
|
26
|
-
@volumes = {}
|
27
|
-
@network_aliases = []
|
23
|
+
super
|
24
|
+
|
28
25
|
@disable_animations = true
|
29
|
-
@
|
26
|
+
@skip_availability_check = false
|
30
27
|
|
31
28
|
@volumes[CERTIFICATES_PATH] = SSL_PATH
|
32
29
|
|
33
30
|
self.release = 'CE'
|
34
|
-
self.exec_commands = []
|
35
31
|
end
|
36
32
|
|
37
33
|
def omnibus_config=(config)
|
@@ -48,10 +44,6 @@ module Gitlab
|
|
48
44
|
@environment['ELASTIC_URL'] = url
|
49
45
|
end
|
50
46
|
|
51
|
-
def add_network_alias(name)
|
52
|
-
@network_aliases.push(name)
|
53
|
-
end
|
54
|
-
|
55
47
|
def release=(release)
|
56
48
|
@release = QA::Release.new(release)
|
57
49
|
end
|
@@ -72,10 +64,6 @@ module Gitlab
|
|
72
64
|
tls ? '443' : '80'
|
73
65
|
end
|
74
66
|
|
75
|
-
def hostname
|
76
|
-
"#{name}.#{network}"
|
77
|
-
end
|
78
|
-
|
79
67
|
def relative_path
|
80
68
|
@relative_path ||= ''
|
81
69
|
end
|
@@ -84,24 +72,16 @@ module Gitlab
|
|
84
72
|
Runtime::Env.accept_insecure_certs = 'true'
|
85
73
|
end
|
86
74
|
|
87
|
-
def
|
88
|
-
|
89
|
-
start
|
90
|
-
reconfigure
|
91
|
-
wait unless @skip_check
|
92
|
-
process_exec_commands
|
75
|
+
def prepare
|
76
|
+
prepare_gitlab_omnibus_config
|
93
77
|
|
94
|
-
|
95
|
-
ensure
|
96
|
-
teardown
|
78
|
+
super
|
97
79
|
end
|
98
80
|
|
99
|
-
|
81
|
+
def pull
|
82
|
+
docker.login(**release.login_params) if release.login_params
|
100
83
|
|
101
|
-
|
102
|
-
prepare_gitlab_omnibus_config
|
103
|
-
prepare_docker_image
|
104
|
-
prepare_network
|
84
|
+
super
|
105
85
|
end
|
106
86
|
|
107
87
|
def prepare_gitlab_omnibus_config
|
@@ -109,18 +89,6 @@ module Gitlab
|
|
109
89
|
set_formless_login_token
|
110
90
|
end
|
111
91
|
|
112
|
-
def prepare_docker_image
|
113
|
-
return if Runtime::Env.skip_pull?
|
114
|
-
|
115
|
-
@docker.pull(image, tag)
|
116
|
-
end
|
117
|
-
|
118
|
-
def prepare_network
|
119
|
-
return if @docker.network_exists?(network)
|
120
|
-
|
121
|
-
@docker.network_create(network)
|
122
|
-
end
|
123
|
-
|
124
92
|
def setup_disable_animations
|
125
93
|
@environment['GITLAB_OMNIBUS_CONFIG'] = "gitlab_rails['gitlab_disable_animations'] = true; #{@environment['GITLAB_OMNIBUS_CONFIG'] || ''}"
|
126
94
|
end
|
@@ -128,28 +96,6 @@ module Gitlab
|
|
128
96
|
def start # rubocop:disable Metrics/AbcSize
|
129
97
|
ensure_configured!
|
130
98
|
|
131
|
-
if release.dev_gitlab_org?
|
132
|
-
Docker::Command.execute(
|
133
|
-
[
|
134
|
-
'login',
|
135
|
-
'--username gitlab-qa-bot',
|
136
|
-
%(--password "#{Runtime::Env.dev_access_token_variable}"),
|
137
|
-
QA::Release::DEV_REGISTRY
|
138
|
-
]
|
139
|
-
)
|
140
|
-
elsif release.omnibus_mirror?
|
141
|
-
bot_token = ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN']
|
142
|
-
|
143
|
-
Docker::Command.execute(
|
144
|
-
[
|
145
|
-
'login',
|
146
|
-
'--username gitlab-bot',
|
147
|
-
%(--password "#{bot_token}"),
|
148
|
-
QA::Release::COM_REGISTRY
|
149
|
-
]
|
150
|
-
)
|
151
|
-
end
|
152
|
-
|
153
99
|
docker.run(image, tag) do |command|
|
154
100
|
command << "-d -p #{port}"
|
155
101
|
command << "--name #{name}"
|
@@ -170,6 +116,7 @@ module Gitlab
|
|
170
116
|
command << "--network-alias #{network_alias}"
|
171
117
|
end
|
172
118
|
end
|
119
|
+
Docker::Command.execute("network connect --alias #{name}.#{network} --alias #{name}.#{runner_network} #{runner_network} #{name}") if runner_network
|
173
120
|
end
|
174
121
|
|
175
122
|
def reconfigure
|
@@ -181,18 +128,9 @@ module Gitlab
|
|
181
128
|
end
|
182
129
|
end
|
183
130
|
|
184
|
-
def restart
|
185
|
-
@docker.restart(name)
|
186
|
-
end
|
187
|
-
|
188
|
-
def teardown
|
189
|
-
raise 'Invalid instance name!' unless name
|
190
|
-
|
191
|
-
@docker.stop(name)
|
192
|
-
@docker.remove(name)
|
193
|
-
end
|
194
|
-
|
195
131
|
def wait
|
132
|
+
return if skip_availability_check
|
133
|
+
|
196
134
|
if Availability.new(name, relative_path: relative_path, scheme: scheme, protocol_port: port.to_i).check(180)
|
197
135
|
sleep 12 # TODO, handle that better
|
198
136
|
puts ' -> GitLab is available.'
|
@@ -201,10 +139,6 @@ module Gitlab
|
|
201
139
|
end
|
202
140
|
end
|
203
141
|
|
204
|
-
def pull
|
205
|
-
@docker.pull(@release.image, @release.tag)
|
206
|
-
end
|
207
|
-
|
208
142
|
def sha_version
|
209
143
|
json = @docker.read_file(
|
210
144
|
@release.image, @release.tag,
|
@@ -215,14 +149,8 @@ module Gitlab
|
|
215
149
|
manifest['software']['gitlab-rails']['locked_version']
|
216
150
|
end
|
217
151
|
|
218
|
-
def process_exec_commands
|
219
|
-
exec_commands.each { |command| @docker.exec(name, command) }
|
220
|
-
end
|
221
|
-
|
222
152
|
private
|
223
153
|
|
224
|
-
attr_reader :exec_commands
|
225
|
-
|
226
154
|
def ensure_configured!
|
227
155
|
raise 'Please configure an instance first!' unless [name, release, network].all?
|
228
156
|
end
|