Commit 1f3a4ac3 authored by svistas's avatar svistas Committed by Mark Lapierre

Fix monitor tests and de-quarantine

parent 135d32dc
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Monitor', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/217705', type: :flaky } do context 'Monitor' do
describe 'with Prometheus Gitlab-managed cluster', :orchestrated, :kubernetes, :docker, :runner do describe 'with Prometheus in a Gitlab-managed cluster', :orchestrated, :kubernetes do
before :all do before :all do
Flow::Login.sign_in @cluster = Service::KubernetesCluster.new.create!
@project, @runner = deploy_project_with_prometheus @project = Resource::Project.fabricate_via_api! do |project|
project.name = 'monitoring-project'
project.auto_devops_enabled = true
end
deploy_project_with_prometheus
end end
before do before do
...@@ -14,7 +19,6 @@ module QA ...@@ -14,7 +19,6 @@ module QA
end end
after :all do after :all do
@runner.remove_via_api!
@cluster.remove! @cluster.remove!
end end
...@@ -27,81 +31,94 @@ module QA ...@@ -27,81 +31,94 @@ module QA
it 'duplicates to create dashboard to custom' do it 'duplicates to create dashboard to custom' do
Page::Project::Menu.perform(&:go_to_operations_metrics) Page::Project::Menu.perform(&:go_to_operations_metrics)
Page::Project::Operations::Metrics::Show.perform do |dashboard| Page::Project::Operations::Metrics::Show.perform do |on_dashboard|
dashboard.duplicate_dashboard on_dashboard.duplicate_dashboard
expect(dashboard).to have_metrics expect(on_dashboard).to have_metrics
expect(dashboard).to have_edit_dashboard_enabled expect(on_dashboard).to have_edit_dashboard_enabled
end end
end end
it 'verifies data on filtered deployed environment' do it 'verifies data on filtered deployed environment' do
Page::Project::Menu.perform(&:go_to_operations_metrics) Page::Project::Menu.perform(&:go_to_operations_metrics)
Page::Project::Operations::Metrics::Show.perform do |dashboard| Page::Project::Operations::Metrics::Show.perform do |on_dashboard|
dashboard.filter_environment on_dashboard.filter_environment
expect(dashboard).to have_metrics expect(on_dashboard).to have_metrics
end end
end end
it 'filters using the quick range' do it 'filters using the quick range' do
Page::Project::Menu.perform(&:go_to_operations_metrics) Page::Project::Menu.perform(&:go_to_operations_metrics)
Page::Project::Operations::Metrics::Show.perform do |dashboard| Page::Project::Operations::Metrics::Show.perform do |on_dashboard|
dashboard.show_last('30 minutes') on_dashboard.show_last('30 minutes')
expect(dashboard).to have_metrics expect(on_dashboard).to have_metrics
dashboard.show_last('3 hours') on_dashboard.show_last('3 hours')
expect(dashboard).to have_metrics expect(on_dashboard).to have_metrics
dashboard.show_last('1 day') on_dashboard.show_last('1 day')
expect(dashboard).to have_metrics expect(on_dashboard).to have_metrics
end end
end end
private private
def deploy_project_with_prometheus def deploy_project_with_prometheus
project = Resource::Project.fabricate_via_api! do |project| %w[
project.name = 'cluster-with-prometheus' CODE_QUALITY_DISABLED TEST_DISABLED LICENSE_MANAGEMENT_DISABLED
project.description = 'Cluster with Prometheus' SAST_DISABLED DAST_DISABLED DEPENDENCY_SCANNING_DISABLED
CONTAINER_SCANNING_DISABLED PERFORMANCE_DISABLED
].each do |key|
Resource::CiVariable.fabricate_via_api! do |resource|
resource.project = @project
resource.key = key
resource.value = '1'
resource.masked = false
end
end end
runner = Resource::Runner.fabricate_via_api! do |runner| Flow::Login.sign_in
runner.project = project
runner.name = project.name
end
@cluster = Service::KubernetesCluster.new.create!
cluster_props = Resource::KubernetesCluster::ProjectCluster.fabricate! do |cluster_settings| Resource::KubernetesCluster::ProjectCluster.fabricate! do |cluster_settings|
cluster_settings.project = project cluster_settings.project = @project
cluster_settings.cluster = @cluster cluster_settings.cluster = @cluster
cluster_settings.install_helm_tiller = true cluster_settings.install_helm_tiller = true
cluster_settings.install_runner = true
cluster_settings.install_ingress = true cluster_settings.install_ingress = true
cluster_settings.install_prometheus = true cluster_settings.install_prometheus = true
end end
Resource::CiVariable.fabricate_via_api! do |ci_variable|
ci_variable.project = project
ci_variable.key = 'AUTO_DEVOPS_DOMAIN'
ci_variable.value = cluster_props.ingress_ip
ci_variable.masked = false
end
Resource::Repository::ProjectPush.fabricate! do |push| Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project push.project = @project
push.directory = Pathname push.directory = Pathname
.new(__dir__) .new(__dir__)
.join('../../../../fixtures/monitored_auto_devops') .join('../../../../fixtures/auto_devops_rack')
push.commit_message = 'Create AutoDevOps compatible Project for Monitoring' push.commit_message = 'Create AutoDevOps compatible Project for Monitoring'
end end
Page::Project::Menu.perform(&:click_ci_cd_pipelines) Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:wait_for_latest_pipeline_success_or_retry) Page::Project::Pipeline::Index.perform(&:click_on_latest_pipeline)
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('build')
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 600)
job.click_element(:pipeline_path)
end
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('production')
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 1200)
[project, runner] job.click_element(:pipeline_path)
end
end end
def verify_add_custom_metric def verify_add_custom_metric
...@@ -115,8 +132,8 @@ module QA ...@@ -115,8 +132,8 @@ module QA
Page::Project::Menu.perform(&:go_to_operations_metrics) Page::Project::Menu.perform(&:go_to_operations_metrics)
Page::Project::Operations::Metrics::Show.perform do |dashboard| Page::Project::Operations::Metrics::Show.perform do |on_dashboard|
expect(dashboard).to have_custom_metric('HTTP Requests Total') expect(on_dashboard).to have_custom_metric('HTTP Requests Total')
end end
end end
...@@ -130,8 +147,8 @@ module QA ...@@ -130,8 +147,8 @@ module QA
Page::Project::Menu.perform(&:go_to_operations_metrics) Page::Project::Menu.perform(&:go_to_operations_metrics)
Page::Project::Operations::Metrics::Show.perform do |dashboard| Page::Project::Operations::Metrics::Show.perform do |on_dashboard|
expect(dashboard).to have_custom_metric('Throughput') expect(on_dashboard).to have_custom_metric('Throughput')
end end
end end
...@@ -146,8 +163,8 @@ module QA ...@@ -146,8 +163,8 @@ module QA
Page::Project::Menu.perform(&:go_to_operations_metrics) Page::Project::Menu.perform(&:go_to_operations_metrics)
Page::Project::Operations::Metrics::Show.perform do |dashboard| Page::Project::Operations::Metrics::Show.perform do |on_dashboard|
expect(dashboard).not_to have_custom_metric('Throughput') expect(on_dashboard).not_to have_custom_metric('Throughput')
end end
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
require 'pathname'
module QA module QA
context 'Monitor', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/217705', type: :flaky } do context 'Monitor' do
describe 'with Prometheus Gitlab-managed cluster', :orchestrated, :kubernetes, :docker, :runner do describe 'with Prometheus in a Gitlab-managed cluster', :orchestrated, :kubernetes do
before :all do before :all do
@cluster = Service::KubernetesCluster.new.create! @cluster = Service::KubernetesCluster.new.create!
Flow::Login.sign_in @project = Resource::Project.fabricate_via_api! do |project|
@project, @runner = deploy_project_with_prometheus project.name = 'monitoring-project'
project.auto_devops_enabled = true
end
deploy_project_with_prometheus
end end
after :all do after :all do
@runner&.remove_via_api! @cluster.remove!
@cluster&.remove!
end end
before do before do
...@@ -22,26 +26,25 @@ module QA ...@@ -22,26 +26,25 @@ module QA
it 'allows configuration of alerts' do it 'allows configuration of alerts' do
Page::Project::Menu.perform(&:go_to_operations_metrics) Page::Project::Menu.perform(&:go_to_operations_metrics)
Page::Project::Operations::Metrics::Show.perform do |metrics| Page::Project::Operations::Metrics::Show.perform do |on_dashboard|
verify_metrics(metrics) verify_metrics(on_dashboard)
verify_add_alert(metrics) verify_add_alert(on_dashboard)
verify_edit_alert(metrics) verify_edit_alert(on_dashboard)
verify_persist_alert(metrics) verify_persist_alert(on_dashboard)
verify_delete_alert(metrics) verify_delete_alert(on_dashboard)
end end
end end
it 'observes cluster health graph' do it 'observes cluster health graph' do
Page::Project::Menu.perform(&:go_to_operations_kubernetes) Page::Project::Menu.perform(&:go_to_operations_kubernetes)
Page::Project::Operations::Kubernetes::Index.perform do |cluster| Page::Project::Operations::Kubernetes::Index.perform do |cluster_list|
cluster.click_on_cluster(@cluster) cluster_list.click_on_cluster(@cluster)
end end
Page::Project::Operations::Kubernetes::Show.perform do |cluster| Page::Project::Operations::Kubernetes::Show.perform do |cluster_panel|
cluster.open_health cluster_panel.open_health
cluster_panel.wait_for_cluster_health
cluster.wait_for_cluster_health
end end
end end
...@@ -65,87 +68,102 @@ module QA ...@@ -65,87 +68,102 @@ module QA
private private
def deploy_project_with_prometheus def deploy_project_with_prometheus
project = Resource::Project.fabricate_via_api! do |project| %w[
project.name = 'cluster-with-prometheus' CODE_QUALITY_DISABLED TEST_DISABLED LICENSE_MANAGEMENT_DISABLED
project.description = 'Cluster with Prometheus' SAST_DISABLED DAST_DISABLED DEPENDENCY_SCANNING_DISABLED
CONTAINER_SCANNING_DISABLED PERFORMANCE_DISABLED
].each do |key|
Resource::CiVariable.fabricate_via_api! do |resource|
resource.project = @project
resource.key = key
resource.value = '1'
resource.masked = false
end
end end
runner = Resource::Runner.fabricate_via_api! do |runner| Flow::Login.sign_in
runner.project = project
runner.name = project.name
end
cluster_props = Resource::KubernetesCluster::ProjectCluster.fabricate! do |cluster| Resource::KubernetesCluster::ProjectCluster.fabricate! do |cluster_settings|
cluster.project = project cluster_settings.project = @project
cluster.cluster = @cluster cluster_settings.cluster = @cluster
cluster.install_helm_tiller = true cluster_settings.install_helm_tiller = true
cluster.install_ingress = true cluster_settings.install_runner = true
cluster.install_prometheus = true cluster_settings.install_ingress = true
cluster_settings.install_prometheus = true
end end
Resource::Repository::ProjectPush.fabricate! do |push| Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project push.project = @project
push.directory = Pathname push.directory = Pathname
.new(__dir__) .new(__dir__)
.join('../../../../../fixtures/monitored_auto_devops') .join('../../../../../fixtures/auto_devops_rack')
push.commit_message = 'Create AutoDevOps compatible Project for Monitoring' push.commit_message = 'Create AutoDevOps compatible Project for Monitoring'
end end
Resource::CiVariable.fabricate_via_api! do |ci_variable| Page::Project::Menu.perform(&:click_ci_cd_pipelines)
ci_variable.project = project Page::Project::Pipeline::Index.perform(&:click_on_latest_pipeline)
ci_variable.key = 'AUTO_DEVOPS_DOMAIN'
ci_variable.value = cluster_props.ingress_ip Page::Project::Pipeline::Show.perform do |pipeline|
ci_variable.masked = false pipeline.click_job('build')
end end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 600)
Page::Project::Menu.perform(&:click_ci_cd_pipelines) job.click_element(:pipeline_path)
Page::Project::Pipeline::Index.perform(&:wait_for_latest_pipeline_success_or_retry) end
[project, runner] Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('production')
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 1200)
job.click_element(:pipeline_path)
end
end end
def verify_metrics(metrics) def verify_metrics(on_dashboard)
metrics.wait_for_metrics on_dashboard.wait_for_metrics
expect(metrics).to have_metrics expect(on_dashboard).to have_metrics
expect(metrics).not_to have_alert expect(on_dashboard).not_to have_alert
end end
def verify_add_alert(metrics) def verify_add_alert(on_dashboard)
metrics.write_first_alert('>', 0) on_dashboard.write_first_alert('>', 0)
expect(metrics).to have_alert expect(on_dashboard).to have_alert
end end
def verify_edit_alert(metrics) def verify_edit_alert(on_dashboard)
metrics.write_first_alert('<', 0) on_dashboard.write_first_alert('<', 0)
expect(metrics).to have_alert('<') expect(on_dashboard).to have_alert('<')
end end
def verify_persist_alert(metrics) def verify_persist_alert(on_dashboard)
metrics.refresh on_dashboard.refresh
metrics.wait_for_metrics on_dashboard.wait_for_metrics
metrics.wait_for_alert('<') on_dashboard.wait_for_alert('<')
expect(metrics).to have_alert('<') expect(on_dashboard).to have_alert('<')
end end
def verify_delete_alert(metrics) def verify_delete_alert(on_dashboard)
metrics.delete_first_alert on_dashboard.delete_first_alert
expect(metrics).not_to have_alert('<') expect(on_dashboard).not_to have_alert('<')
end end
def create_incident_template def create_incident_template
Page::Project::Menu.perform(&:go_to_operations_metrics) Page::Project::Menu.perform(&:go_to_operations_metrics)
@chart_link = Page::Project::Operations::Metrics::Show.perform do |metric| chart_link = Page::Project::Operations::Metrics::Show.perform do |on_dashboard|
metric.wait_for_metrics on_dashboard.wait_for_metrics
metric.copy_link_to_first_chart on_dashboard.copy_link_to_first_chart
end end
incident_template = "Incident Metric: #{@chart_link}" incident_template = "Incident Metric: #{chart_link}"
push_template_to_repository(incident_template) push_template_to_repository(incident_template)
end end
......
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