gitlab-qa 5.13.6 → 5.13.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 742350ecaafcf21ca9ff0fc50547cbb6cd28b2cf7a3fc090f5cb6ab542da3154
4
- data.tar.gz: e65a23e2620961c5751eca131cf0dfa4b639f2915488b888975e6a0313c8baee
3
+ metadata.gz: 80567a3f14ce823c574bf448dd57339aa9ac95d39514b2c18ec4f8d9094c5e95
4
+ data.tar.gz: 4aa694b95e7bc667a58d63d7ac4c2606dbbd3d9a5819cd49e160dfae60b919cc
5
5
  SHA512:
6
- metadata.gz: e42ac20b6a9dd4881c50d5018956241543395dae6c2aac148c1db87e77daa0ac677950a876ffa730e9d8f991c3850640775213ca6a0c8ebefa4a45dd2ab811c2
7
- data.tar.gz: b7f993786ae4ac8fdc7b15d4d936cad11066e2f92731b30f696e8615a9454657f40d67e3cccb9074b6464755ab2d37a2e74569e92b66476328ee8215ea4543e3
6
+ metadata.gz: 1a9f28e68a1717e93f7df4dda6de613185b3175417092517d56338d35af67679eed4a8d074e6ee5b6efd1f9d425b761aec3d9a8803d9d993341a9a28b1abde4c
7
+ data.tar.gz: da4ca897e44bd8c398c42f431370b73bb482fdb032b059053b759eb0c97646500057961b8a378a789b39cf5ab093e00a4a8577c36fbb6ef9353ce9116b24f98a
@@ -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` |- | 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` |- | Set to `false` to skip tests that require admin access. | No|
67
- | `QA_CAN_TEST_PRAEFECT` |- | Set to `false` to skip tests that require Praefect to be running. | No|
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` |- | Set to `true` to skip pulling docker images (e.g., to use one you built locally). | No|
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|
@@ -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
 
@@ -63,6 +64,7 @@ module Gitlab
63
64
  end
64
65
 
65
66
  module Component
67
+ autoload :Base, 'gitlab/qa/component/base'
66
68
  autoload :Gitlab, 'gitlab/qa/component/gitlab'
67
69
  autoload :InternetTunnel, 'gitlab/qa/component/internet_tunnel'
68
70
  autoload :LDAP, 'gitlab/qa/component/ldap'
@@ -0,0 +1,131 @@
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
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
+ prepare
46
+ start
47
+ reconfigure
48
+ wait_until_ready
49
+ process_exec_commands
50
+
51
+ yield self if block_given?
52
+ ensure
53
+ teardown
54
+ end
55
+
56
+ alias_method :launch_and_teardown_instance, :instance
57
+
58
+ def prepare
59
+ prepare_docker_image
60
+ prepare_network
61
+ end
62
+
63
+ def prepare_docker_image
64
+ return if Runtime::Env.skip_pull?
65
+
66
+ pull
67
+ end
68
+
69
+ def prepare_network
70
+ return if docker.network_exists?(network)
71
+
72
+ docker.network_create(network)
73
+ end
74
+
75
+ def start # rubocop:disable Metrics/AbcSize
76
+ docker.run(image, tag) do |command|
77
+ command << "-d"
78
+ command << "--name #{name}"
79
+ command << "--net #{network}"
80
+ command << "--hostname #{hostname}"
81
+
82
+ @volumes.to_h.each do |to, from|
83
+ command.volume(to, from, 'Z')
84
+ end
85
+
86
+ command.volume(File.join(Runtime::Env.host_artifacts_dir, name, 'logs'), '/var/log/gitlab', 'Z')
87
+
88
+ @environment.to_h.each do |key, value|
89
+ command.env(key, value)
90
+ end
91
+
92
+ @network_aliases.to_a.each do |network_alias|
93
+ command << "--network-alias #{network_alias}"
94
+ end
95
+ end
96
+ end
97
+
98
+ def restart
99
+ assert_name!
100
+
101
+ docker.restart(name)
102
+ end
103
+
104
+ def teardown
105
+ assert_name!
106
+
107
+ return unless docker.running?(name)
108
+
109
+ docker.stop(name)
110
+ docker.remove(name)
111
+ end
112
+
113
+ def pull
114
+ docker.pull(image, tag)
115
+ end
116
+
117
+ def process_exec_commands
118
+ exec_commands.each { |command| docker.exec(name, command) }
119
+ end
120
+
121
+ private
122
+
123
+ attr_reader :exec_commands, :wait_until_ready, :reconfigure
124
+
125
+ def assert_name!
126
+ raise 'Invalid instance name!' unless name
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
@@ -1,41 +1,19 @@
1
1
  module Gitlab
2
2
  module QA
3
3
  module Component
4
- class Elasticsearch
5
- include Scenario::Actable
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 instance
23
- prepare
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(ELASTIC_IMAGE, Runtime::Env.elastic_version) do |command|
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, :docker
15
- attr_accessor :volumes, :network, :environment, :tls, :disable_animations
16
- attr_writer :name, :relative_path, :exec_commands, :skip_check
13
+ attr_reader :release
14
+ attr_accessor :tls, :disable_animations, :skip_availability_check
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
- @docker = Docker::Engine.new
25
- @environment = {}
26
- @volumes = {}
27
- @network_aliases = []
23
+ super
24
+
28
25
  @disable_animations = true
29
- @skip_check = false
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 instance
88
- prepare
89
- start
90
- reconfigure
91
- wait unless @skip_check
92
- process_exec_commands
75
+ def prepare
76
+ prepare_gitlab_omnibus_config
93
77
 
94
- yield self if block_given?
95
- ensure
96
- teardown
78
+ super
97
79
  end
98
80
 
99
- alias_method :launch_and_teardown_instance, :instance
81
+ def pull
82
+ docker.login(**release.login_params) if release.login_params
100
83
 
101
- def prepare
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}"
@@ -181,18 +127,9 @@ module Gitlab
181
127
  end
182
128
  end
183
129
 
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
130
  def wait
131
+ return if skip_availability_check
132
+
196
133
  if Availability.new(name, relative_path: relative_path, scheme: scheme, protocol_port: port.to_i).check(180)
197
134
  sleep 12 # TODO, handle that better
198
135
  puts ' -> GitLab is available.'
@@ -201,10 +138,6 @@ module Gitlab
201
138
  end
202
139
  end
203
140
 
204
- def pull
205
- @docker.pull(@release.image, @release.tag)
206
- end
207
-
208
141
  def sha_version
209
142
  json = @docker.read_file(
210
143
  @release.image, @release.tag,
@@ -215,14 +148,8 @@ module Gitlab
215
148
  manifest['software']['gitlab-rails']['locked_version']
216
149
  end
217
150
 
218
- def process_exec_commands
219
- exec_commands.each { |command| @docker.exec(name, command) }
220
- end
221
-
222
151
  private
223
152
 
224
- attr_reader :exec_commands
225
-
226
153
  def ensure_configured!
227
154
  raise 'Please configure an instance first!' unless [name, release, network].all?
228
155
  end
@@ -3,18 +3,14 @@ require 'tempfile'
3
3
  module Gitlab
4
4
  module QA
5
5
  module Component
6
- class InternetTunnel
7
- include Scenario::Actable
8
-
6
+ class InternetTunnel < Base
9
7
  DOCKER_IMAGE = 'gitlab/ssh-tunnel'.freeze
10
8
  DOCKER_IMAGE_TAG = '1.0.0'.freeze
11
9
 
12
- attr_writer :gitlab_hostname, :name
13
- attr_accessor :network
10
+ attr_writer :gitlab_hostname
14
11
 
15
12
  def initialize
16
- @docker = Docker::Engine.new
17
- @volumes = {}
13
+ super
18
14
 
19
15
  key_dir = ENV['CI_PROJECT_DIR'] || Dir.tmpdir
20
16
  @ssh_key = Tempfile.new('tunnel-ssh-private-key', key_dir)
@@ -27,14 +23,9 @@ module Gitlab
27
23
  end
28
24
 
29
25
  def instance
30
- raise ArgumentError, 'Please provide a block!' unless block_given?
31
-
32
- prepare
33
- start
26
+ raise 'Please provide a block!' unless block_given?
34
27
 
35
- yield self
36
- ensure
37
- teardown
28
+ super
38
29
  end
39
30
 
40
31
  def url
@@ -47,14 +38,6 @@ module Gitlab
47
38
  @name ||= "ssh-tunnel-#{SecureRandom.hex(4)}"
48
39
  end
49
40
 
50
- def prepare
51
- @docker.pull(DOCKER_IMAGE, DOCKER_IMAGE_TAG)
52
-
53
- return if @docker.network_exists?(network)
54
-
55
- @docker.network_create(network)
56
- end
57
-
58
41
  def tunnel_server_hostname
59
42
  ENV.fetch("TUNNEL_SERVER_HOSTNAME")
60
43
  end
@@ -77,15 +60,9 @@ module Gitlab
77
60
  end
78
61
  end
79
62
 
80
- def restart
81
- @docker.restart(name)
82
- end
83
-
84
63
  def teardown
85
- raise 'Invalid instance name!' unless name
64
+ super
86
65
 
87
- @docker.stop(name)
88
- @docker.remove(name)
89
66
  @ssh_key.unlink
90
67
  end
91
68
  end
@@ -1,50 +1,22 @@
1
1
  module Gitlab
2
2
  module QA
3
3
  module Component
4
- class Jira
5
- include Scenario::Actable
6
-
7
- JIRA_IMAGE = 'registry.gitlab.com/gitlab-org/gitlab-qa/jira-gitlab'.freeze
8
- JIRA_IMAGE_TAG = '8.8-project-and-issue'.freeze
9
-
10
- attr_reader :docker
11
- attr_accessor :environment, :network
12
- attr_writer :name
13
-
14
- def initialize
15
- @docker = Docker::Engine.new
16
- @environment = {}
17
- end
4
+ class Jira < Base
5
+ DOCKER_IMAGE = 'registry.gitlab.com/gitlab-org/gitlab-qa/jira-gitlab'.freeze
6
+ DOCKER_IMAGE_TAG = '8.8-project-and-issue'.freeze
18
7
 
19
8
  def name
20
9
  @name ||= "jira"
21
10
  end
22
11
 
23
- def hostname
24
- "#{name}.#{network}"
25
- end
26
-
27
12
  def instance
28
13
  raise 'Please provide a block!' unless block_given?
29
14
 
30
- prepare
31
- start
32
-
33
- yield self
34
- ensure
35
- teardown
36
- end
37
-
38
- def prepare
39
- @docker.pull(JIRA_IMAGE, JIRA_IMAGE_TAG)
40
-
41
- return if @docker.network_exists?(network)
42
-
43
- @docker.network_create(network)
15
+ super
44
16
  end
45
17
 
46
18
  def start
47
- docker.run(JIRA_IMAGE, JIRA_IMAGE_TAG) do |command|
19
+ docker.run(image, tag) do |command|
48
20
  command << '-d '
49
21
  command << "--name #{name}"
50
22
  command << "--net #{network}"
@@ -53,17 +25,6 @@ module Gitlab
53
25
  end
54
26
  end
55
27
 
56
- def restart
57
- @docker.restart(name)
58
- end
59
-
60
- def teardown
61
- raise 'Invalid instance name!' unless name
62
-
63
- @docker.stop(name)
64
- @docker.remove(name)
65
- end
66
-
67
28
  def set_jira_hostname
68
29
  ::Gitlab::QA::Runtime::Env.jira_hostname = hostname
69
30
  end
@@ -15,25 +15,16 @@ require 'securerandom'
15
15
  module Gitlab
16
16
  module QA
17
17
  module Component
18
- class LDAP
19
- include Scenario::Actable
20
-
21
- LDAP_IMAGE = 'osixia/openldap'.freeze
22
- LDAP_IMAGE_TAG = 'latest'.freeze
18
+ class LDAP < Base
19
+ DOCKER_IMAGE = 'osixia/openldap'.freeze
20
+ DOCKER_IMAGE_TAG = 'latest'.freeze
23
21
  LDAP_USER = 'tanuki'.freeze
24
22
  LDAP_PASSWORD = 'password'.freeze
25
23
  BOOTSTRAP_LDIF = '/container/service/slapd/assets/config/bootstrap/ldif/custom'.freeze
26
24
  FIXTURE_PATH = File.expand_path('../../../../fixtures/ldap'.freeze, __dir__)
27
25
 
28
- attr_reader :docker
29
- attr_accessor :volumes, :network, :environment
30
- attr_writer :name
31
-
32
26
  def initialize
33
- @docker = Docker::Engine.new
34
- @environment = {}
35
- @volumes = {}
36
- @network_aliases = []
27
+ super
37
28
 
38
29
  @volumes[FIXTURE_PATH] = BOOTSTRAP_LDIF
39
30
  end
@@ -58,41 +49,21 @@ module Gitlab
58
49
  LDAP_PASSWORD
59
50
  end
60
51
 
61
- def add_network_alias(name)
62
- @network_aliases.push(name)
63
- end
64
-
65
52
  def name
66
53
  @name ||= "openldap-#{SecureRandom.hex(4)}"
67
54
  end
68
55
 
69
- def hostname
70
- "#{name}.#{network}"
71
- end
72
-
73
56
  def instance
74
57
  raise 'Please provide a block!' unless block_given?
75
58
 
76
- prepare
77
- start
78
-
79
- yield self
80
- ensure
81
- teardown
82
- end
83
-
84
- def prepare
85
- @docker.pull(LDAP_IMAGE, LDAP_IMAGE_TAG)
86
-
87
- return if @docker.network_exists?(network)
88
-
89
- @docker.network_create(network)
59
+ super
90
60
  end
91
61
 
62
+ # rubocop:disable Metrics/AbcSize
92
63
  def start
93
64
  # copy-service needed for bootstraping LDAP user:
94
65
  # https://github.com/osixia/docker-openldap#seed-ldap-database-with-ldif
95
- docker.run(LDAP_IMAGE, LDAP_IMAGE_TAG, '--copy-service') do |command|
66
+ docker.run(image, tag, '--copy-service') do |command|
96
67
  command << '-d '
97
68
  command << "--name #{name}"
98
69
  command << "--net #{network}"
@@ -111,21 +82,7 @@ module Gitlab
111
82
  end
112
83
  end
113
84
  end
114
-
115
- def restart
116
- @docker.restart(name)
117
- end
118
-
119
- def teardown
120
- raise 'Invalid instance name!' unless name
121
-
122
- @docker.stop(name)
123
- @docker.remove(name)
124
- end
125
-
126
- def pull
127
- @docker.pull(LDAP_IMAGE, LDAP_IMAGE_TAG)
128
- end
85
+ # rubocop:enable Metrics/AbcSize
129
86
 
130
87
  def set_gitlab_credentials
131
88
  ::Gitlab::QA::Runtime::Env.ldap_username = username
@@ -4,50 +4,22 @@
4
4
  module Gitlab
5
5
  module QA
6
6
  module Component
7
- class MailHog
8
- include Scenario::Actable
9
-
10
- MAILHOG_IMAGE = 'mailhog/mailhog'.freeze
11
- MAILHOG_IMAGE_TAG = 'v1.0.0'.freeze
12
-
13
- attr_reader :docker
14
- attr_accessor :environment, :network
15
- attr_writer :name
16
-
17
- def initialize
18
- @docker = Docker::Engine.new
19
- @environment = {}
20
- end
7
+ class MailHog < Base
8
+ DOCKER_IMAGE = 'mailhog/mailhog'.freeze
9
+ DOCKER_IMAGE_TAG = 'v1.0.0'.freeze
21
10
 
22
11
  def name
23
12
  @name ||= "mailhog"
24
13
  end
25
14
 
26
- def hostname
27
- "#{name}.#{network}"
28
- end
29
-
30
15
  def instance
31
16
  raise 'Please provide a block!' unless block_given?
32
17
 
33
- prepare
34
- start
35
-
36
- yield self
37
- ensure
38
- teardown
39
- end
40
-
41
- def prepare
42
- @docker.pull(MAILHOG_IMAGE, MAILHOG_IMAGE_TAG)
43
-
44
- return if @docker.network_exists?(network)
45
-
46
- @docker.network_create(network)
18
+ super
47
19
  end
48
20
 
49
21
  def start
50
- docker.run(MAILHOG_IMAGE, MAILHOG_IMAGE_TAG) do |command|
22
+ docker.run(image, tag) do |command|
51
23
  command << '-d '
52
24
  command << "--name #{name}"
53
25
  command << "--net #{network}"
@@ -57,17 +29,6 @@ module Gitlab
57
29
  end
58
30
  end
59
31
 
60
- def restart
61
- @docker.restart(name)
62
- end
63
-
64
- def teardown
65
- raise 'Invalid instance name!' unless name
66
-
67
- @docker.stop(name)
68
- @docker.remove(name)
69
- end
70
-
71
32
  def set_mailhog_hostname
72
33
  ::Gitlab::QA::Runtime::Env.mailhog_hostname = hostname
73
34
  end
@@ -6,23 +6,18 @@ require 'fileutils'
6
6
  module Gitlab
7
7
  module QA
8
8
  module Component
9
- class Minio
10
- include Scenario::Actable
11
-
12
- MINIO_IMAGE = 'minio/minio'.freeze
13
- MINIO_IMAGE_TAG = 'latest'.freeze
9
+ class Minio < Base
10
+ DOCKER_IMAGE = 'minio/minio'.freeze
11
+ DOCKER_IMAGE_TAG = 'latest'.freeze
14
12
  # These are secrets used in a local Minio container, they're not used for any online S3 server.
15
13
  AWS_ACCESS_KEY = 'AKIAIOSFODNN7EXAMPLE'.freeze
16
14
  AWS_SECRET_KEY = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'.freeze
17
15
  DATA_DIR = '/data'.freeze
18
16
  DEFAULT_PORT = 9000
19
17
 
20
- attr_reader :docker
21
- attr_accessor :volumes, :network, :environment
22
- attr_writer :name
23
-
24
18
  def initialize
25
- @docker = Docker::Engine.new
19
+ super
20
+
26
21
  @environment = { MINIO_ACCESS_KEY: AWS_ACCESS_KEY, MINIO_SECRET_KEY: AWS_SECRET_KEY }
27
22
  @volumes = { host_data_dir => DATA_DIR }
28
23
  @buckets = []
@@ -31,12 +26,7 @@ module Gitlab
31
26
  def instance
32
27
  raise 'Please provide a block!' unless block_given?
33
28
 
34
- prepare
35
- start
36
-
37
- yield self
38
- ensure
39
- teardown
29
+ super
40
30
  end
41
31
 
42
32
  def add_bucket(name)
@@ -70,16 +60,12 @@ module Gitlab
70
60
  @name ||= "minio-#{SecureRandom.hex(4)}"
71
61
  end
72
62
 
73
- def hostname
74
- "#{name}.#{network}"
75
- end
76
-
77
63
  def port
78
64
  DEFAULT_PORT
79
65
  end
80
66
 
81
67
  def prepare
82
- @docker.pull(MINIO_IMAGE, MINIO_IMAGE_TAG)
68
+ super
83
69
 
84
70
  FileUtils.mkdir_p(host_data_dir)
85
71
 
@@ -87,16 +73,12 @@ module Gitlab
87
73
  puts "Creating Minio bucket: #{bucket}"
88
74
  FileUtils.mkdir_p(File.join(host_data_dir, bucket))
89
75
  end
90
-
91
- return if @docker.network_exists?(network)
92
-
93
- @docker.network_create(network)
94
76
  end
95
77
 
96
- def start
78
+ def start # rubocop:disable Metrics/AbcSize
97
79
  # --compat needed until https://gitlab.com/gitlab-org/gitlab-workhorse/issues/210
98
80
  # is resolved
99
- docker.run(MINIO_IMAGE, MINIO_IMAGE_TAG, "server", "--compat", DATA_DIR) do |command|
81
+ docker.run(image, tag, "server", "--compat", DATA_DIR) do |command|
100
82
  command << '-d '
101
83
  command << "--name #{name}"
102
84
  command << "--net #{network}"
@@ -115,13 +97,6 @@ module Gitlab
115
97
  end
116
98
  end
117
99
  end
118
-
119
- def teardown
120
- raise 'Invalid instance name!' unless name
121
-
122
- @docker.stop(name)
123
- @docker.remove(name)
124
- end
125
100
  end
126
101
  end
127
102
  end
@@ -1,43 +1,16 @@
1
1
  module Gitlab
2
2
  module QA
3
3
  module Component
4
- class PostgreSQL
5
- include Scenario::Actable
6
-
7
- POSTGRES_IMAGE = 'postgres'.freeze
8
- POSTGRES_IMAGE_TAG = '11'.freeze
9
-
10
- attr_reader :docker
11
- attr_accessor :environment, :network
12
- attr_writer :name
13
-
14
- def initialize
15
- @docker = Docker::Engine.new
16
- @environment = {}
17
- end
4
+ class PostgreSQL < Base
5
+ DOCKER_IMAGE = 'postgres'.freeze
6
+ DOCKER_IMAGE_TAG = '11'.freeze
18
7
 
19
8
  def name
20
9
  @name ||= "postgres"
21
10
  end
22
11
 
23
- def instance
24
- prepare
25
- start
26
- wait_until_ready
27
- yield self
28
- ensure
29
- teardown
30
- end
31
-
32
- def prepare
33
- @docker.pull(POSTGRES_IMAGE, POSTGRES_IMAGE_TAG)
34
- return if @docker.network_exists?(network)
35
-
36
- @docker.network_create(network)
37
- end
38
-
39
12
  def start
40
- @docker.run(POSTGRES_IMAGE, POSTGRES_IMAGE_TAG) do |command|
13
+ @docker.run(image, tag) do |command|
41
14
  command << "-d"
42
15
  command << "--name #{name}"
43
16
  command << "--net #{network}"
@@ -46,11 +19,6 @@ module Gitlab
46
19
  end
47
20
  end
48
21
 
49
- def teardown
50
- @docker.stop(name)
51
- @docker.remove(name)
52
- end
53
-
54
22
  def run_psql(command)
55
23
  @docker.exec(name, %(psql -U postgres #{command}))
56
24
  end
@@ -6,22 +6,9 @@ require 'securerandom'
6
6
  module Gitlab
7
7
  module QA
8
8
  module Component
9
- class SAML
10
- include Scenario::Actable
11
-
12
- SAML_IMAGE = 'jamedjo/test-saml-idp'.freeze
13
- SAML_IMAGE_TAG = 'latest'.freeze
14
-
15
- attr_reader :docker
16
- attr_accessor :volumes, :network, :environment
17
- attr_writer :name
18
-
19
- def initialize
20
- @docker = Docker::Engine.new
21
- @environment = {}
22
- @volumes = {}
23
- @network_aliases = []
24
- end
9
+ class SAML < Base
10
+ DOCKER_IMAGE = 'jamedjo/test-saml-idp'.freeze
11
+ DOCKER_IMAGE_TAG = 'latest'.freeze
25
12
 
26
13
  def set_entity_id(entity_id)
27
14
  @environment['SIMPLESAMLPHP_SP_ENTITY_ID'] = entity_id
@@ -31,18 +18,10 @@ module Gitlab
31
18
  @environment['SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE'] = assertion_con_service
32
19
  end
33
20
 
34
- def add_network_alias(name)
35
- @network_aliases.push(name)
36
- end
37
-
38
21
  def name
39
22
  @name ||= "saml-qa-idp"
40
23
  end
41
24
 
42
- def hostname
43
- "#{name}.#{network}"
44
- end
45
-
46
25
  def group_name
47
26
  @group_name ||= "saml_sso_group-#{SecureRandom.hex(4)}"
48
27
  end
@@ -50,25 +29,12 @@ module Gitlab
50
29
  def instance
51
30
  raise 'Please provide a block!' unless block_given?
52
31
 
53
- prepare
54
- start
55
-
56
- yield self
57
- ensure
58
- teardown
59
- end
60
-
61
- def prepare
62
- pull
63
-
64
- return if @docker.network_exists?(network)
65
-
66
- @docker.network_create(network)
32
+ super
67
33
  end
68
34
 
69
35
  # rubocop:disable Metrics/AbcSize
70
36
  def start
71
- docker.run(SAML_IMAGE, SAML_IMAGE_TAG) do |command|
37
+ docker.run(image, tag) do |command|
72
38
  command << '-d '
73
39
  command << "--name #{name}"
74
40
  command << "--net #{network}"
@@ -91,21 +57,6 @@ module Gitlab
91
57
  end
92
58
  # rubocop:enable Metrics/AbcSize
93
59
 
94
- def restart
95
- @docker.restart(name)
96
- end
97
-
98
- def teardown
99
- raise 'Invalid instance name!' unless name
100
-
101
- @docker.stop(name)
102
- @docker.remove(name)
103
- end
104
-
105
- def pull
106
- @docker.pull(SAML_IMAGE, SAML_IMAGE_TAG)
107
- end
108
-
109
60
  def set_sandbox_name(sandbox_name)
110
61
  ::Gitlab::QA::Runtime::Env.gitlab_sandbox_name = sandbox_name
111
62
  end
@@ -19,16 +19,7 @@ module Gitlab
19
19
  def perform # rubocop:disable Metrics/AbcSize
20
20
  raise ArgumentError unless [suite, release].all?
21
21
 
22
- if release.dev_gitlab_org?
23
- Docker::Command.execute(
24
- [
25
- 'login',
26
- '--username gitlab-qa-bot',
27
- %(--password "#{Runtime::Env.dev_access_token_variable}"),
28
- QA::Release::DEV_REGISTRY
29
- ]
30
- )
31
- end
22
+ @docker.login(**release.login_params) if release.login_params
32
23
 
33
24
  puts "Running test suite `#{suite}` for #{release.project_name}"
34
25
 
@@ -8,6 +8,10 @@ module Gitlab
8
8
  URI(DOCKER_HOST).host
9
9
  end
10
10
 
11
+ def login(username:, password:, registry:)
12
+ Docker::Command.execute(%(login --username "#{username}" --password "#{password}" #{registry}))
13
+ end
14
+
11
15
  def pull(image, tag)
12
16
  Docker::Command.execute("pull #{image}:#{tag}")
13
17
  end
@@ -63,6 +67,10 @@ module Gitlab
63
67
  def port(name, port)
64
68
  Docker::Command.execute("port #{name} #{port}/tcp")
65
69
  end
70
+
71
+ def running?(name)
72
+ Docker::Command.execute("ps -f name=#{name}").include?(name)
73
+ end
66
74
  end
67
75
  end
68
76
  end
@@ -135,6 +135,26 @@ module Gitlab
135
135
  end
136
136
  end
137
137
 
138
+ def login_params
139
+ if dev_gitlab_org?
140
+ Runtime::Env.require_qa_dev_access_token!
141
+
142
+ {
143
+ username: Runtime::Env.gitlab_dev_username,
144
+ password: Runtime::Env.dev_access_token_variable,
145
+ registry: DEV_REGISTRY
146
+ }
147
+ elsif omnibus_mirror?
148
+ Runtime::Env.require_gitlab_bot_multi_project_pipeline_polling_token!
149
+
150
+ {
151
+ username: Runtime::Env.gitlab_username,
152
+ password: Runtime::Env.gitlab_bot_multi_project_pipeline_polling_token,
153
+ registry: COM_REGISTRY
154
+ }
155
+ end
156
+ end
157
+
138
158
  def dev_gitlab_org?
139
159
  image.start_with?(DEV_REGISTRY)
140
160
  end
@@ -84,10 +84,22 @@ module Gitlab
84
84
  send(:attr_accessor, accessor) # rubocop:disable GitlabSecurity/PublicSend
85
85
  end
86
86
 
87
+ def gitlab_username
88
+ ENV['GITLAB_USERNAME'] || 'gitlab-qa'
89
+ end
90
+
91
+ def gitlab_dev_username
92
+ ENV['GITLAB_DEV_USERNAME'] || 'gitlab-qa-bot'
93
+ end
94
+
87
95
  def gitlab_api_base
88
96
  ENV['GITLAB_API_BASE'] || 'https://gitlab.com/api/v4'
89
97
  end
90
98
 
99
+ def gitlab_bot_multi_project_pipeline_polling_token
100
+ ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN']
101
+ end
102
+
91
103
  def ci_job_name
92
104
  ENV['CI_JOB_NAME']
93
105
  end
@@ -195,8 +207,14 @@ module Gitlab
195
207
  end
196
208
  end
197
209
 
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
+
198
216
  def skip_pull?
199
- (ENV['QA_SKIP_PULL'] =~ /^(false|no|0)$/i) != 0
217
+ enabled?(ENV['QA_SKIP_PULL'], default: false)
200
218
  end
201
219
 
202
220
  def gitlab_qa_formless_login_token
@@ -205,6 +223,12 @@ module Gitlab
205
223
 
206
224
  private
207
225
 
226
+ def enabled?(value, default: true)
227
+ return default if value.nil?
228
+
229
+ (value =~ /^(false|no|0)$/i) != 0
230
+ end
231
+
208
232
  def env_value_if_defined(variable)
209
233
  # Pass through the variables if they are defined in the environment
210
234
  return "$#{variable}" if ENV[variable]
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitlab
4
+ module QA
5
+ module Runtime
6
+ ##
7
+ # Singleton approach to global test scenario arguments.
8
+ #
9
+ module Scenario
10
+ extend self
11
+
12
+ def attributes
13
+ @attributes ||= {}
14
+ end
15
+
16
+ def define(attribute, value)
17
+ attributes.store(attribute.to_sym, value)
18
+
19
+ define_singleton_method(attribute) do
20
+ attributes[attribute.to_sym].tap do |value|
21
+ if value.to_s.empty?
22
+ raise ArgumentError, "Empty `#{attribute}` attribute!"
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ # rubocop:disable Style/MethodMissing
29
+ def method_missing(name, *)
30
+ raise ArgumentError, "Scenario attribute `#{name}` not defined!"
31
+ end
32
+ # rubocop:enable Style/MethodMissing
33
+ end
34
+ end
35
+ end
36
+ end
@@ -31,7 +31,7 @@ module Gitlab
31
31
  praefect.release = QA::Release.new(release)
32
32
  praefect.name = @praefect_node
33
33
  praefect.network = @network
34
- praefect.skip_check = true
34
+ praefect.skip_availability_check = true
35
35
 
36
36
  praefect.omnibus_config = praefect_omnibus_configuration
37
37
 
@@ -149,7 +149,7 @@ module Gitlab
149
149
  gitaly.release = QA::Release.new(release)
150
150
  gitaly.name = name
151
151
  gitaly.network = @network
152
- gitaly.skip_check = true
152
+ gitaly.skip_availability_check = true
153
153
 
154
154
  gitaly.omnibus_config = gitaly_omnibus_configuration
155
155
 
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module QA
3
- VERSION = '5.13.6'.freeze
3
+ VERSION = '5.13.7'.freeze
4
4
  end
5
5
  end
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.13.6
4
+ version: 5.13.7
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-02 00:00:00.000000000 Z
11
+ date: 2020-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control
@@ -237,6 +237,7 @@ files:
237
237
  - fixtures/ldap/tanuki.ldif
238
238
  - gitlab-qa.gemspec
239
239
  - lib/gitlab/qa.rb
240
+ - lib/gitlab/qa/component/base.rb
240
241
  - lib/gitlab/qa/component/elasticsearch.rb
241
242
  - lib/gitlab/qa/component/gitlab.rb
242
243
  - lib/gitlab/qa/component/internet_tunnel.rb
@@ -263,6 +264,7 @@ files:
263
264
  - lib/gitlab/qa/reporter.rb
264
265
  - lib/gitlab/qa/runner.rb
265
266
  - lib/gitlab/qa/runtime/env.rb
267
+ - lib/gitlab/qa/runtime/scenario.rb
266
268
  - lib/gitlab/qa/runtime/token_finder.rb
267
269
  - lib/gitlab/qa/scenario/actable.rb
268
270
  - lib/gitlab/qa/scenario/cli_commands.rb
@@ -327,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
327
329
  - !ruby/object:Gem::Version
328
330
  version: '0'
329
331
  requirements: []
330
- rubygems_version: 3.1.3
332
+ rubygems_version: 3.1.4
331
333
  signing_key:
332
334
  specification_version: 4
333
335
  summary: Integration tests for GitLab