gitlab-qa 14.16.0 → 14.18.0

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: b98b613be98b09d382003ce5a1bd4562bddf7a7e0216de30a76c0c264c51a973
4
- data.tar.gz: 808ee2237ccbcabe62430f504b99a1c39930e90ccaff107d7316ce8a7ee71f52
3
+ metadata.gz: 2aca04edea5cc1cf803513ed9d4bab1ed4d73ce2126e244e1d166ddce1c8cf1c
4
+ data.tar.gz: 5e5a38423e70530828c6a86a368c6825d5247808d799fcf38c195992d1a25bb7
5
5
  SHA512:
6
- metadata.gz: edff13e29e9dc6cdda84b1cf8103676e5b74703a45fd6a7a77d34cc5b7f5b1fa836957e130806c263864c2ee659bb7f7cd9c9620e0f97c8c5cce0b756b7b2c60
7
- data.tar.gz: 45ef2a7609d5e2345a4ca25067cb722098fe0ec734b9ab18ebf5513bf1af45d87f0a755f91ae0c4b2e10329a809e72c25f81df2c293aaadcc5dc89c763c07f6d
6
+ metadata.gz: 87668dd869f1100e6a78df1273934026960903a5de2fd36c53c54be61783a61cdc798d0baa908e82d5e9b6dcf9100e147fdf3d1343afe476b2c9e042f74b7d57
7
+ data.tar.gz: e47a1c57792a1f697eec41709ffdaef17c27284b9b3c918648d850dee3d968c63783b5e3c1cd87e1b15c832c6df92a2d32f0e2f796db14fd36f03a59e369fd57
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-qa (14.16.0)
4
+ gitlab-qa (14.18.0)
5
5
  activesupport (>= 6.1, < 7.2)
6
6
  gitlab (~> 4.19)
7
7
  http (~> 5.0)
@@ -1196,7 +1196,7 @@ The following `AiGateway` scenarios spin up a GitLab Omnibus instance integrated
1196
1196
 
1197
1197
  All scenarios below require the following environment variables, **_unless otherwise noted:_**
1198
1198
 
1199
- - `QA_EE_ACTIVATION_CODE`: An activation code for a Staging-generated Premium or Ultimate cloud license with a purchased Duo Pro add-on. This can be found in the GitLab QA 1Password vault.
1199
+ - `QA_EE_ACTIVATION_CODE`: An activation code for a Staging-generated Premium or Ultimate cloud license with a purchased Duo Pro or Duo Enterprise add-on. This can be found in the GitLab QA 1Password vault.
1200
1200
  - `GITLAB_LICENSE_MODE`: Set to `test` in order to configure GitLab Omnibus with the correct license mode and `CUSTOMER_PORTAL_URL`.
1201
1201
 
1202
1202
  Example:
@@ -1211,7 +1211,7 @@ $ export GITLAB_LICENSE_MODE="test"
1211
1211
  #### `Test::Integration::AiGateway EE|<full image address>`
1212
1212
 
1213
1213
  - Runs tests tagged with `:ai_gateway`
1214
- - GitLab instance has a cloud license + Duo Pro add-on, and a seat is assigned to the admin user
1214
+ - GitLab instance has a cloud license with either a Duo Pro add-on or Duo Enterprise add-on, and a seat is assigned to the admin user. Choose Duo Enterprise over Duo Pro when available.
1215
1215
 
1216
1216
  Example:
1217
1217
 
@@ -1224,7 +1224,7 @@ $ gitlab-qa Test::Integration::AiGateway EE
1224
1224
  #### `Test::Integration::AiGatewayNoSeatAssigned EE|<full image address>`
1225
1225
 
1226
1226
  - Runs tests tagged with `:ai_gateway_no_seat_assigned`
1227
- - GitLab instance has a cloud license + Duo Pro add-on, but no seat is assigned to the admin user
1227
+ - GitLab instance has a cloud license + Duo Pro or Duo Enterprise add-on, but no seat is assigned to the admin user.
1228
1228
 
1229
1229
  Example:
1230
1230
 
@@ -1237,11 +1237,11 @@ $ gitlab-qa Test::Integration::AiGatewayNoSeatAssigned EE
1237
1237
  #### `Test::Integration::AiGatewayNoAddOn EE|<full image address>`
1238
1238
 
1239
1239
  - Runs tests tagged with `:ai_gateway_no_add_on`
1240
- - GitLab instance has a cloud license without a Duo Pro add-on, and no seat is assigned to the admin user
1240
+ - GitLab instance has a cloud license without a Duo Pro or Duo Enterprise add-on, and no seat is assigned to the admin user.
1241
1241
 
1242
1242
  **Regarding environment variables:**
1243
1243
 
1244
- - `QA_EE_ACTIVATION_CODE` should be set to a Staging-generated Premium or Ultimate cloud license _without_ a Duo Pro add-on.
1244
+ - `QA_EE_ACTIVATION_CODE` should be set to a Staging-generated Premium or Ultimate cloud license _without_ a Duo Pro or Duo Enterprise add-on.
1245
1245
 
1246
1246
  Example:
1247
1247
 
@@ -28,7 +28,7 @@ module Gitlab
28
28
 
29
29
  ai_gateway.instance do
30
30
  gitlab.instance do
31
- set_up_duo_pro(gitlab) if @use_cloud_license
31
+ set_up_gitlab_duo(gitlab) if @use_cloud_license
32
32
  run_specs(gitlab, *rspec_args)
33
33
  end
34
34
  end
@@ -55,14 +55,14 @@ module Gitlab
55
55
  ai_gateway.configure_environment(gitlab_hostname: gitlab_hostname)
56
56
  end
57
57
 
58
- def set_up_duo_pro(gitlab)
59
- Runtime::Logger.info('Setting up Duo Pro on GitLab instance')
58
+ def set_up_gitlab_duo(gitlab)
59
+ Runtime::Logger.info('Setting up Gitlab Duo on GitLab instance')
60
60
 
61
61
  gitlab.docker.copy(gitlab.name, SETUP_SRC_PATH, SETUP_DEST_PATH)
62
62
 
63
63
  gitlab.docker.exec(
64
64
  gitlab.name,
65
- "ASSIGN_SEATS=#{@assign_seats} HAS_ADD_ON=#{@has_add_on} gitlab-rails runner #{SETUP_DEST_PATH}/duo_pro_setup.rb",
65
+ "ASSIGN_SEATS=#{@assign_seats} HAS_ADD_ON=#{@has_add_on} gitlab-rails runner #{SETUP_DEST_PATH}/gitlab_duo_setup.rb",
66
66
  mask_secrets: gitlab.secrets
67
67
  )
68
68
  end
@@ -26,8 +26,31 @@ module Gitlab
26
26
  #
27
27
  # @return [Array<QA::Release>]
28
28
  def fetch
29
- return [release(latest_patch(previous_version))] unless major_upgrade?
29
+ return minor_upgrade_path unless major_upgrade?
30
30
 
31
+ major_upgrade_path
32
+ rescue GitlabVersionInfo::VersionNotFoundError
33
+ logger.error("Failed to construct gitlab upgrade path")
34
+ raise
35
+ end
36
+
37
+ private
38
+
39
+ delegate :latest_patch, to: :version_info
40
+
41
+ attr_reader :version_info, :current_version, :semver_component, :edition, :logger
42
+
43
+ # Upgrade path from previous minor version
44
+ #
45
+ # @return [Array]
46
+ def minor_upgrade_path
47
+ [release(latest_patch(previous_version))]
48
+ end
49
+
50
+ # Upgrade path from previous major version
51
+ #
52
+ # @return [Array]
53
+ def major_upgrade_path
31
54
  # get versions between previous major and current version in gitlab upgrade path
32
55
  path = full_upgrade_path.each_with_object([]) do |ver, arr|
33
56
  next if ver <= previous_version || ver >= current_version
@@ -40,12 +63,6 @@ module Gitlab
40
63
  end
41
64
  end
42
65
 
43
- private
44
-
45
- delegate :latest_patch, to: :version_info
46
-
47
- attr_reader :version_info, :current_version, :semver_component, :edition, :logger
48
-
49
66
  # Upgrade from previous major
50
67
  #
51
68
  # @return [Boolean]
@@ -48,7 +48,9 @@ module Gitlab
48
48
  # check if version is already a patch version
49
49
  return version if version.to_s.split('.').size == 3
50
50
 
51
- versions.find { |ver| ver.to_s.match?(/^#{version}\./) }
51
+ versions.find { |ver| ver.to_s.match?(/^#{version}\./) }.tap do |ver|
52
+ raise_version_not_found("Latest patch version for version #{version}") unless ver
53
+ end
52
54
  end
53
55
 
54
56
  private
@@ -103,8 +105,9 @@ module Gitlab
103
105
  return fallback_minor unless tags
104
106
  return previous_major if current_minor.zero?
105
107
 
106
- versions.find { |version| version.to_s.match?(/^#{current_major}\.#{current_minor - 1}/) } ||
107
- raise(VersionNotFoundError, "Previous minor version for current version #{current_version} not available on Dockerhub (yet)")
108
+ versions.find { |version| version.to_s.match?(/^#{current_major}\.#{current_minor - 1}/) }.tap do |ver|
109
+ raise_version_not_found("Previous minor version for current version #{current_version}") unless ver
110
+ end
108
111
  end
109
112
 
110
113
  # Previous first minor version
@@ -204,6 +207,10 @@ module Gitlab
204
207
 
205
208
  [matching_tags, more_data]
206
209
  end
210
+
211
+ def raise_version_not_found(error_prefix)
212
+ raise(VersionNotFoundError, "#{error_prefix} not available on Dockerhub (yet)")
213
+ end
207
214
  end
208
215
  end
209
216
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module QA
5
- VERSION = '14.16.0'
5
+ VERSION = '14.18.0'
6
6
  end
7
7
  end
@@ -1,17 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class DuoProSetup
3
+ require 'active_support/core_ext/object/blank'
4
+
5
+ class GitlabDuoSetup
4
6
  class << self
5
7
  def configure!
6
8
  activate_cloud_license
7
9
 
8
10
  return unless enabled?('HAS_ADD_ON')
9
11
 
12
+ # The seat links endpoint in CustomersDot is rate limited and can sometimes
13
+ # prevent the service access token from being generated during license activation
14
+ # This generates the token directly, similar to the sync_service_token_worker cron job
15
+ generate_service_access_token
16
+
10
17
  # Due to the various async Sidekiq processes involved, we wait to verify
11
18
  # that the service access token has been generated before proceeding
12
19
  verify_service_access_token
13
20
 
14
- assign_duo_pro_seat_to_admin if enabled?('ASSIGN_SEATS')
21
+ assign_duo_seat_to_admin if enabled?('ASSIGN_SEATS')
15
22
  end
16
23
 
17
24
  private
@@ -29,32 +36,37 @@ class DuoProSetup
29
36
  end
30
37
  end
31
38
 
39
+ def generate_service_access_token
40
+ puts 'Generating service access token...'
41
+
42
+ ::CloudConnector::SyncServiceTokenWorker.perform_async(license_id: License.current.id)
43
+ end
44
+
45
+ def token_count
46
+ ::CloudConnector::ServiceAccessToken.active.count
47
+ end
48
+
32
49
  def verify_service_access_token
33
50
  puts 'Waiting for service access token to be available...'
34
51
 
35
52
  max_attempts = 3
36
53
  attempts = 0
37
54
 
38
- until (tokens = ::CloudConnector::ServiceAccessToken.active.count)&.positive? || attempts == max_attempts
55
+ until token_count&.positive? || attempts == max_attempts
39
56
  puts 'Attempting to verify access token exists...'
40
57
  attempts += 1
41
58
  sleep 30
42
59
  end
43
60
 
44
- return if tokens&.positive?
61
+ return if token_count&.positive?
45
62
 
46
63
  puts "Failed to create service access token after #{max_attempts} attempts"
47
64
  exit 1
48
65
  end
49
66
 
50
- def assign_duo_pro_seat_to_admin
51
- puts 'Assigning Duo Pro seat to admin...'
52
-
53
- admin = User.find_by(username: 'root')
54
- add_on = GitlabSubscriptions::AddOnPurchase.find_by(add_on: GitlabSubscriptions::AddOn.code_suggestions.last)
55
-
67
+ def assign_duo_seat_to_admin
56
68
  result = ::GitlabSubscriptions::UserAddOnAssignments::SelfManaged::CreateService.new(
57
- add_on_purchase: add_on, user: admin
69
+ add_on_purchase: add_on_purchase, user: admin
58
70
  ).execute
59
71
 
60
72
  if result.is_a?(ServiceResponse) && result[:status] == :success
@@ -70,7 +82,33 @@ class DuoProSetup
70
82
  def enabled?(key, default: nil)
71
83
  ENV.fetch(key, default) == 'true'
72
84
  end
85
+
86
+ def find_add_on_purchase(add_on:)
87
+ GitlabSubscriptions::AddOnPurchase.find_by(add_on: add_on)
88
+ end
89
+
90
+ def duo_pro_add_on
91
+ find_add_on_purchase(add_on: GitlabSubscriptions::AddOn.code_suggestions.last)
92
+ end
93
+
94
+ def duo_enterprise_add_on
95
+ find_add_on_purchase(add_on: GitlabSubscriptions::AddOn.duo_enterprise.last)
96
+ end
97
+
98
+ def admin
99
+ User.find_by(username: 'root')
100
+ end
101
+
102
+ def add_on_purchase
103
+ if duo_enterprise_add_on.present?
104
+ puts 'Assigning Duo Enterprise seat to admin...'
105
+ duo_enterprise_add_on
106
+ else
107
+ puts 'Assigning Duo Pro seat to admin...'
108
+ duo_pro_add_on
109
+ end
110
+ end
73
111
  end
74
112
  end
75
113
 
76
- DuoProSetup.configure!
114
+ GitlabDuoSetup.configure!
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: 14.16.0
4
+ version: 14.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab Quality
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-26 00:00:00.000000000 Z
11
+ date: 2024-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control
@@ -502,7 +502,7 @@ files:
502
502
  - support/manifests/suggested_reviewer/pubsub.yaml
503
503
  - support/manifests/suggested_reviewer/recommender-bot.yaml
504
504
  - support/manifests/suggested_reviewer/recommender.yaml
505
- - support/setup/duo_pro_setup.rb
505
+ - support/setup/gitlab_duo_setup.rb
506
506
  - tls_certificates/authority/ca.crt
507
507
  - tls_certificates/authority/ca.key
508
508
  - tls_certificates/authority/ca.pem