Commit 6f7b87d0 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'gt-rename-cluster-platform-configure-worker' into 'master'

Rename `ClusterPlatformConfigureWorker`

Closes #54863

See merge request gitlab-org/gitlab-ce!23754
parents 82772caf ac5fe450
......@@ -228,7 +228,7 @@ module Clusters
return unless namespace_changed?
run_after_commit do
ClusterPlatformConfigureWorker.perform_async(cluster_id)
ClusterConfigureWorker.perform_async(cluster_id)
end
end
end
......
......@@ -13,7 +13,7 @@ module Clusters
configure_kubernetes
cluster.save!
ClusterPlatformConfigureWorker.perform_async(cluster.id)
ClusterConfigureWorker.perform_async(cluster.id)
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
log_service_error(e.class.name, provider.id, e.message)
......
......@@ -27,7 +27,7 @@
- gcp_cluster:cluster_wait_for_app_installation
- gcp_cluster:wait_for_cluster_creation
- gcp_cluster:cluster_wait_for_ingress_ip_address
- gcp_cluster:cluster_platform_configure
- gcp_cluster:cluster_configure
- gcp_cluster:cluster_project_configure
- github_import_advance_stage
......
# frozen_string_literal: true
class ClusterPlatformConfigureWorker
class ClusterConfigureWorker
include ApplicationWorker
include ClusterQueue
......
......@@ -10,7 +10,7 @@ class ClusterProvisionWorker
Clusters::Gcp::ProvisionService.new.execute(provider) if cluster.gcp?
end
ClusterPlatformConfigureWorker.perform_async(cluster.id) if cluster.user?
ClusterConfigureWorker.perform_async(cluster.id) if cluster.user?
end
end
end
# frozen_string_literal: true
class MigrateClusterConfigureWorkerSidekiqQueue < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
sidekiq_queue_migrate 'gcp_cluster:cluster_platform_configure', to: 'gcp_cluster:cluster_configure'
end
def down
sidekiq_queue_migrate 'gcp_cluster:cluster_configure', to: 'gcp_cluster:cluster_platform_configure'
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20181218192239) do
ActiveRecord::Schema.define(version: 20181219145520) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......
......@@ -311,7 +311,7 @@ describe Projects::ClustersController do
describe 'security' do
before do
allow(ClusterPlatformConfigureWorker).to receive(:perform_async)
allow(ClusterConfigureWorker).to receive(:perform_async)
stub_kubeclient_get_namespace('https://kubernetes.example.com', namespace: 'my-namespace')
end
......@@ -409,7 +409,7 @@ describe Projects::ClustersController do
end
before do
allow(ClusterPlatformConfigureWorker).to receive(:perform_async)
allow(ClusterConfigureWorker).to receive(:perform_async)
stub_kubeclient_get_namespace('https://kubernetes.example.com', namespace: 'my-namespace')
end
......
......@@ -130,7 +130,7 @@ describe 'Gcp Cluster', :js do
context 'when user changes cluster parameters' do
before do
allow(ClusterPlatformConfigureWorker).to receive(:perform_async)
allow(ClusterConfigureWorker).to receive(:perform_async)
fill_in 'cluster_platform_kubernetes_attributes_namespace', with: 'my-namespace'
page.within('#js-cluster-details') { click_button 'Save changes' }
end
......
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb')
describe MigrateClusterConfigureWorkerSidekiqQueue, :sidekiq, :redis do
include Gitlab::Database::MigrationHelpers
context 'when there are jobs in the queue' do
it 'correctly migrates queue when migrating up' do
Sidekiq::Testing.disable! do
stubbed_worker(queue: 'gcp_cluster:cluster_platform_configure').perform_async('Something', [1])
stubbed_worker(queue: 'gcp_cluster:cluster_configure').perform_async('Something', [1])
described_class.new.up
expect(sidekiq_queue_length('gcp_cluster:cluster_platform_configure')).to eq 0
expect(sidekiq_queue_length('gcp_cluster:cluster_configure')).to eq 2
end
end
it 'does not affect other queues under the same namespace' do
Sidekiq::Testing.disable! do
stubbed_worker(queue: 'gcp_cluster:cluster_install_app').perform_async('Something', [1])
stubbed_worker(queue: 'gcp_cluster:cluster_provision').perform_async('Something', [1])
stubbed_worker(queue: 'gcp_cluster:cluster_wait_for_app_installation').perform_async('Something', [1])
stubbed_worker(queue: 'gcp_cluster:wait_for_cluster_creation').perform_async('Something', [1])
stubbed_worker(queue: 'gcp_cluster:cluster_wait_for_ingress_ip_address').perform_async('Something', [1])
stubbed_worker(queue: 'gcp_cluster:cluster_project_configure').perform_async('Something', [1])
described_class.new.up
expect(sidekiq_queue_length('gcp_cluster:cluster_install_app')).to eq 1
expect(sidekiq_queue_length('gcp_cluster:cluster_provision')).to eq 1
expect(sidekiq_queue_length('gcp_cluster:cluster_wait_for_app_installation')).to eq 1
expect(sidekiq_queue_length('gcp_cluster:wait_for_cluster_creation')).to eq 1
expect(sidekiq_queue_length('gcp_cluster:cluster_wait_for_ingress_ip_address')).to eq 1
expect(sidekiq_queue_length('gcp_cluster:cluster_project_configure')).to eq 1
end
end
it 'correctly migrates queue when migrating down' do
Sidekiq::Testing.disable! do
stubbed_worker(queue: 'gcp_cluster:cluster_configure').perform_async('Something', [1])
described_class.new.down
expect(sidekiq_queue_length('gcp_cluster:cluster_platform_configure')).to eq 1
expect(sidekiq_queue_length('gcp_cluster:cluster_configure')).to eq 0
end
end
end
context 'when there are no jobs in the queues' do
it 'does not raise error when migrating up' do
expect { described_class.new.up }.not_to raise_error
end
it 'does not raise error when migrating down' do
expect { described_class.new.down }.not_to raise_error
end
end
def stubbed_worker(queue:)
Class.new do
include Sidekiq::Worker
sidekiq_options queue: queue
end
end
end
......@@ -394,7 +394,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context 'when namespace is updated' do
it 'should call ConfigureWorker' do
expect(ClusterPlatformConfigureWorker).to receive(:perform_async).with(cluster.id).once
expect(ClusterConfigureWorker).to receive(:perform_async).with(cluster.id).once
platform.namespace = 'new-namespace'
platform.save
......@@ -403,7 +403,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context 'when namespace is not updated' do
it 'should not call ConfigureWorker' do
expect(ClusterPlatformConfigureWorker).not_to receive(:perform_async)
expect(ClusterConfigureWorker).not_to receive(:perform_async)
platform.username = "new-username"
platform.save
......
......@@ -20,7 +20,7 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
subject { described_class.new.execute(provider) }
before do
allow(ClusterPlatformConfigureWorker).to receive(:perform_async)
allow(ClusterConfigureWorker).to receive(:perform_async)
end
shared_examples 'success' do
......@@ -43,8 +43,8 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
expect(platform.token).to eq(token)
end
it 'calls ClusterPlatformConfigureWorker in a ascync fashion' do
expect(ClusterPlatformConfigureWorker).to receive(:perform_async).with(cluster.id)
it 'calls ClusterConfigureWorker in a ascync fashion' do
expect(ClusterConfigureWorker).to receive(:perform_async).with(cluster.id)
subject
end
......
......@@ -37,7 +37,7 @@ describe Clusters::UpdateService do
end
before do
allow(ClusterPlatformConfigureWorker).to receive(:perform_async)
allow(ClusterConfigureWorker).to receive(:perform_async)
stub_kubeclient_get_namespace('https://kubernetes.example.com', namespace: 'my-namespace')
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe ClusterPlatformConfigureWorker, '#perform' do
describe ClusterConfigureWorker, '#perform' do
let(:worker) { described_class.new }
context 'when group cluster' do
......
......@@ -23,7 +23,7 @@ describe ClusterProvisionWorker do
end
it 'configures kubernetes platform' do
expect(ClusterPlatformConfigureWorker).to receive(:perform_async).with(cluster.id)
expect(ClusterConfigureWorker).to receive(:perform_async).with(cluster.id)
described_class.new.perform(cluster.id)
end
......@@ -32,7 +32,7 @@ describe ClusterProvisionWorker do
context 'when cluster does not exist' do
it 'does not provision a cluster' do
expect_any_instance_of(Clusters::Gcp::ProvisionService).not_to receive(:execute)
expect(ClusterPlatformConfigureWorker).not_to receive(:perform_async)
expect(ClusterConfigureWorker).not_to receive(:perform_async)
described_class.new.perform(123)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment