Commit be1011fe authored by Markus Koller's avatar Markus Koller

Merge branch 'aa-speed-up-ee-usage-data-spec' into 'master'

Speed up EE usage data specs

See merge request gitlab-org/gitlab!38775
parents 71ce21e3 57741742
......@@ -268,8 +268,10 @@ RSpec.describe Gitlab::UsageData do
expect(described_class.uncached_data).to include(:usage_activity_by_stage)
expect(described_class.uncached_data).to include(:usage_activity_by_stage_monthly)
end
end
end
context 'for configure' do
describe 'usage_activity_by_stage_configure' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
user = create(:user)
......@@ -279,12 +281,12 @@ RSpec.describe Gitlab::UsageData do
create(:prometheus_service, project: project)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:configure]).to include(
expect(described_class.usage_activity_by_stage_configure({})).to include(
projects_slack_notifications_active: 2,
projects_slack_slash_active: 2,
projects_with_prometheus_alerts: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:configure]).to include(
expect(described_class.usage_activity_by_stage_configure(described_class.last_28_days_time_period)).to include(
projects_slack_notifications_active: 1,
projects_slack_slash_active: 1,
projects_with_prometheus_alerts: 1
......@@ -292,7 +294,7 @@ RSpec.describe Gitlab::UsageData do
end
end
context 'for create' do
describe 'usage_activity_by_stage_create' do
it 'includes accurate usage_activity_by_stage data', :aggregate_failures do
for_defined_days_back do
user = create(:user)
......@@ -316,7 +318,7 @@ RSpec.describe Gitlab::UsageData do
create_list(:code_owner_rule, 2)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:create]).to include(
expect(described_class.usage_activity_by_stage_create({})).to include(
approval_project_rules: 6,
approval_project_rules_with_target_branch: 2,
projects_enforcing_code_owner_approval: 0,
......@@ -328,7 +330,7 @@ RSpec.describe Gitlab::UsageData do
protected_branches: 2,
suggestions: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:create]).to include(
expect(described_class.usage_activity_by_stage_create(described_class.last_28_days_time_period)).to include(
approval_project_rules: 6,
approval_project_rules_with_target_branch: 2,
projects_enforcing_code_owner_approval: 0,
......@@ -343,7 +345,7 @@ RSpec.describe Gitlab::UsageData do
end
end
context 'for manage' do
describe 'usage_activity_by_stage_manage' do
it 'includes accurate usage_activity_by_stage data' do
stub_config(
ldap:
......@@ -358,7 +360,7 @@ RSpec.describe Gitlab::UsageData do
create(:compliance_framework_project_setting)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:manage]).to include(
expect(described_class.usage_activity_by_stage_manage({})).to include(
ldap_keys: 2,
ldap_users: 2,
value_stream_management_customized_group_stages: 2,
......@@ -368,7 +370,7 @@ RSpec.describe Gitlab::UsageData do
ldap_admin_sync_enabled: true,
group_saml_enabled: true
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:manage]).to include(
expect(described_class.usage_activity_by_stage_manage(described_class.last_28_days_time_period)).to include(
ldap_keys: 1,
ldap_users: 1,
value_stream_management_customized_group_stages: 2,
......@@ -398,7 +400,7 @@ RSpec.describe Gitlab::UsageData do
end
end
context 'for monitor' do
describe 'usage_activity_by_stage_monitor' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
user = create(:user, dashboard: 'operations')
......@@ -409,13 +411,13 @@ RSpec.describe Gitlab::UsageData do
create(:project_tracing_setting, project: project)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:monitor]).to include(
expect(described_class.usage_activity_by_stage_monitor({})).to include(
operations_dashboard_users_with_projects_added: 2,
projects_prometheus_active: 2,
projects_with_error_tracking_enabled: 2,
projects_with_tracing_enabled: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:monitor]).to include(
expect(described_class.usage_activity_by_stage_monitor(described_class.last_28_days_time_period)).to include(
operations_dashboard_users_with_projects_added: 1,
projects_prometheus_active: 1,
projects_with_error_tracking_enabled: 1,
......@@ -424,22 +426,22 @@ RSpec.describe Gitlab::UsageData do
end
end
context 'for package' do
describe 'usage_activity_by_stage_package' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
create(:project, packages: [create(:package)] )
end
expect(described_class.uncached_data[:usage_activity_by_stage][:package]).to eq(
expect(described_class.usage_activity_by_stage_package({})).to eq(
projects_with_packages: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:package]).to eq(
expect(described_class.usage_activity_by_stage_package(described_class.last_28_days_time_period)).to eq(
projects_with_packages: 1
)
end
end
context 'for plan' do
describe 'usage_activity_by_stage_plan' do
it 'includes accurate usage_activity_by_stage data' do
stub_licensed_features(board_assignee_lists: true, board_milestone_lists: true)
......@@ -455,7 +457,7 @@ RSpec.describe Gitlab::UsageData do
create(:jira_service, active: true, project: create(:project, :jira_dvcs_server, creator: user))
end
expect(described_class.uncached_data[:usage_activity_by_stage][:plan]).to include(
expect(described_class.usage_activity_by_stage_plan({})).to include(
assignee_lists: 2,
epics: 2,
label_lists: 2,
......@@ -464,7 +466,7 @@ RSpec.describe Gitlab::UsageData do
projects_jira_dvcs_cloud_active: 2,
projects_jira_dvcs_server_active: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:plan]).to include(
expect(described_class.usage_activity_by_stage_plan(described_class.last_28_days_time_period)).to include(
assignee_lists: 1,
epics: 1,
label_lists: 1,
......@@ -476,22 +478,22 @@ RSpec.describe Gitlab::UsageData do
end
end
context 'for release' do
describe 'usage_activity_by_stage_release' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
create(:project, :mirror, mirror_trigger_builds: true)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:release]).to include(
expect(described_class.usage_activity_by_stage_release({})).to include(
projects_mirrored_with_pipelines_enabled: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:release]).to include(
expect(described_class.usage_activity_by_stage_release(described_class.last_28_days_time_period)).to include(
projects_mirrored_with_pipelines_enabled: 1
)
end
end
context 'for secure' do
describe 'usage_activity_by_stage_secure' do
let_it_be(:user) { create(:user, group_view: :security_dashboard) }
let_it_be(:user2) { create(:user, group_view: :security_dashboard) }
let_it_be(:user3) { create(:user, group_view: :security_dashboard) }
......@@ -508,7 +510,7 @@ RSpec.describe Gitlab::UsageData do
end
it 'includes accurate usage_activity_by_stage data' do
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:secure]).to eq(
expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq(
user_preferences_group_overview_security_dashboard: 3,
user_container_scanning_jobs: 1,
user_dast_jobs: 1,
......@@ -540,7 +542,7 @@ RSpec.describe Gitlab::UsageData do
create(:security_scan, build: sast_build, scan_type: 'sast')
end
expect(described_class.uncached_data[:usage_activity_by_stage][:secure]).to include(
expect(described_class.usage_activity_by_stage_secure({})).to include(
user_preferences_group_overview_security_dashboard: 3,
user_container_scanning_jobs: 1,
user_dast_jobs: 1,
......@@ -551,7 +553,7 @@ RSpec.describe Gitlab::UsageData do
user_unique_users_all_secure_scanners: 1
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:secure]).to include(
expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to include(
user_preferences_group_overview_security_dashboard: 3,
user_container_scanning_jobs: 1,
user_dast_jobs: 1,
......@@ -576,7 +578,7 @@ RSpec.describe Gitlab::UsageData do
create(:ci_build, name: 'dast', user: user3)
end
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:secure]).to eq(
expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq(
user_preferences_group_overview_security_dashboard: 3,
user_container_scanning_jobs: 1,
user_dast_jobs: 3,
......@@ -599,7 +601,7 @@ RSpec.describe Gitlab::UsageData do
create(:ci_build, name: 'license_scanning', user: user)
end
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:secure]).to eq(
expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq(
user_preferences_group_overview_security_dashboard: 3,
user_container_scanning_jobs: 1,
user_dast_jobs: 1,
......@@ -621,7 +623,7 @@ RSpec.describe Gitlab::UsageData do
allow(Gitlab::Database::BatchCount).to receive(:batch_distinct_count).and_raise(ActiveRecord::StatementInvalid)
allow(::Ci::Build).to receive(:distinct_count_by).and_raise(ActiveRecord::StatementInvalid)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:secure]).to eq(
expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq(
user_preferences_group_overview_security_dashboard: 3,
user_container_scanning_jobs: -1,
user_dast_jobs: -1,
......@@ -640,20 +642,18 @@ RSpec.describe Gitlab::UsageData do
end
end
context 'for verify' do
describe 'usage_activity_by_stage_verify' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
create(:github_service)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:verify]).to include(
expect(described_class.usage_activity_by_stage_verify({})).to include(
projects_reporting_ci_cd_back_to_github: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:verify]).to include(
expect(described_class.usage_activity_by_stage_verify(described_class.last_28_days_time_period)).to include(
projects_reporting_ci_cd_back_to_github: 1
)
end
end
end
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