Commit ed2f7e23 authored by João Cunha's avatar João Cunha Committed by Kamil Trzciński

Rename scope to imply :installed and :updated result

- Adds to specs the case where apps are also updated
- Rename scope calls on Gitlab::UsageData and Clusters::Cluster
- Removes a duplicated spec
parent 0b966fb0
...@@ -99,7 +99,7 @@ module Clusters ...@@ -99,7 +99,7 @@ module Clusters
where('NOT EXISTS (?)', subquery) where('NOT EXISTS (?)', subquery)
end end
scope :with_knative_installed, -> { joins(:application_knative).merge(Clusters::Applications::Knative.installed) } scope :with_knative_installed, -> { joins(:application_knative).merge(Clusters::Applications::Knative.available) }
scope :preload_knative, -> { scope :preload_knative, -> {
preload( preload(
......
...@@ -6,7 +6,14 @@ module Clusters ...@@ -6,7 +6,14 @@ module Clusters
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
scope :installed, -> { where(status: self.state_machines[:status].states[:installed].value) } scope :available, -> do
where(
status: [
self.state_machines[:status].states[:installed].value,
self.state_machines[:status].states[:updated].value
]
)
end
state_machine :status, initial: :not_installable do state_machine :status, initial: :not_installable do
state :not_installable, value: -2 state :not_installable, value: -2
......
---
title: Fixes functions finder for upgraded Knative app
merge_request: 25067
author:
type: fixed
...@@ -64,12 +64,12 @@ module Gitlab ...@@ -64,12 +64,12 @@ module Gitlab
group_clusters_disabled: count(::Clusters::Cluster.disabled.group_type), group_clusters_disabled: count(::Clusters::Cluster.disabled.group_type),
clusters_platforms_gke: count(::Clusters::Cluster.gcp_installed.enabled), clusters_platforms_gke: count(::Clusters::Cluster.gcp_installed.enabled),
clusters_platforms_user: count(::Clusters::Cluster.user_provided.enabled), clusters_platforms_user: count(::Clusters::Cluster.user_provided.enabled),
clusters_applications_helm: count(::Clusters::Applications::Helm.installed), clusters_applications_helm: count(::Clusters::Applications::Helm.available),
clusters_applications_ingress: count(::Clusters::Applications::Ingress.installed), clusters_applications_ingress: count(::Clusters::Applications::Ingress.available),
clusters_applications_cert_managers: count(::Clusters::Applications::CertManager.installed), clusters_applications_cert_managers: count(::Clusters::Applications::CertManager.available),
clusters_applications_prometheus: count(::Clusters::Applications::Prometheus.installed), clusters_applications_prometheus: count(::Clusters::Applications::Prometheus.available),
clusters_applications_runner: count(::Clusters::Applications::Runner.installed), clusters_applications_runner: count(::Clusters::Applications::Runner.available),
clusters_applications_knative: count(::Clusters::Applications::Knative.installed), clusters_applications_knative: count(::Clusters::Applications::Knative.available),
in_review_folder: count(::Environment.in_review_folder), in_review_folder: count(::Environment.in_review_folder),
groups: count(Group), groups: count(Group),
issues: count(Issue), issues: count(Issue),
......
...@@ -3,16 +3,17 @@ require 'rails_helper' ...@@ -3,16 +3,17 @@ require 'rails_helper'
describe Clusters::Applications::Helm do describe Clusters::Applications::Helm do
include_examples 'cluster application core specs', :clusters_applications_helm include_examples 'cluster application core specs', :clusters_applications_helm
describe '.installed' do describe '.available' do
subject { described_class.installed } subject { described_class.available }
let!(:installed_cluster) { create(:clusters_applications_helm, :installed) } let!(:installed_cluster) { create(:clusters_applications_helm, :installed) }
let!(:updated_cluster) { create(:clusters_applications_helm, :updated) }
before do before do
create(:clusters_applications_helm, :errored) create(:clusters_applications_helm, :errored)
end end
it { is_expected.to contain_exactly(installed_cluster) } it { is_expected.to contain_exactly(installed_cluster, updated_cluster) }
end end
describe '#issue_client_cert' do describe '#issue_client_cert' do
......
...@@ -16,18 +16,6 @@ describe Clusters::Applications::Ingress do ...@@ -16,18 +16,6 @@ describe Clusters::Applications::Ingress do
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async) allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async)
end end
describe '.installed' do
subject { described_class.installed }
let!(:cluster) { create(:clusters_applications_ingress, :installed) }
before do
create(:clusters_applications_ingress, :errored)
end
it { is_expected.to contain_exactly(cluster) }
end
describe '#make_installed!' do describe '#make_installed!' do
before do before do
application.make_installed! application.make_installed!
......
...@@ -24,30 +24,6 @@ describe Clusters::Applications::Knative do ...@@ -24,30 +24,6 @@ describe Clusters::Applications::Knative do
it { expect(knative_no_rbac).to be_not_installable } it { expect(knative_no_rbac).to be_not_installable }
end end
describe '.installed' do
subject { described_class.installed }
let!(:cluster) { create(:clusters_applications_knative, :installed) }
before do
create(:clusters_applications_knative, :errored)
end
it { is_expected.to contain_exactly(cluster) }
end
describe '#make_installed' do
subject { described_class.installed }
let!(:cluster) { create(:clusters_applications_knative, :installed) }
before do
create(:clusters_applications_knative, :errored)
end
it { is_expected.to contain_exactly(cluster) }
end
describe 'make_installed with external_ip' do describe 'make_installed with external_ip' do
before do before do
application.make_installed! application.make_installed!
......
...@@ -9,18 +9,6 @@ describe Clusters::Applications::Prometheus do ...@@ -9,18 +9,6 @@ describe Clusters::Applications::Prometheus do
include_examples 'cluster application helm specs', :clusters_applications_prometheus include_examples 'cluster application helm specs', :clusters_applications_prometheus
include_examples 'cluster application initial status specs' include_examples 'cluster application initial status specs'
describe '.installed' do
subject { described_class.installed }
let!(:cluster) { create(:clusters_applications_prometheus, :installed) }
before do
create(:clusters_applications_prometheus, :errored)
end
it { is_expected.to contain_exactly(cluster) }
end
describe 'transition to installed' do describe 'transition to installed' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:cluster) { create(:cluster, :with_installed_helm, projects: [project]) } let(:cluster) { create(:cluster, :with_installed_helm, projects: [project]) }
...@@ -192,7 +180,7 @@ describe Clusters::Applications::Prometheus do ...@@ -192,7 +180,7 @@ describe Clusters::Applications::Prometheus do
end end
context 'with knative installed' do context 'with knative installed' do
let(:knative) { create(:clusters_applications_knative, :installed ) } let(:knative) { create(:clusters_applications_knative, :updated ) }
let(:prometheus) { create(:clusters_applications_prometheus, cluster: knative.cluster) } let(:prometheus) { create(:clusters_applications_prometheus, cluster: knative.cluster) }
subject { prometheus.install_command } subject { prometheus.install_command }
......
...@@ -11,18 +11,6 @@ describe Clusters::Applications::Runner do ...@@ -11,18 +11,6 @@ describe Clusters::Applications::Runner do
it { is_expected.to belong_to(:runner) } it { is_expected.to belong_to(:runner) }
describe '.installed' do
subject { described_class.installed }
let!(:cluster) { create(:clusters_applications_runner, :installed) }
before do
create(:clusters_applications_runner, :errored)
end
it { is_expected.to contain_exactly(cluster) }
end
describe '#install_command' do describe '#install_command' do
let(:kubeclient) { double('kubernetes client') } let(:kubeclient) { double('kubernetes client') }
let(:gitlab_runner) { create(:clusters_applications_runner, runner: ci_runner) } let(:gitlab_runner) { create(:clusters_applications_runner, runner: ci_runner) }
......
...@@ -9,6 +9,19 @@ shared_examples 'cluster application status specs' do |application_name| ...@@ -9,6 +9,19 @@ shared_examples 'cluster application status specs' do |application_name|
end end
end end
describe '.available' do
subject { described_class.available }
let!(:installed_cluster) { create(application_name, :installed) }
let!(:updated_cluster) { create(application_name, :updated) }
before do
create(application_name, :errored)
end
it { is_expected.to contain_exactly(installed_cluster, updated_cluster) }
end
describe 'status state machine' do describe 'status state machine' do
describe '#make_installing' do describe '#make_installing' do
subject { create(application_name, :scheduled) } subject { create(application_name, :scheduled) }
......
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