diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/services/clusters | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/services/clusters')
40 files changed, 87 insertions, 127 deletions
diff --git a/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb b/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb index 84bca76e69b..605d9e67ab6 100644 --- a/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb +++ b/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::CheckIngressIpAddressService do +RSpec.describe Clusters::Applications::CheckIngressIpAddressService do include ExclusiveLeaseHelpers let(:application) { create(:clusters_applications_ingress, :installed) } diff --git a/spec/services/clusters/applications/check_installation_progress_service_spec.rb b/spec/services/clusters/applications/check_installation_progress_service_spec.rb index 4b8db405101..13f7cd62002 100644 --- a/spec/services/clusters/applications/check_installation_progress_service_spec.rb +++ b/spec/services/clusters/applications/check_installation_progress_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::CheckInstallationProgressService, '#execute' do +RSpec.describe Clusters::Applications::CheckInstallationProgressService, '#execute' do RESCHEDULE_PHASES = Gitlab::Kubernetes::Pod::PHASES - [Gitlab::Kubernetes::Pod::SUCCEEDED, Gitlab::Kubernetes::Pod::FAILED].freeze let(:application) { create(:clusters_applications_helm, :installing) } diff --git a/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb b/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb index 9dede1947f8..4b8893429cf 100644 --- a/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb +++ b/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::CheckUninstallProgressService do +RSpec.describe Clusters::Applications::CheckUninstallProgressService do reschedule_phases = Gitlab::Kubernetes::Pod::PHASES - [Gitlab::Kubernetes::Pod::SUCCEEDED, Gitlab::Kubernetes::Pod::FAILED].freeze let(:application) { create(:clusters_applications_prometheus, :uninstalling) } diff --git a/spec/services/clusters/applications/check_upgrade_progress_service_spec.rb b/spec/services/clusters/applications/check_upgrade_progress_service_spec.rb index 29ee897454a..dbde8cec9b9 100644 --- a/spec/services/clusters/applications/check_upgrade_progress_service_spec.rb +++ b/spec/services/clusters/applications/check_upgrade_progress_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::CheckUpgradeProgressService do +RSpec.describe Clusters::Applications::CheckUpgradeProgressService do reschedule_phashes = ::Gitlab::Kubernetes::Pod::PHASES - [::Gitlab::Kubernetes::Pod::SUCCEEDED, ::Gitlab::Kubernetes::Pod::FAILED, ::Gitlab].freeze diff --git a/spec/services/clusters/applications/create_service_spec.rb b/spec/services/clusters/applications/create_service_spec.rb index 0b48af408e1..f93ae2c62f3 100644 --- a/spec/services/clusters/applications/create_service_spec.rb +++ b/spec/services/clusters/applications/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::CreateService do +RSpec.describe Clusters::Applications::CreateService do include TestRequestHelpers let(:cluster) { create(:cluster, :project, :provided_by_gcp) } diff --git a/spec/services/clusters/applications/destroy_service_spec.rb b/spec/services/clusters/applications/destroy_service_spec.rb index 8d9dc6a0f11..7306256e68e 100644 --- a/spec/services/clusters/applications/destroy_service_spec.rb +++ b/spec/services/clusters/applications/destroy_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::DestroyService, '#execute' do +RSpec.describe Clusters::Applications::DestroyService, '#execute' do let(:cluster) { create(:cluster, :project, :provided_by_gcp) } let(:user) { create(:user) } let(:params) { { application: 'prometheus' } } diff --git a/spec/services/clusters/applications/install_service_spec.rb b/spec/services/clusters/applications/install_service_spec.rb index 2441cc595a3..d34b4dd943c 100644 --- a/spec/services/clusters/applications/install_service_spec.rb +++ b/spec/services/clusters/applications/install_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::InstallService do +RSpec.describe Clusters::Applications::InstallService do describe '#execute' do let(:application) { create(:clusters_applications_helm, :scheduled) } let!(:install_command) { application.install_command } diff --git a/spec/services/clusters/applications/patch_service_spec.rb b/spec/services/clusters/applications/patch_service_spec.rb index dc9843a5116..281da62b80b 100644 --- a/spec/services/clusters/applications/patch_service_spec.rb +++ b/spec/services/clusters/applications/patch_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::PatchService do +RSpec.describe Clusters::Applications::PatchService do describe '#execute' do let(:application) { create(:clusters_applications_knative, :scheduled) } let!(:update_command) { application.update_command } diff --git a/spec/services/clusters/applications/prometheus_config_service_spec.rb b/spec/services/clusters/applications/prometheus_config_service_spec.rb index b9032e665ec..7399f250248 100644 --- a/spec/services/clusters/applications/prometheus_config_service_spec.rb +++ b/spec/services/clusters/applications/prometheus_config_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::PrometheusConfigService do +RSpec.describe Clusters::Applications::PrometheusConfigService do include Gitlab::Routing.url_helpers let_it_be(:project) { create(:project) } diff --git a/spec/services/clusters/applications/prometheus_health_check_service_spec.rb b/spec/services/clusters/applications/prometheus_health_check_service_spec.rb index 5c4127e4938..fc5a80688e6 100644 --- a/spec/services/clusters/applications/prometheus_health_check_service_spec.rb +++ b/spec/services/clusters/applications/prometheus_health_check_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::PrometheusHealthCheckService, '#execute' do +RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' do let(:service) { described_class.new(cluster) } subject { service.execute } diff --git a/spec/services/clusters/applications/prometheus_update_service_spec.rb b/spec/services/clusters/applications/prometheus_update_service_spec.rb index 078b01d2777..076ff0210c9 100644 --- a/spec/services/clusters/applications/prometheus_update_service_spec.rb +++ b/spec/services/clusters/applications/prometheus_update_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::PrometheusUpdateService do +RSpec.describe Clusters::Applications::PrometheusUpdateService do describe '#execute' do let(:project) { create(:project) } let(:environment) { create(:environment, project: project) } diff --git a/spec/services/clusters/applications/schedule_update_service_spec.rb b/spec/services/clusters/applications/schedule_update_service_spec.rb index eb1006ce8e0..f559fb1b7aa 100644 --- a/spec/services/clusters/applications/schedule_update_service_spec.rb +++ b/spec/services/clusters/applications/schedule_update_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::ScheduleUpdateService do +RSpec.describe Clusters::Applications::ScheduleUpdateService do describe '#execute' do let(:project) { create(:project) } diff --git a/spec/services/clusters/applications/uninstall_service_spec.rb b/spec/services/clusters/applications/uninstall_service_spec.rb index 6d7f0478b20..50d7e82c47e 100644 --- a/spec/services/clusters/applications/uninstall_service_spec.rb +++ b/spec/services/clusters/applications/uninstall_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::UninstallService, '#execute' do +RSpec.describe Clusters::Applications::UninstallService, '#execute' do let(:application) { create(:clusters_applications_prometheus, :scheduled) } let(:service) { described_class.new(application) } let(:helm_client) { instance_double(Gitlab::Kubernetes::Helm::API) } diff --git a/spec/services/clusters/applications/update_service_spec.rb b/spec/services/clusters/applications/update_service_spec.rb index 4676951faff..4c05a12a4a1 100644 --- a/spec/services/clusters/applications/update_service_spec.rb +++ b/spec/services/clusters/applications/update_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::UpdateService do +RSpec.describe Clusters::Applications::UpdateService do include TestRequestHelpers let(:cluster) { create(:cluster, :project, :provided_by_gcp) } diff --git a/spec/services/clusters/applications/upgrade_service_spec.rb b/spec/services/clusters/applications/upgrade_service_spec.rb index 86fb06375f1..22fbb7ca6e3 100644 --- a/spec/services/clusters/applications/upgrade_service_spec.rb +++ b/spec/services/clusters/applications/upgrade_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::UpgradeService do +RSpec.describe Clusters::Applications::UpgradeService do describe '#execute' do let(:application) { create(:clusters_applications_helm, :scheduled) } let!(:install_command) { application.install_command } diff --git a/spec/services/clusters/aws/authorize_role_service_spec.rb b/spec/services/clusters/aws/authorize_role_service_spec.rb index 3ef332558a2..530268340b7 100644 --- a/spec/services/clusters/aws/authorize_role_service_spec.rb +++ b/spec/services/clusters/aws/authorize_role_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Aws::AuthorizeRoleService do +RSpec.describe Clusters::Aws::AuthorizeRoleService do let(:user) { create(:user) } let(:credentials) { instance_double(Aws::Credentials) } let(:credentials_service) { instance_double(Clusters::Aws::FetchCredentialsService, execute: credentials) } diff --git a/spec/services/clusters/aws/fetch_credentials_service_spec.rb b/spec/services/clusters/aws/fetch_credentials_service_spec.rb index 9194947c67f..a0e63d96a5c 100644 --- a/spec/services/clusters/aws/fetch_credentials_service_spec.rb +++ b/spec/services/clusters/aws/fetch_credentials_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Aws::FetchCredentialsService do +RSpec.describe Clusters::Aws::FetchCredentialsService do describe '#execute' do let(:user) { create(:user) } let(:provider) { create(:cluster_provider_aws, region: 'ap-southeast-2') } diff --git a/spec/services/clusters/aws/finalize_creation_service_spec.rb b/spec/services/clusters/aws/finalize_creation_service_spec.rb index 8d7341483e3..6b0cb86eff0 100644 --- a/spec/services/clusters/aws/finalize_creation_service_spec.rb +++ b/spec/services/clusters/aws/finalize_creation_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Aws::FinalizeCreationService do +RSpec.describe Clusters::Aws::FinalizeCreationService do describe '#execute' do let(:provider) { create(:cluster_provider_aws, :creating) } let(:platform) { provider.cluster.platform_kubernetes } diff --git a/spec/services/clusters/aws/provision_service_spec.rb b/spec/services/clusters/aws/provision_service_spec.rb index 15571c64e13..529e1d26575 100644 --- a/spec/services/clusters/aws/provision_service_spec.rb +++ b/spec/services/clusters/aws/provision_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Aws::ProvisionService do +RSpec.describe Clusters::Aws::ProvisionService do describe '#execute' do let(:provider) { create(:cluster_provider_aws) } diff --git a/spec/services/clusters/aws/verify_provision_status_service_spec.rb b/spec/services/clusters/aws/verify_provision_status_service_spec.rb index b62b0875bf3..b9a58b97842 100644 --- a/spec/services/clusters/aws/verify_provision_status_service_spec.rb +++ b/spec/services/clusters/aws/verify_provision_status_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Aws::VerifyProvisionStatusService do +RSpec.describe Clusters::Aws::VerifyProvisionStatusService do describe '#execute' do let(:provider) { create(:cluster_provider_aws) } diff --git a/spec/services/clusters/build_kubernetes_namespace_service_spec.rb b/spec/services/clusters/build_kubernetes_namespace_service_spec.rb index 36c05469542..4ee933374f6 100644 --- a/spec/services/clusters/build_kubernetes_namespace_service_spec.rb +++ b/spec/services/clusters/build_kubernetes_namespace_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::BuildKubernetesNamespaceService do +RSpec.describe Clusters::BuildKubernetesNamespaceService do let(:cluster) { create(:cluster, :project, :provided_by_gcp) } let(:environment) { create(:environment) } let(:project) { environment.project } diff --git a/spec/services/clusters/build_service_spec.rb b/spec/services/clusters/build_service_spec.rb index f3e852726f4..c7a64435d3b 100644 --- a/spec/services/clusters/build_service_spec.rb +++ b/spec/services/clusters/build_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::BuildService do +RSpec.describe Clusters::BuildService do describe '#execute' do subject { described_class.new(cluster_subject).execute } diff --git a/spec/services/clusters/cleanup/app_service_spec.rb b/spec/services/clusters/cleanup/app_service_spec.rb index 14bfca02fee..ba1be7448a4 100644 --- a/spec/services/clusters/cleanup/app_service_spec.rb +++ b/spec/services/clusters/cleanup/app_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Cleanup::AppService do +RSpec.describe Clusters::Cleanup::AppService do describe '#execute' do let!(:cluster) { create(:cluster, :project, :cleanup_uninstalling_applications, provider_type: :gcp) } let(:service) { described_class.new(cluster) } diff --git a/spec/services/clusters/cleanup/project_namespace_service_spec.rb b/spec/services/clusters/cleanup/project_namespace_service_spec.rb index 22e29cc57d1..761ad8dd8c8 100644 --- a/spec/services/clusters/cleanup/project_namespace_service_spec.rb +++ b/spec/services/clusters/cleanup/project_namespace_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Cleanup::ProjectNamespaceService do +RSpec.describe Clusters::Cleanup::ProjectNamespaceService do describe '#execute' do subject { service.execute } diff --git a/spec/services/clusters/cleanup/service_account_service_spec.rb b/spec/services/clusters/cleanup/service_account_service_spec.rb index ecaf0da9fa3..6fe3d0c286e 100644 --- a/spec/services/clusters/cleanup/service_account_service_spec.rb +++ b/spec/services/clusters/cleanup/service_account_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Cleanup::ServiceAccountService do +RSpec.describe Clusters::Cleanup::ServiceAccountService do describe '#execute' do subject { service.execute } diff --git a/spec/services/clusters/create_service_spec.rb b/spec/services/clusters/create_service_spec.rb index 3dd25be2a3d..6e252bee7c0 100644 --- a/spec/services/clusters/create_service_spec.rb +++ b/spec/services/clusters/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::CreateService do +RSpec.describe Clusters::CreateService do let(:access_token) { 'xxx' } let(:project) { create(:project) } let(:user) { create(:user) } @@ -53,13 +53,54 @@ describe Clusters::CreateService do include_context 'valid cluster create params' let!(:cluster) { create(:cluster, :provided_by_gcp, :production_environment, projects: [project]) } - it 'does not create a cluster' do - expect(ClusterProvisionWorker).not_to receive(:perform_async) - expect { subject }.to raise_error(ArgumentError).and change { Clusters::Cluster.count }.by(0) + it 'creates another cluster' do + expect(ClusterProvisionWorker).to receive(:perform_async) + expect { subject }.to change { Clusters::Cluster.count }.by(1) end end end + context 'when another cluster exists' do + let!(:cluster) { create(:cluster, :provided_by_gcp, :production_environment, projects: [project]) } + + context 'when correct params' do + let(:params) do + { + name: 'test-cluster', + provider_type: :gcp, + provider_gcp_attributes: { + gcp_project_id: 'gcp-project', + zone: 'us-central1-a', + num_nodes: 1, + machine_type: 'machine_type-a', + legacy_abac: 'true' + }, + clusterable: project + } + end + + include_examples 'create cluster service success' + end + + context 'when invalid params' do + let(:params) do + { + name: 'test-cluster', + provider_type: :gcp, + provider_gcp_attributes: { + gcp_project_id: '!!!!!!!', + zone: 'us-central1-a', + num_nodes: 1, + machine_type: 'machine_type-a' + }, + clusterable: project + } + end + + include_examples 'create cluster service error' + end + end + context 'when params includes :management_project_id' do subject(:cluster) { described_class.new(user, params).execute(access_token: access_token) } diff --git a/spec/services/clusters/destroy_service_spec.rb b/spec/services/clusters/destroy_service_spec.rb index 43ebf8f499e..76d9cc34b5d 100644 --- a/spec/services/clusters/destroy_service_spec.rb +++ b/spec/services/clusters/destroy_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::DestroyService do +RSpec.describe Clusters::DestroyService do describe '#execute' do subject { described_class.new(cluster.user, params).execute(cluster) } diff --git a/spec/services/clusters/gcp/fetch_operation_service_spec.rb b/spec/services/clusters/gcp/fetch_operation_service_spec.rb index 23da8004a7d..990cc745382 100644 --- a/spec/services/clusters/gcp/fetch_operation_service_spec.rb +++ b/spec/services/clusters/gcp/fetch_operation_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Gcp::FetchOperationService do +RSpec.describe Clusters::Gcp::FetchOperationService do include GoogleApi::CloudPlatformHelpers describe '#execute' do diff --git a/spec/services/clusters/gcp/finalize_creation_service_spec.rb b/spec/services/clusters/gcp/finalize_creation_service_spec.rb index 4d1548c9786..be362dc6e23 100644 --- a/spec/services/clusters/gcp/finalize_creation_service_spec.rb +++ b/spec/services/clusters/gcp/finalize_creation_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Gcp::FinalizeCreationService, '#execute' do +RSpec.describe Clusters::Gcp::FinalizeCreationService, '#execute' do include GoogleApi::CloudPlatformHelpers include KubernetesHelpers diff --git a/spec/services/clusters/gcp/provision_service_spec.rb b/spec/services/clusters/gcp/provision_service_spec.rb index dfd15690a1f..c5778db6001 100644 --- a/spec/services/clusters/gcp/provision_service_spec.rb +++ b/spec/services/clusters/gcp/provision_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Gcp::ProvisionService do +RSpec.describe Clusters::Gcp::ProvisionService do include GoogleApi::CloudPlatformHelpers describe '#execute' do diff --git a/spec/services/clusters/gcp/verify_provision_status_service_spec.rb b/spec/services/clusters/gcp/verify_provision_status_service_spec.rb index 584f9b8367f..ccb4b3b6c15 100644 --- a/spec/services/clusters/gcp/verify_provision_status_service_spec.rb +++ b/spec/services/clusters/gcp/verify_provision_status_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Gcp::VerifyProvisionStatusService do +RSpec.describe Clusters::Gcp::VerifyProvisionStatusService do include GoogleApi::CloudPlatformHelpers describe '#execute' do diff --git a/spec/services/clusters/kubernetes/configure_istio_ingress_service_spec.rb b/spec/services/clusters/kubernetes/configure_istio_ingress_service_spec.rb index e9f7f015293..b4402aadc88 100644 --- a/spec/services/clusters/kubernetes/configure_istio_ingress_service_spec.rb +++ b/spec/services/clusters/kubernetes/configure_istio_ingress_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Kubernetes::ConfigureIstioIngressService, '#execute' do +RSpec.describe Clusters::Kubernetes::ConfigureIstioIngressService, '#execute' do include KubernetesHelpers let(:cluster) { create(:cluster, :project, :provided_by_gcp) } diff --git a/spec/services/clusters/kubernetes/create_or_update_namespace_service_spec.rb b/spec/services/clusters/kubernetes/create_or_update_namespace_service_spec.rb index 6d8b1617c17..ee10c59390e 100644 --- a/spec/services/clusters/kubernetes/create_or_update_namespace_service_spec.rb +++ b/spec/services/clusters/kubernetes/create_or_update_namespace_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Kubernetes::CreateOrUpdateNamespaceService, '#execute' do +RSpec.describe Clusters::Kubernetes::CreateOrUpdateNamespaceService, '#execute' do include KubernetesHelpers let(:cluster) { create(:cluster, :project, :provided_by_gcp) } diff --git a/spec/services/clusters/kubernetes/create_or_update_service_account_service_spec.rb b/spec/services/clusters/kubernetes/create_or_update_service_account_service_spec.rb index 4bcd5c6933e..f3fa6c2c0bb 100644 --- a/spec/services/clusters/kubernetes/create_or_update_service_account_service_spec.rb +++ b/spec/services/clusters/kubernetes/create_or_update_service_account_service_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -describe Clusters::Kubernetes::CreateOrUpdateServiceAccountService do +RSpec.describe Clusters::Kubernetes::CreateOrUpdateServiceAccountService do include KubernetesHelpers let(:api_url) { 'http://111.111.111.111' } diff --git a/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb b/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb index fa4b6e497e5..c4daae9dbf0 100644 --- a/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb +++ b/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Kubernetes::FetchKubernetesTokenService do +RSpec.describe Clusters::Kubernetes::FetchKubernetesTokenService do include KubernetesHelpers describe '#execute' do diff --git a/spec/services/clusters/kubernetes_spec.rb b/spec/services/clusters/kubernetes_spec.rb index 09cc304debe..12af63890fc 100644 --- a/spec/services/clusters/kubernetes_spec.rb +++ b/spec/services/clusters/kubernetes_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Kubernetes do +RSpec.describe Clusters::Kubernetes do it { is_expected.to be_const_defined(:GITLAB_SERVICE_ACCOUNT_NAME) } it { is_expected.to be_const_defined(:GITLAB_SERVICE_ACCOUNT_NAMESPACE) } it { is_expected.to be_const_defined(:GITLAB_ADMIN_TOKEN_NAME) } diff --git a/spec/services/clusters/management/create_project_service_spec.rb b/spec/services/clusters/management/create_project_service_spec.rb index b7764b7840c..5d8cc71faa4 100644 --- a/spec/services/clusters/management/create_project_service_spec.rb +++ b/spec/services/clusters/management/create_project_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Management::CreateProjectService do +RSpec.describe Clusters::Management::CreateProjectService do let(:cluster) { create(:cluster, :project) } let(:current_user) { create(:user) } diff --git a/spec/services/clusters/management/validate_management_project_permissions_service_spec.rb b/spec/services/clusters/management/validate_management_project_permissions_service_spec.rb index 1bcebe2e2ac..a21c378d3d1 100644 --- a/spec/services/clusters/management/validate_management_project_permissions_service_spec.rb +++ b/spec/services/clusters/management/validate_management_project_permissions_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Management::ValidateManagementProjectPermissionsService do +RSpec.describe Clusters::Management::ValidateManagementProjectPermissionsService do describe '#execute' do subject { described_class.new(user).execute(cluster, management_project_id) } diff --git a/spec/services/clusters/parse_cluster_applications_artifact_service_spec.rb b/spec/services/clusters/parse_cluster_applications_artifact_service_spec.rb index bb0b107eba6..3b155d95345 100644 --- a/spec/services/clusters/parse_cluster_applications_artifact_service_spec.rb +++ b/spec/services/clusters/parse_cluster_applications_artifact_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::ParseClusterApplicationsArtifactService do +RSpec.describe Clusters::ParseClusterApplicationsArtifactService do let_it_be(:project) { create(:project) } let_it_be(:user) { create(:user) } @@ -120,90 +120,9 @@ describe Clusters::ParseClusterApplicationsArtifactService do end end - context 'release is missing' do - let(:fixture) { 'spec/fixtures/helm/helm_list_v2_prometheus_missing.json.gz' } - let(:file) { fixture_file_upload(Rails.root.join(fixture)) } - let(:artifact) { create(:ci_job_artifact, :cluster_applications, job: job, file: file) } - - context 'application does not exist' do - it 'does not create or destroy an application' do - expect do - described_class.new(job, user).execute(artifact) - end.not_to change(Clusters::Applications::Prometheus, :count) - end - end - - context 'application exists' do - before do - create(:clusters_applications_prometheus, :installed, cluster: cluster) - end - - it 'marks the application as uninstalled' do - described_class.new(job, user).execute(artifact) - - cluster.application_prometheus.reload - expect(cluster.application_prometheus).to be_uninstalled - end - end - end - - context 'release is deployed' do - let(:fixture) { 'spec/fixtures/helm/helm_list_v2_prometheus_deployed.json.gz' } - let(:file) { fixture_file_upload(Rails.root.join(fixture)) } - let(:artifact) { create(:ci_job_artifact, :cluster_applications, job: job, file: file) } - - context 'application does not exist' do - it 'creates an application and marks it as installed' do - expect do - described_class.new(job, user).execute(artifact) - end.to change(Clusters::Applications::Prometheus, :count) - - expect(cluster.application_prometheus).to be_persisted - expect(cluster.application_prometheus).to be_installed - end - end - - context 'application exists' do - before do - create(:clusters_applications_prometheus, :errored, cluster: cluster) - end - - it 'marks the application as installed' do - described_class.new(job, user).execute(artifact) - - expect(cluster.application_prometheus).to be_installed - end - end - end - - context 'release is failed' do - let(:fixture) { 'spec/fixtures/helm/helm_list_v2_prometheus_failed.json.gz' } - let(:file) { fixture_file_upload(Rails.root.join(fixture)) } - let(:artifact) { create(:ci_job_artifact, :cluster_applications, job: job, file: file) } - - context 'application does not exist' do - it 'creates an application and marks it as errored' do - expect do - described_class.new(job, user).execute(artifact) - end.to change(Clusters::Applications::Prometheus, :count) - - expect(cluster.application_prometheus).to be_persisted - expect(cluster.application_prometheus).to be_errored - expect(cluster.application_prometheus.status_reason).to eq('Helm release failed to install') - end - end - - context 'application exists' do - before do - create(:clusters_applications_prometheus, :installed, cluster: cluster) - end - - it 'marks the application as errored' do - described_class.new(job, user).execute(artifact) - - expect(cluster.application_prometheus).to be_errored - expect(cluster.application_prometheus.status_reason).to eq('Helm release failed to install') - end + Clusters::ParseClusterApplicationsArtifactService::RELEASE_NAMES.each do |release_name| + context release_name do + include_examples 'parse cluster applications artifact', release_name end end end diff --git a/spec/services/clusters/update_service_spec.rb b/spec/services/clusters/update_service_spec.rb index 5a7726eded8..e496ccd5c23 100644 --- a/spec/services/clusters/update_service_spec.rb +++ b/spec/services/clusters/update_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::UpdateService do +RSpec.describe Clusters::UpdateService do include KubernetesHelpers describe '#execute' do |