diff options
author | Tiger <twatson@gitlab.com> | 2019-04-11 06:26:10 +0300 |
---|---|---|
committer | Tiger <twatson@gitlab.com> | 2019-05-17 04:18:42 +0300 |
commit | fa5a6ae172584c5c33665a6efa4a6aa4efaea9ad (patch) | |
tree | e24b9715ffd352f5285b46c4f1780ec2b173f141 /spec/services | |
parent | e9ed028472747422670fed448624bb3e067fb4e2 (diff) |
Stop configuring group clusters on creation
Immediate configuration is not ideal for group and instance
level clusters as projects that may never be deployed would
still have Kubernetes namespaces and service accounts created
for them.
As of https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/25586
we now create only the resources that are required for the
project being deployed, at the time of deployment.
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/clusters/refresh_service_spec.rb | 26 | ||||
-rw-r--r-- | spec/services/projects/create_service_spec.rb | 27 | ||||
-rw-r--r-- | spec/services/projects/transfer_service_spec.rb | 27 |
3 files changed, 4 insertions, 76 deletions
diff --git a/spec/services/clusters/refresh_service_spec.rb b/spec/services/clusters/refresh_service_spec.rb index 94c35228955..5bc8a709941 100644 --- a/spec/services/clusters/refresh_service_spec.rb +++ b/spec/services/clusters/refresh_service_spec.rb @@ -93,32 +93,14 @@ describe Clusters::RefreshService do let(:group) { cluster.group } let(:project) { create(:project, group: group) } - context 'when ci_preparing_state feature flag is enabled' do - include_examples 'does not create a kubernetes namespace' - - context 'when project already has kubernetes namespace' do - before do - create(:cluster_kubernetes_namespace, project: project, cluster: cluster) - end - - include_examples 'does not create a kubernetes namespace' - end - end + include_examples 'does not create a kubernetes namespace' - context 'when ci_preparing_state feature flag is disabled' do + context 'when project already has kubernetes namespace' do before do - stub_feature_flags(ci_preparing_state: false) + create(:cluster_kubernetes_namespace, project: project, cluster: cluster) end - include_examples 'creates a kubernetes namespace' - - context 'when project already has kubernetes namespace' do - before do - create(:cluster_kubernetes_namespace, project: project, cluster: cluster) - end - - include_examples 'does not create a kubernetes namespace' - end + include_examples 'does not create a kubernetes namespace' end end diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index bd7a0c68766..f54f9200661 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -268,33 +268,6 @@ describe Projects::CreateService, '#execute' do end end - context 'when group has kubernetes cluster' do - let(:group_cluster) { create(:cluster, :group, :provided_by_gcp) } - let(:group) { group_cluster.group } - - let(:token) { 'aaaa' } - let(:service_account_creator) { double(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService, execute: true) } - let(:secrets_fetcher) { double(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService, execute: token) } - - before do - group.add_owner(user) - - stub_feature_flags(ci_preparing_state: false) - expect(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService).to receive(:namespace_creator).and_return(service_account_creator) - expect(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService).to receive(:new).and_return(secrets_fetcher) - end - - it 'creates kubernetes namespace for the project' do - project = create_project(user, opts.merge!(namespace_id: group.id)) - - expect(project).to be_valid - - kubernetes_namespace = group_cluster.kubernetes_namespaces.first - expect(kubernetes_namespace).to be_present - expect(kubernetes_namespace.project).to eq(project) - end - end - context 'when there is an active service template' do before do create(:service, project: nil, template: true, active: true) diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 9acc3657fa9..a47c10d991a 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -73,33 +73,6 @@ describe Projects::TransferService do shard_name: project.repository_storage ) end - - context 'new group has a kubernetes cluster' do - let(:group_cluster) { create(:cluster, :group, :provided_by_gcp) } - let(:group) { group_cluster.group } - - let(:token) { 'aaaa' } - let(:service_account_creator) { double(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService, execute: true) } - let(:secrets_fetcher) { double(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService, execute: token) } - - subject { transfer_project(project, user, group) } - - before do - stub_feature_flags(ci_preparing_state: false) - expect(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService).to receive(:namespace_creator).and_return(service_account_creator) - expect(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService).to receive(:new).and_return(secrets_fetcher) - end - - it 'creates kubernetes namespace for the project' do - subject - - expect(project.kubernetes_namespaces.count).to eq(1) - - kubernetes_namespace = group_cluster.kubernetes_namespaces.first - expect(kubernetes_namespace).to be_present - expect(kubernetes_namespace.project).to eq(project) - end - end end context 'when transfer fails' do |