gitlab-qa 5.13.3 → 5.13.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,17 +19,6 @@ 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
32
-
33
22
  puts "Running test suite `#{suite}` for #{release.project_name}"
34
23
 
35
24
  name = "#{release.project_name}-qa-#{SecureRandom.hex(4)}"
@@ -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.3'.freeze
3
+ VERSION = '5.13.4'.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.3
4
+ version: 5.13.4
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-05-29 00:00:00.000000000 Z
11
+ date: 2020-06-02 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