diff options
Diffstat (limited to 'spec/factories/clusters')
-rw-r--r-- | spec/factories/clusters/applications/helm.rb | 79 | ||||
-rw-r--r-- | spec/factories/clusters/integrations/prometheus.rb | 12 |
2 files changed, 42 insertions, 49 deletions
diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb index 01df5cc677d..1ff1292c36e 100644 --- a/spec/factories/clusters/applications/helm.rb +++ b/spec/factories/clusters/applications/helm.rb @@ -4,18 +4,26 @@ FactoryBot.define do factory :clusters_applications_helm, class: 'Clusters::Applications::Helm' do cluster factory: %i(cluster provided_by_gcp) - before(:create) do - allow(Gitlab::Kubernetes::Helm::V2::Certificate).to receive(:generate_root) - .and_return( - double( - key_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_key.key')), - cert_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_cert.pem')) + transient do + helm_installed { true } + end + + before(:create) do |_record, evaluator| + if evaluator.helm_installed + allow(Gitlab::Kubernetes::Helm::V2::Certificate).to receive(:generate_root) + .and_return( + double( + key_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_key.key')), + cert_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_cert.pem')) + ) ) - ) + end end - after(:create) do - allow(Gitlab::Kubernetes::Helm::V2::Certificate).to receive(:generate_root).and_call_original + after(:create) do |_record, evaluator| + if evaluator.helm_installed + allow(Gitlab::Kubernetes::Helm::V2::Certificate).to receive(:generate_root).and_call_original + end end trait :not_installable do @@ -69,19 +77,28 @@ FactoryBot.define do status { 10 } end + trait :externally_installed do + status { 11 } + end + trait :timed_out do installing updated_at { ClusterWaitForAppInstallationWorker::TIMEOUT.ago } end + # Common trait used by the apps below + trait :no_helm_installed do + cluster factory: %i(cluster provided_by_gcp) + + transient do + helm_installed { false } + end + end + factory :clusters_applications_ingress, class: 'Clusters::Applications::Ingress' do modsecurity_enabled { false } cluster factory: %i(cluster with_installed_helm provided_by_gcp) - trait :no_helm_installed do - cluster factory: %i(cluster provided_by_gcp) - end - trait :modsecurity_blocking do modsecurity_enabled { true } modsecurity_mode { :blocking } @@ -104,62 +121,34 @@ FactoryBot.define do factory :clusters_applications_cert_manager, class: 'Clusters::Applications::CertManager' do email { 'admin@example.com' } cluster factory: %i(cluster with_installed_helm provided_by_gcp) - - trait :no_helm_installed do - cluster factory: %i(cluster provided_by_gcp) - end end factory :clusters_applications_elastic_stack, class: 'Clusters::Applications::ElasticStack' do cluster factory: %i(cluster with_installed_helm provided_by_gcp) - - trait :no_helm_installed do - cluster factory: %i(cluster provided_by_gcp) - end end factory :clusters_applications_crossplane, class: 'Clusters::Applications::Crossplane' do stack { 'gcp' } cluster factory: %i(cluster with_installed_helm provided_by_gcp) - - trait :no_helm_installed do - cluster factory: %i(cluster provided_by_gcp) - end end factory :clusters_applications_prometheus, class: 'Clusters::Applications::Prometheus' do cluster factory: %i(cluster with_installed_helm provided_by_gcp) - - trait :no_helm_installed do - cluster factory: %i(cluster provided_by_gcp) - end end factory :clusters_applications_runner, class: 'Clusters::Applications::Runner' do runner factory: %i(ci_runner) cluster factory: %i(cluster with_installed_helm provided_by_gcp) - - trait :no_helm_installed do - cluster factory: %i(cluster provided_by_gcp) - end end factory :clusters_applications_knative, class: 'Clusters::Applications::Knative' do hostname { 'example.com' } cluster factory: %i(cluster with_installed_helm provided_by_gcp) - - trait :no_helm_installed do - cluster factory: %i(cluster provided_by_gcp) - end end factory :clusters_applications_jupyter, class: 'Clusters::Applications::Jupyter' do oauth_application factory: :oauth_application cluster factory: %i(cluster with_installed_helm provided_by_gcp project) - - trait :no_helm_installed do - cluster factory: %i(cluster provided_by_gcp) - end end factory :clusters_applications_fluentd, class: 'Clusters::Applications::Fluentd' do @@ -167,18 +156,10 @@ FactoryBot.define do waf_log_enabled { true } cilium_log_enabled { true } cluster factory: %i(cluster with_installed_helm provided_by_gcp) - - trait :no_helm_installed do - cluster factory: %i(cluster provided_by_gcp) - end end factory :clusters_applications_cilium, class: 'Clusters::Applications::Cilium' do cluster factory: %i(cluster with_installed_helm provided_by_gcp) - - trait :no_helm_installed do - cluster factory: %i(cluster provided_by_gcp) - end end end end diff --git a/spec/factories/clusters/integrations/prometheus.rb b/spec/factories/clusters/integrations/prometheus.rb new file mode 100644 index 00000000000..1f0bb1ed512 --- /dev/null +++ b/spec/factories/clusters/integrations/prometheus.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :clusters_integrations_prometheus, class: 'Clusters::Integrations::Prometheus' do + cluster factory: %i(cluster provided_by_gcp) + enabled { true } + + trait :disabled do + enabled { false } + end + end +end |