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 ...@@ -228,7 +228,7 @@ module Clusters
return unless namespace_changed? return unless namespace_changed?
run_after_commit do run_after_commit do
ClusterPlatformConfigureWorker.perform_async(cluster_id) ClusterConfigureWorker.perform_async(cluster_id)
end end
end end
end end
......
...@@ -13,7 +13,7 @@ module Clusters ...@@ -13,7 +13,7 @@ module Clusters
configure_kubernetes configure_kubernetes
cluster.save! cluster.save!
ClusterPlatformConfigureWorker.perform_async(cluster.id) ClusterConfigureWorker.perform_async(cluster.id)
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
log_service_error(e.class.name, provider.id, e.message) log_service_error(e.class.name, provider.id, e.message)
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
- gcp_cluster:cluster_wait_for_app_installation - gcp_cluster:cluster_wait_for_app_installation
- gcp_cluster:wait_for_cluster_creation - gcp_cluster:wait_for_cluster_creation
- gcp_cluster:cluster_wait_for_ingress_ip_address - gcp_cluster:cluster_wait_for_ingress_ip_address
- gcp_cluster:cluster_platform_configure - gcp_cluster:cluster_configure
- gcp_cluster:cluster_project_configure - gcp_cluster:cluster_project_configure
- github_import_advance_stage - github_import_advance_stage
......
# frozen_string_literal: true # frozen_string_literal: true
class ClusterPlatformConfigureWorker class ClusterConfigureWorker
include ApplicationWorker include ApplicationWorker
include ClusterQueue include ClusterQueue
......
...@@ -10,7 +10,7 @@ class ClusterProvisionWorker ...@@ -10,7 +10,7 @@ class ClusterProvisionWorker
Clusters::Gcp::ProvisionService.new.execute(provider) if cluster.gcp? Clusters::Gcp::ProvisionService.new.execute(provider) if cluster.gcp?
end end
ClusterPlatformConfigureWorker.perform_async(cluster.id) if cluster.user? ClusterConfigureWorker.perform_async(cluster.id) if cluster.user?
end end
end 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 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
......
...@@ -311,7 +311,7 @@ describe Projects::ClustersController do ...@@ -311,7 +311,7 @@ describe Projects::ClustersController do
describe 'security' do describe 'security' do
before 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') stub_kubeclient_get_namespace('https://kubernetes.example.com', namespace: 'my-namespace')
end end
...@@ -409,7 +409,7 @@ describe Projects::ClustersController do ...@@ -409,7 +409,7 @@ describe Projects::ClustersController do
end end
before 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') stub_kubeclient_get_namespace('https://kubernetes.example.com', namespace: 'my-namespace')
end end
......
...@@ -130,7 +130,7 @@ describe 'Gcp Cluster', :js do ...@@ -130,7 +130,7 @@ describe 'Gcp Cluster', :js do
context 'when user changes cluster parameters' do context 'when user changes cluster parameters' do
before 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' fill_in 'cluster_platform_kubernetes_attributes_namespace', with: 'my-namespace'
page.within('#js-cluster-details') { click_button 'Save changes' } page.within('#js-cluster-details') { click_button 'Save changes' }
end 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 ...@@ -394,7 +394,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context 'when namespace is updated' do context 'when namespace is updated' do
it 'should call ConfigureWorker' 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.namespace = 'new-namespace'
platform.save platform.save
...@@ -403,7 +403,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching ...@@ -403,7 +403,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context 'when namespace is not updated' do context 'when namespace is not updated' do
it 'should not call ConfigureWorker' 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.username = "new-username"
platform.save platform.save
......
...@@ -20,7 +20,7 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do ...@@ -20,7 +20,7 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
subject { described_class.new.execute(provider) } subject { described_class.new.execute(provider) }
before do before do
allow(ClusterPlatformConfigureWorker).to receive(:perform_async) allow(ClusterConfigureWorker).to receive(:perform_async)
end end
shared_examples 'success' do shared_examples 'success' do
...@@ -43,8 +43,8 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do ...@@ -43,8 +43,8 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
expect(platform.token).to eq(token) expect(platform.token).to eq(token)
end end
it 'calls ClusterPlatformConfigureWorker in a ascync fashion' do it 'calls ClusterConfigureWorker in a ascync fashion' do
expect(ClusterPlatformConfigureWorker).to receive(:perform_async).with(cluster.id) expect(ClusterConfigureWorker).to receive(:perform_async).with(cluster.id)
subject subject
end end
......
...@@ -37,7 +37,7 @@ describe Clusters::UpdateService do ...@@ -37,7 +37,7 @@ describe Clusters::UpdateService do
end end
before 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') stub_kubeclient_get_namespace('https://kubernetes.example.com', namespace: 'my-namespace')
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe ClusterPlatformConfigureWorker, '#perform' do describe ClusterConfigureWorker, '#perform' do
let(:worker) { described_class.new } let(:worker) { described_class.new }
context 'when group cluster' do context 'when group cluster' do
......
...@@ -23,7 +23,7 @@ describe ClusterProvisionWorker do ...@@ -23,7 +23,7 @@ describe ClusterProvisionWorker do
end end
it 'configures kubernetes platform' do 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) described_class.new.perform(cluster.id)
end end
...@@ -32,7 +32,7 @@ describe ClusterProvisionWorker do ...@@ -32,7 +32,7 @@ describe ClusterProvisionWorker do
context 'when cluster does not exist' do context 'when cluster does not exist' do
it 'does not provision a cluster' do it 'does not provision a cluster' do
expect_any_instance_of(Clusters::Gcp::ProvisionService).not_to receive(:execute) 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) described_class.new.perform(123)
end 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