diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/features/clusters | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/features/clusters')
-rw-r--r-- | spec/features/clusters/cluster_health_dashboard_spec.rb | 93 | ||||
-rw-r--r-- | spec/features/clusters/installing_applications_shared_examples.rb | 53 |
2 files changed, 129 insertions, 17 deletions
diff --git a/spec/features/clusters/cluster_health_dashboard_spec.rb b/spec/features/clusters/cluster_health_dashboard_spec.rb new file mode 100644 index 00000000000..e9e3b48e9c0 --- /dev/null +++ b/spec/features/clusters/cluster_health_dashboard_spec.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Cluster Health board', :js, :kubeclient, :use_clean_rails_memory_store_caching, :sidekiq_inline do + include KubernetesHelpers + include PrometheusHelpers + + let_it_be(:current_user) { create(:user) } + let_it_be(:clusterable) { create(:project) } + let_it_be(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) } + let_it_be(:cluster_path) { project_cluster_path(clusterable, cluster) } + + before do + clusterable.add_maintainer(current_user) + + sign_in(current_user) + end + + it 'shows cluster board section within the page' do + visit cluster_path + + expect(page).to have_text('Health') + + click_link 'Health' + + expect(page).to have_css('.cluster-health-graphs') + end + + context 'no prometheus installed' do + it 'shows install prometheus message' do + visit cluster_path + + click_link 'Health' + + expect(page).to have_text('you must first install Prometheus in the Applications tab') + end + end + + context 'when there is cluster with installed prometheus' do + before do + create(:clusters_applications_prometheus, :installed, cluster: cluster) + stub_kubeclient_discover(cluster.platform.api_url) + end + + context 'waiting for data' do + before do + stub_empty_response + end + + it 'shows container and waiting for data message' do + visit cluster_path + + click_link 'Health' + + wait_for_requests + + expect(page).to have_css('.prometheus-graphs') + expect(page).to have_text('Waiting for performance data') + end + end + + context 'connected, prometheus returns data' do + before do + stub_connected + end + + it 'renders charts' do + visit cluster_path + + click_link 'Health' + + wait_for_requests + + expect(page).to have_css('.prometheus-graphs') + expect(page).to have_css('.prometheus-graph') + expect(page).to have_css('.prometheus-graph-title') + expect(page).to have_css('[_echarts_instance_]') + expect(page).to have_content('Avg') + end + end + + def stub_empty_response + stub_prometheus_request(/prometheus-prometheus-server/, status: 204, body: {}) + stub_prometheus_request(/prometheus\/api\/v1/, status: 204, body: {}) + end + + def stub_connected + stub_prometheus_request(/prometheus-prometheus-server/, body: prometheus_values_body) + stub_prometheus_request(/prometheus\/api\/v1/, body: prometheus_values_body) + end + end +end diff --git a/spec/features/clusters/installing_applications_shared_examples.rb b/spec/features/clusters/installing_applications_shared_examples.rb index d2f28f5b219..74150c42519 100644 --- a/spec/features/clusters/installing_applications_shared_examples.rb +++ b/spec/features/clusters/installing_applications_shared_examples.rb @@ -2,6 +2,9 @@ RSpec.shared_examples "installing applications for a cluster" do |managed_apps_local_tiller| before do + # Reduce interval from 10 seconds which is too long for an automated test + stub_const("#{Clusters::ClustersController}::STATUS_POLLING_INTERVAL", 500) + stub_feature_flags(managed_apps_local_tiller: managed_apps_local_tiller) visit cluster_path @@ -107,10 +110,6 @@ RSpec.shared_examples "installing applications for a cluster" do |managed_apps_l end describe 'when user clicks install button' do - def domainname_form_value - page.find('.js-knative-domainname').value - end - before do allow(ClusterInstallAppWorker).to receive(:perform_async) allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in) @@ -135,7 +134,7 @@ RSpec.shared_examples "installing applications for a cluster" do |managed_apps_l it 'shows status transition' do page.within('.js-cluster-application-row-knative') do - expect(domainname_form_value).to eq('domain.example.org') + expect(page).to have_field('Knative Domain Name:', with: 'domain.example.org') expect(page).to have_css('.js-cluster-application-uninstall-button', exact_text: 'Uninstall') end @@ -147,7 +146,7 @@ RSpec.shared_examples "installing applications for a cluster" do |managed_apps_l page.within('.js-cluster-application-row-knative') do expect(ClusterPatchAppWorker).to receive(:perform_async) - expect(domainname_form_value).to eq('domain.example.org') + expect(page).to have_field('Knative Domain Name:', with: 'domain.example.org') page.find('.js-knative-domainname').set("new.domain.example.org") @@ -155,7 +154,7 @@ RSpec.shared_examples "installing applications for a cluster" do |managed_apps_l wait_for_requests - expect(domainname_form_value).to eq('new.domain.example.org') + expect(page).to have_field('Knative Domain Name:', with: 'new.domain.example.org') end end end @@ -169,34 +168,54 @@ RSpec.shared_examples "installing applications for a cluster" do |managed_apps_l allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async) create(:clusters_applications_helm, :installed, cluster: cluster) unless managed_apps_local_tiller + end + it 'shows status transition' do page.within('.js-cluster-application-row-cert_manager') do click_button 'Install' + wait_for_requests + + expect(page).to have_field('Issuer Email', with: cluster.user.email) + expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') + + Clusters::Cluster.last.application_cert_manager.make_installing! + + expect(page).to have_field('Issuer Email', with: cluster.user.email) + expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') + + Clusters::Cluster.last.application_cert_manager.make_installed! + + expect(page).to have_field('Issuer Email', with: cluster.user.email) + expect(page).to have_css('.js-cluster-application-uninstall-button', exact_text: 'Uninstall') end + + expect(page).to have_content('Cert-Manager was successfully installed on your Kubernetes cluster') end - it 'shows status transition' do - def email_form_value - page.find('.js-email').value - end + it 'installs with custom email' do + custom_email = 'new_email@example.org' page.within('.js-cluster-application-row-cert_manager') do - expect(email_form_value).to eq(cluster.user.email) + # Wait for the polling to finish + wait_for_requests + + page.find('.js-email').set(custom_email) + click_button 'Install' + wait_for_requests + + expect(page).to have_field('Issuer Email', with: custom_email) expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') - page.find('.js-email').set("new_email@example.org") Clusters::Cluster.last.application_cert_manager.make_installing! - expect(email_form_value).to eq('new_email@example.org') + expect(page).to have_field('Issuer Email', with: custom_email) expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') Clusters::Cluster.last.application_cert_manager.make_installed! - expect(email_form_value).to eq('new_email@example.org') + expect(page).to have_field('Issuer Email', with: custom_email) expect(page).to have_css('.js-cluster-application-uninstall-button', exact_text: 'Uninstall') end - - expect(page).to have_content('Cert-Manager was successfully installed on your Kubernetes cluster') end end |