Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
b49ce524ed
commit
533309f5fc
|
|
@ -43,9 +43,8 @@
|
|||
= s_('AdminUsers|External')
|
||||
%p.light.gl-pl-2
|
||||
= s_('AdminUsers|External users cannot see internal or private projects unless access is explicitly granted. Also, external users cannot create projects, groups, or personal snippets.')
|
||||
%row.hidden#warning_external_automatically_set.hidden
|
||||
.badge.badge-warning.text-white
|
||||
= s_('AdminUsers|Automatically marked as default internal user')
|
||||
%row.hidden#warning_external_automatically_set
|
||||
= gl_badge_tag s_('AdminUsers|Automatically marked as default internal user'), variant: :warning
|
||||
|
||||
.form-group.row
|
||||
- @user.credit_card_validation || @user.build_credit_card_validation
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class BackgroundMigrationWorker # rubocop:disable Scalability/IdempotentWorker
|
|||
include BackgroundMigration::SingleDatabaseWorker
|
||||
|
||||
def self.tracking_database
|
||||
@tracking_database ||= Gitlab::Database::MAIN_DATABASE_NAME.to_sym
|
||||
@tracking_database ||= Gitlab::BackgroundMigration::DEFAULT_TRACKING_DATABASE
|
||||
end
|
||||
|
||||
def self.unhealthy_metric_name
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
|
||||
module Gitlab
|
||||
module BackgroundMigration
|
||||
DEFAULT_TRACKING_DATABASE = Gitlab::Database::MAIN_DATABASE_NAME
|
||||
|
||||
def self.coordinator_for_database(database)
|
||||
JobCoordinator.for_database(database)
|
||||
JobCoordinator.for_tracking_database(database)
|
||||
end
|
||||
|
||||
def self.queue(database: :main)
|
||||
def self.queue(database: DEFAULT_TRACKING_DATABASE)
|
||||
coordinator_for_database(database).queue
|
||||
end
|
||||
|
||||
|
|
@ -22,7 +24,7 @@ module Gitlab
|
|||
# steal_class - The name of the class for which to steal jobs.
|
||||
# retry_dead_jobs - Flag to control whether jobs in Sidekiq::RetrySet or Sidekiq::DeadSet are retried.
|
||||
# database - tracking database this migration executes against
|
||||
def self.steal(steal_class, retry_dead_jobs: false, database: :main, &block)
|
||||
def self.steal(steal_class, retry_dead_jobs: false, database: DEFAULT_TRACKING_DATABASE, &block)
|
||||
coordinator_for_database(database).steal(steal_class, retry_dead_jobs: retry_dead_jobs, &block)
|
||||
end
|
||||
|
||||
|
|
@ -35,15 +37,15 @@ module Gitlab
|
|||
# arguments - The arguments to pass to the background migration's "perform"
|
||||
# method.
|
||||
# database - tracking database this migration executes against
|
||||
def self.perform(class_name, arguments, database: :main)
|
||||
def self.perform(class_name, arguments, database: DEFAULT_TRACKING_DATABASE)
|
||||
coordinator_for_database(database).perform(class_name, arguments)
|
||||
end
|
||||
|
||||
def self.exists?(migration_class, additional_queues = [], database: :main)
|
||||
def self.exists?(migration_class, additional_queues = [], database: DEFAULT_TRACKING_DATABASE)
|
||||
coordinator_for_database(database).exists?(migration_class, additional_queues) # rubocop:disable CodeReuse/ActiveRecord
|
||||
end
|
||||
|
||||
def self.remaining(database: :main)
|
||||
def self.remaining(database: DEFAULT_TRACKING_DATABASE)
|
||||
coordinator_for_database(database).remaining
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,24 +8,33 @@ module Gitlab
|
|||
# convention of how the queues and worker classes are setup for each database.
|
||||
#
|
||||
# Also provides a database connection to the correct tracking database.
|
||||
class JobCoordinator
|
||||
VALID_DATABASES = %i[main].freeze
|
||||
WORKER_CLASS_NAME = 'BackgroundMigrationWorker'
|
||||
|
||||
def self.for_database(database)
|
||||
database = database.to_sym
|
||||
|
||||
unless VALID_DATABASES.include?(database)
|
||||
raise ArgumentError, "database must be one of [#{VALID_DATABASES.join(', ')}], got '#{database}'"
|
||||
class JobCoordinator # rubocop:disable Metrics/ClassLength
|
||||
class << self
|
||||
def worker_classes
|
||||
@worker_classes ||= [
|
||||
BackgroundMigrationWorker
|
||||
].freeze
|
||||
end
|
||||
|
||||
namespace = database.to_s.capitalize unless database == :main
|
||||
namespaced_worker_class = [namespace, WORKER_CLASS_NAME].compact.join('::')
|
||||
def worker_for_tracking_database
|
||||
@worker_for_tracking_database ||= worker_classes
|
||||
.index_by(&:tracking_database)
|
||||
.with_indifferent_access
|
||||
.freeze
|
||||
end
|
||||
|
||||
new(database, "::#{namespaced_worker_class}".constantize)
|
||||
def for_tracking_database(tracking_database)
|
||||
worker_class = worker_for_tracking_database[tracking_database]
|
||||
|
||||
if worker_class.nil?
|
||||
raise ArgumentError, "tracking_database must be one of [#{worker_for_tracking_database.keys.join(', ')}]"
|
||||
end
|
||||
|
||||
new(worker_class)
|
||||
end
|
||||
end
|
||||
|
||||
attr_reader :database, :worker_class
|
||||
attr_reader :worker_class
|
||||
|
||||
def queue
|
||||
@queue ||= worker_class.sidekiq_options['queue']
|
||||
|
|
@ -118,15 +127,14 @@ module Gitlab
|
|||
|
||||
private
|
||||
|
||||
def initialize(database, worker_class)
|
||||
@database = database
|
||||
def initialize(worker_class)
|
||||
@worker_class = worker_class
|
||||
end
|
||||
|
||||
def connection
|
||||
@connection ||= Gitlab::Database
|
||||
.database_base_models
|
||||
.fetch(database, Gitlab::Database::PRIMARY_DATABASE_NAME)
|
||||
.fetch(worker_class.tracking_database, Gitlab::Database::PRIMARY_DATABASE_NAME)
|
||||
.connection
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@
|
|||
"@babel/preset-env": "^7.10.1",
|
||||
"@gitlab/at.js": "1.5.7",
|
||||
"@gitlab/favicon-overlay": "2.0.0",
|
||||
"@gitlab/svgs": "1.229.0",
|
||||
"@gitlab/svgs": "2.0.0",
|
||||
"@gitlab/tributejs": "1.0.0",
|
||||
"@gitlab/ui": "32.49.0",
|
||||
"@gitlab/ui": "32.50.0",
|
||||
"@gitlab/visual-review-tools": "1.6.1",
|
||||
"@rails/actioncable": "6.1.4-1",
|
||||
"@rails/ujs": "6.1.4-1",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,107 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module QA
|
||||
module Flow
|
||||
module Purchase
|
||||
include QA::Support::Helpers::Plan
|
||||
|
||||
module_function
|
||||
|
||||
def upgrade_subscription(plan: PREMIUM)
|
||||
Page::Group::Menu.perform(&:go_to_billing)
|
||||
Gitlab::Page::Group::Settings::Billing.perform do |billing|
|
||||
billing.send("upgrade_to_#{plan[:name].downcase}")
|
||||
end
|
||||
|
||||
Gitlab::Page::Subscriptions::New.perform do |new_subscription|
|
||||
new_subscription.continue_to_billing
|
||||
|
||||
fill_in_customer_info
|
||||
fill_in_payment_info
|
||||
|
||||
new_subscription.confirm_purchase
|
||||
end
|
||||
end
|
||||
|
||||
def purchase_ci_minutes(quantity: 1)
|
||||
Page::Group::Menu.perform(&:go_to_usage_quotas)
|
||||
Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota|
|
||||
usage_quota.pipeline_tab
|
||||
usage_quota.buy_ci_minutes
|
||||
end
|
||||
|
||||
Gitlab::Page::Subscriptions::New.perform do |ci_minutes|
|
||||
ci_minutes.quantity = quantity
|
||||
ci_minutes.continue_to_billing
|
||||
|
||||
fill_in_customer_info
|
||||
fill_in_payment_info
|
||||
|
||||
ci_minutes.confirm_purchase
|
||||
end
|
||||
end
|
||||
|
||||
def purchase_storage(quantity: 1)
|
||||
Page::Group::Menu.perform(&:go_to_usage_quotas)
|
||||
Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota|
|
||||
usage_quota.storage_tab
|
||||
usage_quota.buy_storage
|
||||
end
|
||||
|
||||
Gitlab::Page::Subscriptions::New.perform do |storage|
|
||||
storage.quantity = quantity
|
||||
storage.continue_to_billing
|
||||
|
||||
fill_in_customer_info
|
||||
fill_in_payment_info
|
||||
|
||||
storage.confirm_purchase
|
||||
end
|
||||
end
|
||||
|
||||
def fill_in_customer_info
|
||||
Gitlab::Page::Subscriptions::New.perform do |subscription|
|
||||
subscription.country = user_billing_info[:country]
|
||||
subscription.street_address_1 = user_billing_info[:address_1]
|
||||
subscription.street_address_2 = user_billing_info[:address_2]
|
||||
subscription.city = user_billing_info[:city]
|
||||
subscription.state = user_billing_info[:state]
|
||||
subscription.zip_code = user_billing_info[:zip]
|
||||
subscription.continue_to_payment
|
||||
end
|
||||
end
|
||||
|
||||
def fill_in_payment_info
|
||||
Gitlab::Page::Subscriptions::New.perform do |subscription|
|
||||
subscription.name_on_card = credit_card_info[:name]
|
||||
subscription.card_number = credit_card_info[:number]
|
||||
subscription.expiration_month = credit_card_info[:month]
|
||||
subscription.expiration_year = credit_card_info[:year]
|
||||
subscription.cvv = credit_card_info[:cvv]
|
||||
subscription.review_your_order
|
||||
end
|
||||
end
|
||||
|
||||
def credit_card_info
|
||||
{
|
||||
name: 'QA Test',
|
||||
number: '4111111111111111',
|
||||
month: '01',
|
||||
year: '2025',
|
||||
cvv: '232'
|
||||
}.freeze
|
||||
end
|
||||
|
||||
def user_billing_info
|
||||
{
|
||||
country: 'United States of America',
|
||||
address_1: 'Address 1',
|
||||
address_2: 'Address 2',
|
||||
city: 'San Francisco',
|
||||
state: 'California',
|
||||
zip: '94102'
|
||||
}.freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -3,32 +3,22 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Gitlab::BackgroundMigration::JobCoordinator do
|
||||
let(:database) { :main }
|
||||
let(:worker_class) { BackgroundMigrationWorker }
|
||||
let(:coordinator) { described_class.new(database, worker_class) }
|
||||
let(:tracking_database) { worker_class.tracking_database }
|
||||
let(:coordinator) { described_class.new(worker_class) }
|
||||
|
||||
describe '.for_database' do
|
||||
describe '.for_tracking_database' do
|
||||
it 'returns an executor with the correct worker class and database' do
|
||||
coordinator = described_class.for_database(database)
|
||||
coordinator = described_class.for_tracking_database(tracking_database)
|
||||
|
||||
expect(coordinator.database).to eq(database)
|
||||
expect(coordinator.worker_class).to eq(worker_class)
|
||||
end
|
||||
|
||||
context 'when passed in as a string' do
|
||||
it 'retruns an executor with the correct worker class and database' do
|
||||
coordinator = described_class.for_database(database.to_s)
|
||||
|
||||
expect(coordinator.database).to eq(database)
|
||||
expect(coordinator.worker_class).to eq(worker_class)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when an invalid value is given' do
|
||||
it 'raises an error' do
|
||||
expect do
|
||||
described_class.for_database('notvalid')
|
||||
end.to raise_error(ArgumentError, "database must be one of [main], got 'notvalid'")
|
||||
described_class.for_tracking_database('notvalid')
|
||||
end.to raise_error(ArgumentError, /tracking_database must be one of/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Gitlab::BackgroundMigration do
|
||||
let(:coordinator) { described_class::JobCoordinator.for_database(:main) }
|
||||
let(:default_tracking_database) { described_class::DEFAULT_TRACKING_DATABASE }
|
||||
let(:coordinator) { described_class::JobCoordinator.for_tracking_database(default_tracking_database) }
|
||||
|
||||
before do
|
||||
allow(described_class).to receive(:coordinator_for_database)
|
||||
.with(:main)
|
||||
.with(default_tracking_database)
|
||||
.and_return(coordinator)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do
|
|||
end
|
||||
|
||||
describe '#finalized_background_migration' do
|
||||
let(:job_coordinator) { Gitlab::BackgroundMigration::JobCoordinator.new(:main, BackgroundMigrationWorker) }
|
||||
let(:job_coordinator) { Gitlab::BackgroundMigration::JobCoordinator.new(BackgroundMigrationWorker) }
|
||||
|
||||
let!(:job_class_name) { 'TestJob' }
|
||||
let!(:job_class) { Class.new }
|
||||
|
|
@ -378,7 +378,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do
|
|||
job_class.define_method(:perform, job_perform_method)
|
||||
|
||||
allow(Gitlab::BackgroundMigration).to receive(:coordinator_for_database)
|
||||
.with(:main).and_return(job_coordinator)
|
||||
.with('main').and_return(job_coordinator)
|
||||
|
||||
expect(job_coordinator).to receive(:migration_class_for)
|
||||
.with(job_class_name).at_least(:once) { job_class }
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ RSpec.shared_examples 'it runs background migration jobs' do |tracking_database,
|
|||
allow(Postgresql::ReplicationSlot).to receive(:lag_too_great?).and_return(false)
|
||||
end
|
||||
|
||||
it 'performs jobs using the coordinator for the correct database' do
|
||||
it 'performs jobs using the coordinator for the worker' do
|
||||
expect_next_instance_of(Gitlab::BackgroundMigration::JobCoordinator) do |coordinator|
|
||||
allow(coordinator).to receive(:with_shared_connection).and_yield
|
||||
|
||||
expect(coordinator.database).to eq(tracking_database)
|
||||
expect(coordinator.worker_class).to eq(described_class)
|
||||
expect(coordinator).to receive(:perform).with('Foo', [10, 20])
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe BackgroundMigrationWorker, :clean_gitlab_redis_shared_state do
|
||||
it_behaves_like 'it runs background migration jobs', :main, :background_migration_database_health_reschedules
|
||||
it_behaves_like 'it runs background migration jobs', 'main', :background_migration_database_health_reschedules
|
||||
end
|
||||
|
|
|
|||
16
yarn.lock
16
yarn.lock
|
|
@ -914,20 +914,20 @@
|
|||
stylelint-declaration-strict-value "1.7.7"
|
||||
stylelint-scss "3.18.0"
|
||||
|
||||
"@gitlab/svgs@1.229.0":
|
||||
version "1.229.0"
|
||||
resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.229.0.tgz#1ee863320ea3e0ff6b670dac59373b8b49e31388"
|
||||
integrity sha512-10OLT3gj9AQ5DmcqaRcblkIY1dwr0danjaKl+hzjcA9sjvGuTNn3P/rQZglFanM2eI6MkoHG1YP7UeSs7cFuCQ==
|
||||
"@gitlab/svgs@2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-2.0.0.tgz#06af5e91c36498ccf7e3e30e432eefcb3b1276c2"
|
||||
integrity sha512-kBq7RZ0N+h41b4JbPOmwzx1X++fD+tz8HhaBmHTkOmRFY/7Ygvt2A8GodUUtpFK/NxRxy8O+knZvLNdfMLAIoQ==
|
||||
|
||||
"@gitlab/tributejs@1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@gitlab/tributejs/-/tributejs-1.0.0.tgz#672befa222aeffc83e7d799b0500a7a4418e59b8"
|
||||
integrity sha512-nmKw1+hB6MHvlmPz63yPwVs1qQkycHwsKgxpEbzmky16Y6mL4EJMk3w1b8QlOAF/AIAzjCERPhe/R4MJiohbZw==
|
||||
|
||||
"@gitlab/ui@32.49.0":
|
||||
version "32.49.0"
|
||||
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-32.49.0.tgz#d899e2e2487bb0e23a408386acc04eac14808de5"
|
||||
integrity sha512-QB1M1/8vc1o0hAm5tg8tWIEcj5Isy2JxHFWKtDNnFqPvbb0QNBsoEazz9DNra3dNSRzt8zF8NJPqmuRT8WAvQA==
|
||||
"@gitlab/ui@32.50.0":
|
||||
version "32.50.0"
|
||||
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-32.50.0.tgz#ac50617a8b84f78949e177f495ade276f8560679"
|
||||
integrity sha512-7wPEgbOn7M9hqzq5LZND5b8/OEajoFCjwaXzO42FBNJ+pb80JBsTg1Mu8dyXMGQP/SPcxO58BdQLUSjE0WER4w==
|
||||
dependencies:
|
||||
"@babel/standalone" "^7.0.0"
|
||||
bootstrap-vue "2.20.1"
|
||||
|
|
|
|||
Loading…
Reference in New Issue