diff options
| author | João Cunha <j.a.cunha@gmail.com> | 2019-05-06 15:28:22 +0100 |
|---|---|---|
| committer | João Cunha <j.a.cunha@gmail.com> | 2019-06-07 15:25:49 +0100 |
| commit | 15d2f1f2d6324edba60ad33647c507f0c927d777 (patch) | |
| tree | 2194b4b5b161529094af308b51e1a71dd1ccc045 | |
| parent | 8cd197a0ddd1398bb84926da11c76dd1abdfa688 (diff) | |
| download | gitlab-ce-15d2f1f2d6324edba60ad33647c507f0c927d777.tar.gz | |
Initialize Knative status considering outside GitLab installations
3 files changed, 39 insertions, 3 deletions
diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb index d5a3bd62e3d..a8ee98bd259 100644 --- a/app/models/clusters/applications/knative.rb +++ b/app/models/clusters/applications/knative.rb @@ -20,7 +20,7 @@ module Clusters return unless not_installable? return unless verify_cluster? - self.status = 'installable' + self.status = 'installable' unless cluster.knative_services_finder.knative_detected end state_machine :status do diff --git a/spec/models/clusters/applications/knative_spec.rb b/spec/models/clusters/applications/knative_spec.rb index b38cf96de7e..bb2e2d1c5e9 100644 --- a/spec/models/clusters/applications/knative_spec.rb +++ b/spec/models/clusters/applications/knative_spec.rb @@ -9,7 +9,7 @@ describe Clusters::Applications::Knative do include_examples 'cluster application status specs', :clusters_applications_knative include_examples 'cluster application helm specs', :clusters_applications_knative include_examples 'cluster application version specs', :clusters_applications_knative - include_examples 'cluster application initial status specs' + include_examples 'cluster application initial status specs', :clusters_applications_knative before do allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in) @@ -143,4 +143,34 @@ describe Clusters::Applications::Knative do describe 'validations' do it { is_expected.to validate_presence_of(:hostname) } end + + describe '#status' do + subject { described_class.new(cluster: cluster) } + + let(:cluster) { create(:cluster, :provided_by_gcp) } + + before do + create(:clusters_applications_helm, :installed, cluster: cluster) + + allow_any_instance_of(Clusters::Cluster::KnativeServicesFinder) + .to receive(:knative_detected) + .and_return(state) + end + + context 'when still checking for external Knative Service presence' do + let(:state) { Clusters::Cluster::KnativeServicesFinder::KNATIVE_STATES['checking'] } + + it 'sets a default status' do + expect(subject.status_name).to be(:not_installable) + end + end + + context 'when external Knative Service exists' do + let(:state) { Clusters::Cluster::KnativeServicesFinder::KNATIVE_STATES['installed'] } + + it 'sets a default status' do + expect(subject.status_name).to be(:not_installable) + end + end + end end diff --git a/spec/support/shared_examples/models/cluster_application_initial_status.rb b/spec/support/shared_examples/models/cluster_application_initial_status.rb index 9775d87953c..0362e228732 100644 --- a/spec/support/shared_examples/models/cluster_application_initial_status.rb +++ b/spec/support/shared_examples/models/cluster_application_initial_status.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -shared_examples 'cluster application initial status specs' do +shared_examples 'cluster application initial status specs' do |application_name| describe '#status' do let(:cluster) { create(:cluster, :provided_by_gcp) } @@ -18,6 +18,12 @@ shared_examples 'cluster application initial status specs' do context 'when application is scheduled' do before do + if application_name == :clusters_applications_knative + allow_any_instance_of(Clusters::Cluster::KnativeServicesFinder) + .to receive(:knative_detected) + .and_return(Clusters::Cluster::KnativeServicesFinder::KNATIVE_STATES['uninstalled']) + end + create(:clusters_applications_helm, :installed, cluster: cluster) end |
