Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 15:09:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 15:09:29 +0300
commit3ca9a972f6bc4060a58703398df74d87703916cf (patch)
tree4c10ba27bd3e079ad156f030835179a6dd4dafa8 /spec/lib
parent76e68e67ab3e928d289361ac20558a053a623263 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/cache/json_caches/json_keyed_spec.rb2
-rw-r--r--spec/lib/gitlab/cache/json_caches/redis_keyed_spec.rb4
-rw-r--r--spec/lib/gitlab/ci/queue/metrics_spec.rb71
3 files changed, 74 insertions, 3 deletions
diff --git a/spec/lib/gitlab/cache/json_caches/json_keyed_spec.rb b/spec/lib/gitlab/cache/json_caches/json_keyed_spec.rb
index c4ec393c3ac..8afd5c2bfcd 100644
--- a/spec/lib/gitlab/cache/json_caches/json_keyed_spec.rb
+++ b/spec/lib/gitlab/cache/json_caches/json_keyed_spec.rb
@@ -51,7 +51,7 @@ RSpec.describe Gitlab::Cache::JsonCaches::JsonKeyed, feature_category: :shared d
current_cache = { '_other_revision_' => '_other_value_' }.merge(nested_cache_result).to_json
allow(backend).to receive(:read).with(expanded_key).and_return(current_cache)
- expect(cache.read(key, BroadcastMessage)).to eq(broadcast_message)
+ expect(cache.read(key, System::BroadcastMessage)).to eq(broadcast_message)
end
end
end
diff --git a/spec/lib/gitlab/cache/json_caches/redis_keyed_spec.rb b/spec/lib/gitlab/cache/json_caches/redis_keyed_spec.rb
index 6e98cdd74ce..f408bbf8d25 100644
--- a/spec/lib/gitlab/cache/json_caches/redis_keyed_spec.rb
+++ b/spec/lib/gitlab/cache/json_caches/redis_keyed_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe Gitlab::Cache::JsonCaches::RedisKeyed, feature_category: :shared
allow(backend).to receive(:read).with(expanded_key).and_return(true)
expect(Gitlab::Json).to receive(:parse).with("true").and_call_original
- expect(cache.read(key, BroadcastMessage)).to eq(true)
+ expect(cache.read(key, System::BroadcastMessage)).to eq(true)
end
end
@@ -30,7 +30,7 @@ RSpec.describe Gitlab::Cache::JsonCaches::RedisKeyed, feature_category: :shared
allow(backend).to receive(:read).with(expanded_key).and_return(false)
expect(Gitlab::Json).to receive(:parse).with("false").and_call_original
- expect(cache.read(key, BroadcastMessage)).to eq(false)
+ expect(cache.read(key, System::BroadcastMessage)).to eq(false)
end
end
end
diff --git a/spec/lib/gitlab/ci/queue/metrics_spec.rb b/spec/lib/gitlab/ci/queue/metrics_spec.rb
new file mode 100644
index 00000000000..2fb4226ba5a
--- /dev/null
+++ b/spec/lib/gitlab/ci/queue/metrics_spec.rb
@@ -0,0 +1,71 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Ci::Queue::Metrics, feature_category: :continuous_integration do
+ let(:metrics) { described_class.new(build(:ci_runner)) }
+
+ describe '#observe_queue_depth' do
+ subject { metrics.observe_queue_depth(:found, 1) }
+
+ it { is_expected.not_to be_nil }
+
+ context 'with feature flag gitlab_ci_builds_queueing_metrics disabled' do
+ before do
+ stub_feature_flags(gitlab_ci_builds_queuing_metrics: false)
+ end
+
+ it { is_expected.to be_nil }
+ end
+ end
+
+ describe '#observe_queue_size' do
+ subject { metrics.observe_queue_size(-> { 0 }, :some_runner_type) }
+
+ it { is_expected.not_to be_nil }
+
+ context 'with feature flag gitlab_ci_builds_queueing_metrics disabled' do
+ before do
+ stub_feature_flags(gitlab_ci_builds_queuing_metrics: false)
+ end
+
+ it { is_expected.to be_nil }
+ end
+ end
+
+ describe '#observe_queue_time' do
+ subject { metrics.observe_queue_time(:process, :some_runner_type) { 1 } }
+
+ specify do
+ expect(described_class).to receive(:queue_iteration_duration_seconds).and_call_original
+
+ subject
+ end
+
+ context 'with feature flag gitlab_ci_builds_queueing_metrics disabled' do
+ before do
+ stub_feature_flags(gitlab_ci_builds_queuing_metrics: false)
+ end
+
+ specify do
+ expect(described_class).not_to receive(:queue_iteration_duration_seconds)
+
+ subject
+ end
+ end
+
+ describe '.observe_active_runners' do
+ subject { described_class.observe_active_runners(-> { 0 }) }
+
+ it { is_expected.not_to be_nil }
+
+ context 'with feature flag gitlab_ci_builds_queueing_metrics disabled' do
+ before do
+ stub_feature_flags(gitlab_ci_builds_queuing_metrics: false)
+ end
+
+ it { is_expected.to be_nil }
+ end
+ end
+ end
+end