Commit 23d80005 authored by Thong Kuah's avatar Thong Kuah

Merge branch '241260-core-improve-spec-runtime-for-core' into 'master'

Improve  runtime of usage data core specs

See merge request gitlab-org/gitlab!41744
parents 6123685d a68822c4
...@@ -12,14 +12,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -12,14 +12,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
describe '.uncached_data' do describe '.uncached_data' do
describe '.usage_activity_by_stage' do describe '.usage_activity_by_stage' do
it 'includes usage_activity_by_stage data' do subject { described_class.uncached_data }
uncached_data = described_class.uncached_data
expect(uncached_data).to include(:usage_activity_by_stage) it 'includes usage_activity_by_stage data' do
expect(uncached_data).to include(:usage_activity_by_stage_monthly) is_expected.to include(:usage_activity_by_stage)
expect(uncached_data[:usage_activity_by_stage]) is_expected.to include(:usage_activity_by_stage_monthly)
expect(subject[:usage_activity_by_stage])
.to include(:configure, :create, :manage, :monitor, :plan, :release, :verify) .to include(:configure, :create, :manage, :monitor, :plan, :release, :verify)
expect(uncached_data[:usage_activity_by_stage_monthly]) expect(subject[:usage_activity_by_stage_monthly])
.to include(:configure, :create, :manage, :monitor, :plan, :release, :verify) .to include(:configure, :create, :manage, :monitor, :plan, :release, :verify)
end end
...@@ -34,15 +34,13 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -34,15 +34,13 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(described_class).to receive(:clear_memoization).with(key) expect(described_class).to receive(:clear_memoization).with(key)
end end
described_class.uncached_data subject
end end
it 'merge_requests_users is included only in montly counters' do it 'merge_requests_users is included only in montly counters' do
uncached_data = described_class.uncached_data expect(subject[:usage_activity_by_stage][:create])
expect(uncached_data[:usage_activity_by_stage][:create])
.not_to include(:merge_requests_users) .not_to include(:merge_requests_users)
expect(uncached_data[:usage_activity_by_stage_monthly][:create]) expect(subject[:usage_activity_by_stage_monthly][:create])
.to include(:merge_requests_users) .to include(:merge_requests_users)
end end
end end
...@@ -401,10 +399,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -401,10 +399,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(UsageDataHelpers::COUNTS_KEYS - count_data.keys).to be_empty expect(UsageDataHelpers::COUNTS_KEYS - count_data.keys).to be_empty
end end
it 'gathers usage counts monthly hash' do
expect(subject[:counts_monthly]).to be_an(Hash)
end
it 'gathers usage counts correctly' do it 'gathers usage counts correctly' do
count_data = subject[:counts] count_data = subject[:counts]
...@@ -492,10 +486,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -492,10 +486,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
) )
end end
it 'gathers topology data' do
expect(subject.keys).to include(:topology)
end
context 'with existing container expiration policies' do context 'with existing container expiration policies' do
let_it_be(:disabled) { create(:container_expiration_policy, enabled: false) } let_it_be(:disabled) { create(:container_expiration_policy, enabled: false) }
let_it_be(:enabled) { create(:container_expiration_policy, enabled: true) } let_it_be(:enabled) { create(:container_expiration_policy, enabled: true) }
......
...@@ -138,6 +138,7 @@ module UsageDataHelpers ...@@ -138,6 +138,7 @@ module UsageDataHelpers
USAGE_DATA_KEYS = %i( USAGE_DATA_KEYS = %i(
active_user_count active_user_count
counts counts
counts_monthly
recorded_at recorded_at
edition edition
version version
...@@ -162,6 +163,7 @@ module UsageDataHelpers ...@@ -162,6 +163,7 @@ module UsageDataHelpers
web_ide_clientside_preview_enabled web_ide_clientside_preview_enabled
ingress_modsecurity_enabled ingress_modsecurity_enabled
object_store object_store
topology
).freeze ).freeze
def stub_usage_data_connections def stub_usage_data_connections
......
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