Commit c36d7842 authored by Shinya Maeda's avatar Shinya Maeda

Aling shared_exmaples to "same behavior between KubernetesService and Platform::Kubernetes"

parent 53da3d97
......@@ -147,7 +147,7 @@
%ul
%li Be careful. Renaming a project's repository can have unintended side effects.
%li You will need to update your local repositories to point to the new location.
- if @project.deployment_platform.any?
- if @project.deployment_platform.present?
%li Your deployment services will be broken, you will need to manually fix the services after renaming.
= f.submit 'Rename project', class: "btn btn-warning"
- if can?(current_user, :change_namespace, @project)
......
......@@ -113,7 +113,7 @@ describe Projects::BranchesController do
expect(response).to redirect_to project_tree_path(project, branch)
end
shared_examples 'correct behavior on KubernetesService and Platform::Kubernetes' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
it 'redirects to autodeploy setup page' do
result = { status: :success, branch: double(name: branch) }
......@@ -136,7 +136,7 @@ describe Projects::BranchesController do
project.services << build(:kubernetes_service)
end
it_behaves_like 'correct behavior on KubernetesService and Platform::Kubernetes'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
......@@ -144,7 +144,7 @@ describe Projects::BranchesController do
create(:cluster, :provided_by_gcp, projects: [project])
end
it_behaves_like 'correct behavior on KubernetesService and Platform::Kubernetes'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
......
......@@ -4,7 +4,7 @@ describe 'Auto deploy' do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
shared_examples 'correct behavior on KubernetesService and Platform::Kubernetes' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
context 'when no deployment service is active' do
before do
project.kubernetes_service.update!(active: false)
......@@ -56,7 +56,7 @@ describe 'Auto deploy' do
sign_in user
end
it_behaves_like 'correct behavior on KubernetesService and Platform::Kubernetes'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
......@@ -66,6 +66,6 @@ describe 'Auto deploy' do
sign_in user
end
it_behaves_like 'correct behavior on KubernetesService and Platform::Kubernetes'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
......@@ -101,7 +101,7 @@ feature 'Environment' do
end
context 'with terminal' do
shared_examples 'correct behavior with terminal' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
context 'for project master' do
let(:role) { :master }
......@@ -135,14 +135,14 @@ feature 'Environment' do
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project, :test_repo) }
it_behaves_like 'correct behavior with terminal'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior with terminal'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
......
......@@ -208,7 +208,7 @@ feature 'Environments page', :js do
end
context 'when kubernetes terminal is available' do
shared_examples 'correct behavior with terminal' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
context 'for project master' do
let(:role) { :master }
......@@ -229,14 +229,14 @@ feature 'Environments page', :js do
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project, :test_repo) }
it_behaves_like 'correct behavior with terminal'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior with terminal'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
end
......
......@@ -4,7 +4,7 @@ describe Gitlab::Ci::Build::Policy::Kubernetes do
let(:pipeline) { create(:ci_pipeline, project: project) }
context 'when kubernetes service is active' do
shared_examples 'correct behavior for satisfied_by?' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
it 'is satisfied by a kubernetes pipeline' do
expect(described_class.new('active'))
.to be_satisfied_by(pipeline)
......@@ -14,14 +14,14 @@ describe Gitlab::Ci::Build::Policy::Kubernetes do
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'correct behavior for satisfied_by?'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior for satisfied_by?'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
......
......@@ -178,7 +178,7 @@ module Gitlab
end
context 'when kubernetes is active' do
shared_examples 'correct behavior for kubernetes policy' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
it 'returns seeds for kubernetes dependent job' do
seeds = subject.stage_seeds(pipeline)
......@@ -192,7 +192,7 @@ module Gitlab
let(:project) { create(:kubernetes_project) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
it_behaves_like 'correct behavior for kubernetes policy'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
......@@ -200,7 +200,7 @@ module Gitlab
let(:project) { cluster.project }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
it_behaves_like 'correct behavior for kubernetes policy'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
......
......@@ -557,7 +557,7 @@ describe Ci::Pipeline, :mailer do
describe '#has_kubernetes_active?' do
context 'when kubernetes is active' do
shared_examples 'correct behavior with has_kubernetes_active?' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
it 'returns true' do
expect(pipeline).to have_kubernetes_active
end
......@@ -566,14 +566,14 @@ describe Ci::Pipeline, :mailer do
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'correct behavior with has_kubernetes_active?'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior with has_kubernetes_active?'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
......
......@@ -92,55 +92,6 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
end
end
describe 'after_save from Clusters::Cluster' do
# context 'when platform_kubernetes is being cerated' do
# let(:enabled) { true }
# let(:project) { create(:project) }
# let(:cluster) { build(:cluster, provider_type: :gcp, platform_type: :kubernetes, platform_kubernetes: platform, provider_gcp: provider, enabled: enabled, projects: [project]) }
# let(:platform) { build(:cluster_platform_kubernetes, :configured) }
# let(:provider) { build(:cluster_provider_gcp) }
# let(:kubernetes_service) { project.kubernetes_service }
# it 'updates KubernetesService' do
# cluster.save!
# expect(kubernetes_service.active).to eq(enabled)
# expect(kubernetes_service.api_url).to eq(platform.api_url)
# expect(kubernetes_service.namespace).to eq(platform.namespace)
# expect(kubernetes_service.ca_pem).to eq(platform.ca_cert)
# end
# end
# context 'when platform_kubernetes has been created' do
# let(:enabled) { false }
# let!(:project) { create(:project) }
# let!(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
# let(:platform) { cluster.platform }
# let(:kubernetes_service) { project.kubernetes_service }
# it 'updates KubernetesService' do
# cluster.update(enabled: enabled)
# expect(kubernetes_service.active).to eq(enabled)
# end
# end
# context 'when kubernetes_service has been configured without cluster integration' do
# let!(:project) { create(:project) }
# let(:cluster) { build(:cluster, provider_type: :gcp, platform_type: :kubernetes, platform_kubernetes: platform, provider_gcp: provider, projects: [project]) }
# let(:platform) { build(:cluster_platform_kubernetes, :configured, api_url: 'https://111.111.111.111') }
# let(:provider) { build(:cluster_provider_gcp) }
# before do
# create(:kubernetes_service, project: project)
# end
# it 'raises an error' do
# expect { cluster.save! }.to raise_error('Kubernetes service already configured')
# end
# end
end
describe '#actual_namespace' do
subject { kubernetes.actual_namespace }
......
......@@ -327,7 +327,7 @@ describe Environment do
context 'when the enviroment is available' do
context 'with a deployment service' do
shared_examples 'correct behavior for has_terminals?' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
context 'and a deployment' do
let!(:deployment) { create(:deployment, environment: environment) }
it { is_expected.to be_truthy }
......@@ -341,14 +341,14 @@ describe Environment do
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'correct behavior for has_terminals?'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior for has_terminals?'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
......@@ -376,7 +376,7 @@ describe Environment do
allow(environment).to receive(:has_terminals?).and_return(true)
end
shared_examples 'correct behavior on KubernetesService and Platform::Kubernetes' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
it 'returns the terminals from the deployment service' do
expect(project.deployment_platform)
.to receive(:terminals).with(environment)
......@@ -389,14 +389,14 @@ describe Environment do
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'correct behavior on KubernetesService and Platform::Kubernetes'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior on KubernetesService and Platform::Kubernetes'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
......
......@@ -2002,7 +2002,7 @@ describe Project do
end
context 'when project has a deployment service' do
shared_examples 'correct behavior on KubernetesService and Platform::Kubernetes' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
it 'returns variables from this service' do
expect(project.deployment_variables).to include(
{ key: 'KUBE_TOKEN', value: project.deployment_platform.token, public: false }
......@@ -2013,14 +2013,14 @@ describe Project do
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'correct behavior on KubernetesService and Platform::Kubernetes'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior on KubernetesService and Platform::Kubernetes'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
end
......
......@@ -41,7 +41,7 @@ RSpec.shared_examples 'additional metrics query' do
end
describe 'project has Kubernetes service' do
shared_examples 'correct behavior with metrics' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
let(:environment) { create(:environment, slug: 'environment-slug', project: project) }
let(:kube_namespace) { project.deployment_platform.actual_namespace }
......@@ -57,14 +57,14 @@ RSpec.shared_examples 'additional metrics query' do
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'correct behavior with metrics'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior with metrics'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
......
......@@ -5,7 +5,7 @@ describe ReactiveCachingWorker do
subject { described_class.new.perform("KubernetesService", service.id) }
describe '#perform' do
shared_examples 'correct behavior with perform' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
it 'calls #exclusively_update_reactive_cache!' do
expect_any_instance_of(KubernetesService).to receive(:exclusively_update_reactive_cache!)
......@@ -16,14 +16,14 @@ describe ReactiveCachingWorker do
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'correct behavior with perform'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior with perform'
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
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