summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Cunha <j.a.cunha@gmail.com>2019-06-07 16:33:32 +0100
committerJoão Cunha <j.a.cunha@gmail.com>2019-06-13 17:55:06 +0100
commit3001fea142e99237268b75a14feae08a8e843717 (patch)
tree24867501241582de46a58ba6d5d081c21af0ffdf
parentfa4ed2c8d0ccc0a2a7f2cb37aeb8e71ee93a6b73 (diff)
downloadgitlab-ce-feature/disable-knative-install-button.tar.gz
Knative must be found via a projectfeature/disable-knative-install-button
Since 27173 (merged), to find knative installation we need project.id
-rw-r--r--app/models/clusters/applications/knative.rb12
-rw-r--r--spec/features/projects/clusters/applications_spec.rb11
-rw-r--r--spec/models/clusters/applications/knative_spec.rb6
-rw-r--r--spec/services/clusters/applications/create_service_spec.rb3
-rw-r--r--spec/support/shared_examples/models/cluster_application_initial_status.rb4
5 files changed, 25 insertions, 11 deletions
diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb
index e782abc70ea..af401d4a3d4 100644
--- a/app/models/clusters/applications/knative.rb
+++ b/app/models/clusters/applications/knative.rb
@@ -20,6 +20,7 @@ module Clusters
def set_initial_status
return unless not_installable?
return unless verify_cluster?
+
return self.status_reason = EXTERNAL_KNATIVE_EXISTS_MSG if external_knative_exists?
self.status = 'installable'
@@ -81,7 +82,7 @@ module Clusters
private
def external_knative_exists?
- !cluster.application_knative_available? && cluster.knative_services_finder.knative_detected
+ !cluster.application_knative_available? && knative_installed_or_checking?
end
def install_knative_metrics
@@ -91,6 +92,15 @@ module Clusters
def verify_cluster?
cluster&.application_helm_available? && cluster&.platform_kubernetes_rbac?
end
+
+ def knative_installed_or_checking?
+ [
+ ::Clusters::KnativeServicesFinder::KNATIVE_STATES['installed'],
+ ::Clusters::KnativeServicesFinder::KNATIVE_STATES['checking']
+ ].include?(
+ cluster.knative_services_finder(cluster.projects.first).knative_detected
+ )
+ end
end
end
end
diff --git a/spec/features/projects/clusters/applications_spec.rb b/spec/features/projects/clusters/applications_spec.rb
index 527508b3519..f89aba6693b 100644
--- a/spec/features/projects/clusters/applications_spec.rb
+++ b/spec/features/projects/clusters/applications_spec.rb
@@ -13,6 +13,9 @@ describe 'Clusters Applications', :js do
describe 'Installing applications' do
before do
+ allow_any_instance_of(::Clusters::KnativeServicesFinder)
+ .to receive(:knative_detected)
+ .and_return(Clusters::KnativeServicesFinder::KNATIVE_STATES['uninstalled'])
visit project_cluster_path(project, cluster)
end
@@ -42,16 +45,14 @@ describe 'Clusters Applications', :js do
context 'when user installs Helm' do
before do
allow(ClusterInstallAppWorker).to receive(:perform_async)
-
- page.within('.js-cluster-application-row-helm') do
- page.find(:css, '.js-cluster-application-install-button').click
- end
-
wait_for_requests
end
it 'they see status transition' do
page.within('.js-cluster-application-row-helm') do
+ page.find(:css, '.js-cluster-application-install-button').click
+ wait_for_requests
+
# FE sends request and gets the response, then the buttons is "Installing"
expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing')
diff --git a/spec/models/clusters/applications/knative_spec.rb b/spec/models/clusters/applications/knative_spec.rb
index d71f8023729..6cf308c1740 100644
--- a/spec/models/clusters/applications/knative_spec.rb
+++ b/spec/models/clusters/applications/knative_spec.rb
@@ -152,7 +152,7 @@ describe Clusters::Applications::Knative do
before do
create(:clusters_applications_helm, :installed, cluster: cluster)
- allow_any_instance_of(Clusters::Cluster::KnativeServicesFinder)
+ allow_any_instance_of(::Clusters::KnativeServicesFinder)
.to receive(:knative_detected)
.and_return(state)
end
@@ -163,13 +163,13 @@ describe Clusters::Applications::Knative do
end
context 'when still checking for external Knative Service presence' do
- let(:state) { Clusters::Cluster::KnativeServicesFinder::KNATIVE_STATES['checking'] }
+ let(:state) { ::Clusters::KnativeServicesFinder::KNATIVE_STATES['checking'] }
it_behaves_like 'external knative exists'
end
context 'when external Knative Service exists' do
- let(:state) { Clusters::Cluster::KnativeServicesFinder::KNATIVE_STATES['installed'] }
+ let(:state) { ::Clusters::KnativeServicesFinder::KNATIVE_STATES['installed'] }
it_behaves_like 'external knative exists'
end
diff --git a/spec/services/clusters/applications/create_service_spec.rb b/spec/services/clusters/applications/create_service_spec.rb
index bb86a742f0e..c68736e0123 100644
--- a/spec/services/clusters/applications/create_service_spec.rb
+++ b/spec/services/clusters/applications/create_service_spec.rb
@@ -115,6 +115,9 @@ describe Clusters::Applications::CreateService do
end
before do
+ allow_any_instance_of(::Clusters::KnativeServicesFinder)
+ .to receive(:knative_detected)
+ .and_return(::Clusters::KnativeServicesFinder::KNATIVE_STATES['not_found'])
expect_any_instance_of(Clusters::Applications::Knative)
.to receive(:make_scheduled!)
.and_call_original
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 0362e228732..2fcb0443baa 100644
--- a/spec/support/shared_examples/models/cluster_application_initial_status.rb
+++ b/spec/support/shared_examples/models/cluster_application_initial_status.rb
@@ -19,9 +19,9 @@ shared_examples 'cluster application initial status specs' do |application_name|
context 'when application is scheduled' do
before do
if application_name == :clusters_applications_knative
- allow_any_instance_of(Clusters::Cluster::KnativeServicesFinder)
+ allow_any_instance_of(::Clusters::KnativeServicesFinder)
.to receive(:knative_detected)
- .and_return(Clusters::Cluster::KnativeServicesFinder::KNATIVE_STATES['uninstalled'])
+ .and_return(Clusters::KnativeServicesFinder::KNATIVE_STATES['uninstalled'])
end
create(:clusters_applications_helm, :installed, cluster: cluster)